A call-back to handle events from the native media player.
There are some important implementation details for this callback:
- First, the event notifications are off-loaded to a different thread so as to prevent application code re-entering libvlc in an event call-back which may lead to a deadlock in the native code;
- Second, the native event union structure refers to natively allocated memory which will not be in the scope of the thread used to actually dispatch the event notifications.
Without copying the fields at this point from the native union structure, the native memory referred to by the native event is likely to get deallocated and overwritten by the time the notification thread runs. This would lead to unreliable data being sent with the notification, or even a fatal JVM crash.