<div dir="ltr"><div>Hi,<br><br>> You can use calloc, instead of setting everything to NULL<br><br>Ok. Will fix that.<br><br>> Where does myJavaLibVLC come from ?<br><br>My mistake. I will fix this. I could have missed a commit. This is the LibVLC java object. You can change it to "thiz".<br><br>> I won't apply on master.<br>> I just removed jni_LockAndGetAndroidSurface and vout_android_surf in a<br>> recent commit.<br>> And I added this new function: jni_AndroidJavaSurfaceToNativeSurface.<br>> But It should be easy to merge since it'll work with your new<br>> android_surface struct.<br><br>I made the commit based on master. You won't find jni_LockAndGetAndroidSurface. I will remove<br>vout_android_surf from the struct.<br><br>> Why not having EventHandler an object inside LibVLC ?<br>> So, To get the EventHandler: mLibVlc.getEventHandler() (from java and<br>> native).<br>> That way, you can get ride of all hashmap and you don't have to call<br>> EventHandler methods with an instance of LibVlc.<br><br>Will check that. Will take a little while to get that done.<br><br></div>Thanks<br><div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-25 6:35 GMT-02:00 Thomas Guillem <span dir="ltr"><<a href="mailto:thomas@gllm.fr" target="_blank">thomas@gllm.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Great, I was waiting for this, I can't stand the static everywhere...<br>
<div><div class="h5"><br>
On Tue, Nov 25, 2014, at 01:28, Paulo Vitor Magacho da Silva wrote:<br>
> ---<br>
> libvlc/jni/libvlcjni-util.c | 2 +-<br>
> libvlc/jni/libvlcjni.c | 59 ++++++--<br>
> libvlc/jni/native_crash_handler.c | 81 +++++++++-<br>
> libvlc/jni/native_crash_handler.h | 4 +-<br>
> libvlc/jni/vout.c | 163<br>
> ++++++++++++---------<br>
> libvlc/jni/vout.h | 14 +-<br>
> libvlc/src/org/videolan/libvlc/EventHandler.java | 33 +++--<br>
> libvlc/src/org/videolan/libvlc/LibVLC.java | 21 ++-<br>
> libvlc/src/org/videolan/libvlc/MediaList.java | 8 +-<br>
> .../src/org/videolan/vlc/audio/AudioService.java | 16 +-<br>
> .../src/org/videolan/vlc/gui/HistoryAdapter.java | 2 +-<br>
> .../org/videolan/vlc/gui/PreferencesActivity.java | 2 +-<br>
> .../vlc/gui/video/VideoPlayerActivity.java | 6 +-<br>
> 13 files changed, 290 insertions(+), 121 deletions(-)<br>
><br>
> diff --git a/libvlc/jni/libvlcjni-util.c b/libvlc/jni/libvlcjni-util.c<br>
> index 205d59d..0a3cae9 100644<br>
> --- a/libvlc/jni/libvlcjni-util.c<br>
> +++ b/libvlc/jni/libvlcjni-util.c<br>
> @@ -139,7 +139,7 @@ jobject getEventHandlerReference(JNIEnv *env, jobject<br>
> thiz, jobject eventHandler<br>
> return NULL;<br>
> }<br>
><br>
> - jmethodID methodID = (*env)->GetMethodID(env, cls, "callback",<br>
> "(ILandroid/os/Bundle;)V");<br>
> + jmethodID methodID = (*env)->GetMethodID(env, cls, "callback",<br>
> "(ILandroid/os/Bundle;Lorg/videolan/libvlc/LibVLC;)V");<br>
> if (!methodID) {<br>
> LOGE("setEventHandler: failed to get the callback method");<br>
> return NULL;<br>
> diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c<br>
> index 7edd52f..833bbef 100644<br>
> --- a/libvlc/jni/libvlcjni.c<br>
> +++ b/libvlc/jni/libvlcjni.c<br>
> @@ -195,9 +195,10 @@ static void vlc_event_callback(const libvlc_event_t<br>
> *ev, void *data)<br>
> }<br>
><br>
> /* Find the callback ID */<br>
> - jmethodID methodID = (*env)->GetMethodID(env, cls, "callback",<br>
> "(ILandroid/os/Bundle;)V");<br>
> + jobject vlcObject = (jobject) data;<br>
> + jmethodID methodID = (*env)->GetMethodID(env, cls, "callback",<br>
> "(ILandroid/os/Bundle;Lorg/videolan/libvlc/LibVLC;)V");<br>
> if (methodID) {<br>
> - (*env)->CallVoidMethod(env, eventHandlerInstance, methodID,<br>
> ev->type, bundle);<br>
> + (*env)->CallVoidMethod(env, eventHandlerInstance, methodID,<br>
> ev->type, bundle, vlcObject);<br>
> } else {<br>
> LOGE("EventHandler: failed to get the callback method");<br>
> }<br>
> @@ -213,16 +214,27 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)<br>
> // Keep a reference on the Java VM.<br>
> myVm = vm;<br>
><br>
> - pthread_mutex_init(&vout_android_lock, NULL);<br>
> - pthread_cond_init(&vout_android_surf_attached, NULL);<br>
> + JNIEnv* env;<br>
> + if (jni_get_env(&env) < 0) {<br>
> + return -1;<br>
> + }<br>
> +<br>
> + jclass eventHandlerCls = (*env)->FindClass(env,<br>
> "org/videolan/libvlc/EventHandler");<br>
> + jmethodID methodId = (*env)->GetStaticMethodID(env, eventHandlerCls,<br>
> "getInstance", "()Lorg/videolan/libvlc/EventHandler;");<br>
> + jobject eventHandler = (*env)->CallStaticObjectMethod(env,<br>
> eventHandlerCls, methodId);<br>
> +<br>
> + eventHandlerInstance = (*env)->NewGlobalRef(env, eventHandler);<br>
><br>
> LOGD("JNI interface loaded.");<br>
> return VLC_JNI_VERSION;<br>
> }<br>
><br>
> void JNI_OnUnload(JavaVM* vm, void* reserved) {<br>
> - pthread_mutex_destroy(&vout_android_lock);<br>
> - pthread_cond_destroy(&vout_android_surf_attached);<br>
> + JNIEnv* env;<br>
> + if (jni_get_env(&env) == 0 && eventHandlerInstance != NULL) {<br>
> + (*env)->DeleteGlobalRef(env, eventHandlerInstance);<br>
> + }<br>
> + LOGD("JNI interface un-loaded.");<br>
> }<br>
><br>
> int jni_attach_thread(JNIEnv **env, const char *thread_name)<br>
> @@ -251,8 +263,22 @@ int jni_get_env(JNIEnv **env)<br>
> // FIXME: use atomics<br>
> static bool verbosity;<br>
><br>
> +<br>
> void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject<br>
> thiz)<br>
> {<br>
> + // initialize android_surface_value_t structure<br>
> + android_surf_value_t *android_surface = (android_surf_value_t *)<br>
> malloc(sizeof(android_surf_value_t));<br>
> +<br>
> + android_surface->vout_android_surf = NULL;<br>
> + android_surface->vout_android_gui = NULL;<br>
> + android_surface->vout_android_java_surf = NULL;<br>
> + android_surface->vout_android_subtitles_surf = NULL;<br>
<br>
</div></div>You can use calloc, instead of setting everything to NULL<br>
<div><div class="h5"><br>
> +<br>
> + pthread_mutex_init(&android_surface->vout_android_lock, NULL);<br>
> + pthread_cond_init(&android_surface->vout_android_surf_attached,<br>
> NULL);<br>
> +<br>
> + setLong(env, thiz, "mAndroidSurfaceValue",<br>
> (jlong)(intptr_t)android_surface);<br>
> +<br>
> //only use OpenSLES if java side says we can<br>
> jclass cls = (*env)->GetObjectClass(env, thiz);<br>
> jmethodID methodId = (*env)->GetMethodID(env, cls, "getAout",<br>
> "()I");<br>
> @@ -373,9 +399,13 @@ void<br>
> Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)<br>
><br>
> void Java_org_videolan_libvlc_LibVLC_nativeDestroy(JNIEnv *env, jobject<br>
> thiz)<br>
> {<br>
> - destroy_native_crash_handler(env);<br>
> + destroy_native_crash_handler(env, thiz);<br>
><br>
> releaseMediaPlayer(env, thiz);<br>
> +<br>
> + // set the Android surface value structure before playing<br>
> + android_surf_value_t *android_surface = (android_surf_value_t<br>
> *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
> +<br>
> jlong libVlcInstance = getLong(env, thiz, "mLibVlcInstance");<br>
> if (!libVlcInstance)<br>
> return; // Already destroyed<br>
> @@ -385,6 +415,13 @@ void<br>
> Java_org_videolan_libvlc_LibVLC_nativeDestroy(JNIEnv *env, jobject thiz)<br>
> libvlc_release(instance);<br>
><br>
> setLong(env, thiz, "mLibVlcInstance", 0);<br>
> +<br>
> + pthread_mutex_destroy(&android_surface->vout_android_lock);<br>
> + pthread_cond_destroy(&android_surface->vout_android_surf_attached);<br>
> +<br>
> + free(android_surface);<br>
> +<br>
> + setLong(env, thiz, "mAndroidSurfaceValue", 0);<br>
> }<br>
><br>
> void Java_org_videolan_libvlc_LibVLC_detachEventHandler(JNIEnv *env,<br>
> jobject thiz)<br>
> @@ -439,7 +476,7 @@ void Java_org_videolan_libvlc_LibVLC_playMRL(JNIEnv<br>
> *env, jobject thiz, jlong in<br>
> libvlc_MediaPlayerEncounteredError<br>
> };<br>
> for(int i = 0; i < (sizeof(mp_events) / sizeof(*mp_events)); i++)<br>
> - libvlc_event_attach(ev, mp_events[i], vlc_event_callback, myVm);<br>
> + libvlc_event_attach(ev, mp_events[i], vlc_event_callback,<br>
> (void*) myJavaLibVLC);<br>
<br>
</div></div>Where does myJavaLibVLC come from ?<br>
<div><div class="h5"><br>
><br>
> /* Keep a pointer to this media player */<br>
> setLong(env, thiz, "mInternalMediaPlayerInstance",<br>
> (jlong)(intptr_t)mp);<br>
> @@ -457,13 +494,17 @@ void Java_org_videolan_libvlc_LibVLC_playMRL(JNIEnv<br>
> *env, jobject thiz, jlong in<br>
><br>
> (*env)->ReleaseStringUTFChars(env, mrl, p_mrl);<br>
><br>
> + // set the Android surface value structure before playing<br>
> + android_surf_value_t *object = (android_surf_value_t<br>
> *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
> + libvlc_media_player_set_surfacevalue(mp, object);<br>
> +<br>
> /* Connect the media event manager. */<br>
> libvlc_event_manager_t *ev_media = libvlc_media_event_manager(p_md);<br>
> static const libvlc_event_type_t mp_media_events[] = {<br>
> libvlc_MediaParsedChanged<br>
> };<br>
> for(int i = 0; i < (sizeof(mp_media_events) /<br>
> sizeof(*mp_media_events)); i++)<br>
> - libvlc_event_attach(ev_media, mp_media_events[i],<br>
> vlc_event_callback, myVm);<br>
> + libvlc_event_attach(ev_media, mp_media_events[i],<br>
> vlc_event_callback, (void*) myJavaLibVLC);<br>
><br>
> libvlc_media_player_set_media(mp, p_md);<br>
> libvlc_media_player_play(mp);<br>
> diff --git a/libvlc/jni/native_crash_handler.c<br>
> b/libvlc/jni/native_crash_handler.c<br>
> index 2cb1590..f4a97be 100644<br>
> --- a/libvlc/jni/native_crash_handler.c<br>
> +++ b/libvlc/jni/native_crash_handler.c<br>
> @@ -19,11 +19,19 @@<br>
> *****************************************************************************/<br>
><br>
> #include <signal.h><br>
> +#include <pthread.h><br>
><br>
> #include "native_crash_handler.h"<br>
><br>
> +struct libvlc_crash_handler_t {<br>
> + jobject j_libVLC;<br>
> + libvlc_crash_handler_t *next;<br>
> + libvlc_crash_handler_t *prev;<br>
> +};<br>
> +<br>
> static struct sigaction old_actions[NSIG];<br>
> -static jobject j_libVLC;<br>
> +static libvlc_crash_handler_t *first = NULL;<br>
> +static libvlc_crash_handler_t *last = NULL;<br>
><br>
> #define THREAD_NAME "native_crash_handler"<br>
> extern int jni_attach_thread(JNIEnv **env, const char *thread_name);<br>
> @@ -45,6 +53,8 @@ static const int monitored_signals[] = {<br>
> };<br>
><br>
><br>
> +pthread_mutex_t native_handler_lock = PTHREAD_MUTEX_INITIALIZER;<br>
> +<br>
> /**<br>
> * Callback called when a monitored signal is triggered.<br>
> */<br>
> @@ -54,11 +64,24 @@ void sigaction_callback(int signal, siginfo_t *info,<br>
> void *reserved)<br>
> JNIEnv *env;<br>
> jni_attach_thread(&env, THREAD_NAME);<br>
><br>
> - jclass cls = (*env)->GetObjectClass(env, j_libVLC);<br>
> - jmethodID methodId = (*env)->GetMethodID(env, cls, "onNativeCrash",<br>
> "()V");<br>
> - (*env)->CallVoidMethod(env, j_libVLC, methodId);<br>
> + pthread_mutex_lock(&native_handler_lock);<br>
> +<br>
> + libvlc_crash_handler_t *lp = first;<br>
> + while (lp != NULL)<br>
> + {<br>
> + jclass cls = (*env)->GetObjectClass(env, lp->j_libVLC);<br>
> + jmethodID methodId = (*env)->GetMethodID(env, cls,<br>
> "onNativeCrash", "()V");<br>
> + (*env)->CallVoidMethod(env, lp->j_libVLC, methodId);<br>
> +<br>
> + (*env)->DeleteLocalRef(env, cls);<br>
> +<br>
> + libvlc_crash_handler_t *todelete = lp;<br>
> + lp = lp->next;<br>
> +<br>
> + free(todelete);<br>
> + }<br>
> + pthread_mutex_unlock(&native_handler_lock);<br>
><br>
> - (*env)->DeleteLocalRef(env, cls);<br>
> jni_detach_thread();<br>
><br>
> // Call the old signal handler.<br>
> @@ -68,7 +91,19 @@ void sigaction_callback(int signal, siginfo_t *info,<br>
> void *reserved)<br>
><br>
> void init_native_crash_handler(JNIEnv *env, jobject j_libVLC_local)<br>
> {<br>
> - j_libVLC = (*env)->NewGlobalRef(env, j_libVLC_local);<br>
> + pthread_mutex_lock(&native_handler_lock);<br>
> +<br>
> + libvlc_crash_handler_t *current = (libvlc_crash_handler_t *)<br>
> malloc(sizeof(libvlc_crash_handler_t));<br>
> + current->j_libVLC = (*env)->NewGlobalRef(env, j_libVLC_local);<br>
> + current->prev = last;<br>
> +<br>
> + // update values<br>
> + if (first == NULL)<br>
> + first = current;<br>
> + if (last != NULL)<br>
> + last->next = current;<br>
> + last = current;<br>
> +<br>
> struct sigaction handler;<br>
> memset(&handler, 0, sizeof(struct sigaction));<br>
><br>
> @@ -81,11 +116,15 @@ void init_native_crash_handler(JNIEnv *env, jobject<br>
> j_libVLC_local)<br>
> const int s = monitored_signals[i];<br>
> sigaction(s, &handler, &old_actions[s]);<br>
> }<br>
> +<br>
> + pthread_mutex_unlock(&native_handler_lock);<br>
> }<br>
><br>
><br>
> -void destroy_native_crash_handler(JNIEnv *env)<br>
> +void destroy_native_crash_handler(JNIEnv *env, jobject j_libVLC_local)<br>
> {<br>
> + pthread_mutex_lock(&native_handler_lock);<br>
> +<br>
> // Uninstall the signal handlers and restore their old actions.<br>
> for (unsigned i = 0; i < sizeof(monitored_signals) / sizeof(int);<br>
> ++i)<br>
> {<br>
> @@ -93,5 +132,31 @@ void destroy_native_crash_handler(JNIEnv *env)<br>
> sigaction(s, &old_actions[s], NULL);<br>
> }<br>
><br>
> - (*env)->DeleteGlobalRef(env, j_libVLC);<br>
> + libvlc_crash_handler_t *lp = first;<br>
> + while (lp != NULL)<br>
> + {<br>
> + if (j_libVLC_local == lp->j_libVLC) {<br>
> + (*env)->DeleteGlobalRef(env, lp->j_libVLC);<br>
> +<br>
> + libvlc_crash_handler_t *todelete = lp;<br>
> + libvlc_crash_handler_t *prev = lp->prev;<br>
> + libvlc_crash_handler_t *next = lp->next;<br>
> + if (lp == first) {<br>
> + first = next;<br>
> + if (first != NULL)<br>
> + first->prev = NULL;<br>
> + } else if (lp == last) {<br>
> + last = prev;<br>
> + last->next = NULL;<br>
> + } else {<br>
> + prev->next = next;<br>
> + next->prev = prev;<br>
> + }<br>
> +<br>
> + free(todelete);<br>
> + break;<br>
> + }<br>
> + }<br>
> +<br>
> + pthread_mutex_unlock(&native_handler_lock);<br>
> }<br>
> diff --git a/libvlc/jni/native_crash_handler.h<br>
> b/libvlc/jni/native_crash_handler.h<br>
> index a57e61e..4c5530b 100644<br>
> --- a/libvlc/jni/native_crash_handler.h<br>
> +++ b/libvlc/jni/native_crash_handler.h<br>
> @@ -23,7 +23,9 @@<br>
><br>
> #include <jni.h><br>
><br>
> +typedef struct libvlc_crash_handler_t libvlc_crash_handler_t;<br>
> +<br>
> void init_native_crash_handler(JNIEnv *env, jobject j_libVLC_local);<br>
> -void destroy_native_crash_handler(JNIEnv *env);<br>
> +void destroy_native_crash_handler(JNIEnv *env, jobject j_libVLC_local);<br>
><br>
> #endif // LIBVLCJNI_NATIVE_CRASH_HANDLER_H<br>
> diff --git a/libvlc/jni/vout.c b/libvlc/jni/vout.c<br>
> index 06dc605..107417b 100644<br>
> --- a/libvlc/jni/vout.c<br>
> +++ b/libvlc/jni/vout.c<br>
> @@ -22,43 +22,53 @@<br>
> #include <vlc_common.h><br>
><br>
> #include <jni.h><br>
> +#include "vout.h"<br>
><br>
> #define THREAD_NAME "jni_vout"<br>
> extern int jni_attach_thread(JNIEnv **env, const char *thread_name);<br>
> extern void jni_detach_thread();<br>
> extern int jni_get_env(JNIEnv **env);<br>
><br>
> -pthread_mutex_t vout_android_lock;<br>
> -pthread_cond_t vout_android_surf_attached;<br>
> -static void *vout_android_gui = NULL;<br>
> -static jobject vout_android_java_surf = NULL;<br>
> -static jobject vout_android_subtitles_surf = NULL;<br>
> -static bool vout_video_player_activity_created = false;<br>
> +void *jni_LockAndGetSubtitlesSurface(android_surf_value_t<br>
> *android_surface) {<br>
> + if (android_surface->vout_android_subtitles_surf == NULL)<br>
> + return;<br>
><br>
> -void *jni_LockAndGetSubtitlesSurface() {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> - while (vout_android_subtitles_surf == NULL)<br>
> - pthread_cond_wait(&vout_android_surf_attached,<br>
> &vout_android_lock);<br>
> - return vout_android_subtitles_surf;<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + while (android_surface->vout_android_subtitles_surf == NULL)<br>
> + pthread_cond_wait(&android_surface->vout_android_surf_attached,<br>
> &android_surface->vout_android_lock);<br>
> + return android_surface->vout_android_subtitles_surf;<br>
> }<br>
><br>
> -jobject jni_LockAndGetAndroidJavaSurface() {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> - while (vout_android_java_surf == NULL)<br>
> - pthread_cond_wait(&vout_android_surf_attached,<br>
> &vout_android_lock);<br>
> - return vout_android_java_surf;<br>
> +void *jni_LockAndGetAndroidSurface(android_surf_value_t<br>
> *android_surface) {<br>
> + if (android_surface->vout_android_surf == NULL)<br>
> + return;<br>
> +<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + while (android_surface->vout_android_surf == NULL)<br>
> + pthread_cond_wait(&android_surface->vout_android_surf_attached,<br>
> &android_surface->vout_android_lock);<br>
> + return android_surface->vout_android_surf;<br>
> }<br>
<br>
</div></div>I won't apply on master.<br>
I just removed jni_LockAndGetAndroidSurface and vout_android_surf in a<br>
recent commit.<br>
And I added this new function: jni_AndroidJavaSurfaceToNativeSurface.<br>
But It should be easy to merge since it'll work with your new<br>
android_surface struct.<br>
<div><div class="h5"><br>
><br>
> -void jni_UnlockAndroidSurface() {<br>
> - pthread_mutex_unlock(&vout_android_lock);<br>
> +jobject jni_LockAndGetAndroidJavaSurface(android_surf_value_t<br>
> *android_surface) {<br>
> + if (android_surface->vout_android_java_surf == NULL)<br>
> + return;<br>
> +<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + while (android_surface->vout_android_java_surf == NULL)<br>
> + pthread_cond_wait(&android_surface->vout_android_surf_attached,<br>
> &android_surface->vout_android_lock);<br>
> + return android_surface->vout_android_java_surf;<br>
> }<br>
><br>
> -void jni_EventHardwareAccelerationError()<br>
> +void jni_UnlockAndroidSurface(android_surf_value_t *android_surface) {<br>
> + pthread_mutex_unlock(&android_surface->vout_android_lock);<br>
> +}<br>
> +<br>
> +void jni_EventHardwareAccelerationError(android_surf_value_t<br>
> *android_surface)<br>
> {<br>
> JNIEnv *env;<br>
> bool isAttached = false;<br>
><br>
> - if (vout_android_gui == NULL)<br>
> + if (android_surface->vout_android_gui == NULL)<br>
> return;<br>
><br>
> if (jni_get_env(&env) < 0) {<br>
> @@ -67,39 +77,42 @@ void jni_EventHardwareAccelerationError()<br>
> isAttached = true;<br>
> }<br>
><br>
> - jclass cls = (*env)->GetObjectClass(env, vout_android_gui);<br>
> + jclass cls = (*env)->GetObjectClass(env,<br>
> android_surface->vout_android_gui);<br>
> jmethodID methodId = (*env)->GetMethodID(env, cls,<br>
> "eventHardwareAccelerationError", "()V");<br>
> - (*env)->CallVoidMethod(env, vout_android_gui, methodId);<br>
> + (*env)->CallVoidMethod(env, android_surface->vout_android_gui,<br>
> methodId);<br>
><br>
> (*env)->DeleteLocalRef(env, cls);<br>
> if (isAttached)<br>
> jni_detach_thread();<br>
> }<br>
><br>
> -static void jni_SetSurfaceLayoutEnv(JNIEnv *p_env, int width, int<br>
> height, int visible_width, int visible_height, int sar_num, int sar_den)<br>
> +void jni_SetSurfaceLayoutEnv(JNIEnv *p_env, android_surf_value_t<br>
> *android_surface, int width, int height, int visible_width, int<br>
> visible_height, int sar_num, int sar_den)<br>
> {<br>
> - if (vout_android_gui == NULL)<br>
> + if (android_surface->vout_android_gui == NULL)<br>
> return;<br>
><br>
> - jclass cls = (*p_env)->GetObjectClass (p_env, vout_android_gui);<br>
> + jclass cls = (*p_env)->GetObjectClass (p_env,<br>
> android_surface->vout_android_gui);<br>
> jmethodID methodId = (*p_env)->GetMethodID (p_env, cls,<br>
> "setSurfaceLayout", "(IIIIII)V");<br>
><br>
> - (*p_env)->CallVoidMethod (p_env, vout_android_gui, methodId, width,<br>
> height, visible_width, visible_height, sar_num, sar_den);<br>
> + (*p_env)->CallVoidMethod (p_env, android_surface->vout_android_gui,<br>
> methodId, width, height, visible_width, visible_height, sar_num,<br>
> sar_den);<br>
><br>
> (*p_env)->DeleteLocalRef(p_env, cls);<br>
> }<br>
><br>
> -void jni_SetSurfaceLayout(int width, int height, int visible_width, int<br>
> visible_height, int sar_num, int sar_den)<br>
> +void jni_SetSurfaceLayout(android_surf_value_t *android_surface, int<br>
> width, int height, int visible_width, int visible_height, int sar_num,<br>
> int sar_den)<br>
> {<br>
> JNIEnv *p_env;<br>
> bool isAttached = false;<br>
><br>
> + if (android_surface == NULL)<br>
> + return;<br>
> +<br>
> if (jni_get_env(&p_env) < 0) {<br>
> if (jni_attach_thread(&p_env, THREAD_NAME) < 0)<br>
> return;<br>
> isAttached = true;<br>
> }<br>
> - jni_SetSurfaceLayoutEnv(p_env, width, height, visible_width,<br>
> visible_height, sar_num, sar_den);<br>
> + jni_SetSurfaceLayoutEnv(p_env, android_surface, width, height,<br>
> visible_width, visible_height, sar_num, sar_den);<br>
><br>
> if (isAttached)<br>
> jni_detach_thread();<br>
> @@ -144,7 +157,7 @@ void *jni_AndroidJavaSurfaceToNativeSurface(jobject<br>
> *surf)<br>
> return native_surface;<br>
> }<br>
><br>
> -int jni_ConfigureSurface(jobject jsurf, int width, int height, int hal,<br>
> bool *configured)<br>
> +int jni_ConfigureSurface(jobject jsurf, android_surf_value_t<br>
> *android_surface, int width, int height, int hal, bool *configured)<br>
> {<br>
> JNIEnv *p_env;<br>
> bool isAttached = false;<br>
> @@ -155,9 +168,9 @@ int jni_ConfigureSurface(jobject jsurf, int width,<br>
> int height, int hal, bool *co<br>
> return -1;<br>
> isAttached = true;<br>
> }<br>
> - jclass clz = (*p_env)->GetObjectClass (p_env, vout_android_gui);<br>
> + jclass clz = (*p_env)->GetObjectClass (p_env,<br>
> android_surface->vout_android_gui);<br>
> jmethodID methodId = (*p_env)->GetMethodID (p_env, clz,<br>
> "configureSurface", "(Landroid/view/Surface;III)I");<br>
> - ret = (*p_env)->CallIntMethod (p_env, vout_android_gui, methodId,<br>
> jsurf, width, height, hal);<br>
> + ret = (*p_env)->CallIntMethod (p_env,<br>
> android_surface->vout_android_gui, methodId, jsurf, width, height, hal);<br>
> if (ret >= 0 && configured)<br>
> *configured = ret == 1;<br>
><br>
> @@ -166,58 +179,76 @@ int jni_ConfigureSurface(jobject jsurf, int width,<br>
> int height, int hal, bool *co<br>
> return ret == -1 ? -1 : 0;<br>
> }<br>
><br>
> -bool jni_IsVideoPlayerActivityCreated() {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> - bool result = vout_video_player_activity_created;<br>
> - pthread_mutex_unlock(&vout_android_lock);<br>
> +bool jni_IsVideoPlayerActivityCreated(android_surf_value_t<br>
> *android_surface) {<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + bool result = android_surface->vout_video_player_activity_created;<br>
> + pthread_mutex_unlock(&android_surface->vout_android_lock);<br>
> return result;<br>
> }<br>
><br>
> void<br>
> Java_org_videolan_libvlc_LibVLC_eventVideoPlayerActivityCreated(JNIEnv<br>
> *env, jobject thiz, jboolean created) {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> - vout_video_player_activity_created = created;<br>
> - pthread_mutex_unlock(&vout_android_lock);<br>
> + android_surf_value_t * android_surface = (android_surf_value_t<br>
> *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + android_surface->vout_video_player_activity_created = created;<br>
> + pthread_mutex_unlock(&android_surface->vout_android_lock);<br>
> }<br>
><br>
> void Java_org_videolan_libvlc_LibVLC_attachSurface(JNIEnv *env, jobject<br>
> thiz, jobject surf, jobject gui) {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> + android_surf_value_t * android_surface = (android_surf_value_t<br>
> *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
> + if (android_surface == NULL)<br>
> + return;<br>
> +<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
><br>
> - if (vout_android_gui != NULL)<br>
> - (*env)->DeleteGlobalRef(env, vout_android_gui);<br>
> - if (vout_android_java_surf != NULL)<br>
> - (*env)->DeleteGlobalRef(env, vout_android_java_surf);<br>
> - vout_android_gui = (*env)->NewGlobalRef(env, gui);<br>
> - vout_android_java_surf = (*env)->NewGlobalRef(env, surf);<br>
> - pthread_cond_signal(&vout_android_surf_attached);<br>
> - pthread_mutex_unlock(&vout_android_lock);<br>
> + if (android_surface->vout_android_gui != NULL)<br>
> + (*env)->DeleteGlobalRef(env, android_surface->vout_android_gui);<br>
> + if (android_surface->vout_android_java_surf != NULL)<br>
> + (*env)->DeleteGlobalRef(env,<br>
> android_surface->vout_android_java_surf);<br>
> + android_surface->vout_android_gui = (*env)->NewGlobalRef(env, gui);<br>
> + android_surface->vout_android_java_surf = (*env)->NewGlobalRef(env,<br>
> surf);<br>
> + pthread_cond_signal(&android_surface->vout_android_surf_attached);<br>
> + pthread_mutex_unlock(&android_surface->vout_android_lock);<br>
> }<br>
><br>
> void Java_org_videolan_libvlc_LibVLC_detachSurface(JNIEnv *env, jobject<br>
> thiz) {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> - if (vout_android_gui != NULL)<br>
> - (*env)->DeleteGlobalRef(env, vout_android_gui);<br>
> - if (vout_android_java_surf != NULL)<br>
> - (*env)->DeleteGlobalRef(env, vout_android_java_surf);<br>
> - vout_android_gui = NULL;<br>
> - vout_android_java_surf = NULL;<br>
> - pthread_mutex_unlock(&vout_android_lock);<br>
> + android_surf_value_t * android_surface = (android_surf_value_t<br>
> *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
> + if (android_surface == NULL)<br>
> + return;<br>
> +<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + android_surface->vout_android_surf = NULL;<br>
> + if (android_surface->vout_android_gui != NULL)<br>
> + (*env)->DeleteGlobalRef(env, android_surface->vout_android_gui);<br>
> + if (android_surface->vout_android_java_surf != NULL)<br>
> + (*env)->DeleteGlobalRef(env,<br>
> android_surface->vout_android_java_surf);<br>
> + android_surface->vout_android_gui = NULL;<br>
> + android_surface->vout_android_java_surf = NULL;<br>
> + pthread_mutex_unlock(&android_surface->vout_android_lock);<br>
> }<br>
><br>
> void Java_org_videolan_libvlc_LibVLC_attachSubtitlesSurface(JNIEnv *env,<br>
> jobject thiz, jobject surf) {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> - if (vout_android_subtitles_surf != NULL)<br>
> - (*env)->DeleteGlobalRef(env, vout_android_subtitles_surf);<br>
> - vout_android_subtitles_surf = (*env)->NewGlobalRef(env, surf);<br>
> - pthread_cond_signal(&vout_android_surf_attached);<br>
> - pthread_mutex_unlock(&vout_android_lock);<br>
> + android_surf_value_t * android_surface = (android_surf_value_t<br>
> *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
> + if (android_surface == NULL)<br>
> + return;<br>
> +<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + if (android_surface->vout_android_subtitles_surf != NULL)<br>
> + (*env)->DeleteGlobalRef(env,<br>
> android_surface->vout_android_subtitles_surf);<br>
> + android_surface->vout_android_subtitles_surf =<br>
> (*env)->NewGlobalRef(env, surf);<br>
> + pthread_cond_signal(&android_surface->vout_android_surf_attached);<br>
> + pthread_mutex_unlock(&android_surface->vout_android_lock);<br>
> }<br>
><br>
> void Java_org_videolan_libvlc_LibVLC_detachSubtitlesSurface(JNIEnv *env,<br>
> jobject thiz) {<br>
> - pthread_mutex_lock(&vout_android_lock);<br>
> - if (vout_android_subtitles_surf != NULL)<br>
> - (*env)->DeleteGlobalRef(env, vout_android_subtitles_surf);<br>
> - vout_android_subtitles_surf = NULL;<br>
> - pthread_mutex_unlock(&vout_android_lock);<br>
> + android_surf_value_t * android_surface = (android_surf_value_t<br>
> *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
> + if (android_surface == NULL)<br>
> + return;<br>
> +<br>
> + pthread_mutex_lock(&android_surface->vout_android_lock);<br>
> + if (android_surface->vout_android_subtitles_surf != NULL)<br>
> + (*env)->DeleteGlobalRef(env,<br>
> android_surface->vout_android_subtitles_surf);<br>
> + android_surface->vout_android_subtitles_surf = NULL;<br>
> + pthread_mutex_unlock(&android_surface->vout_android_lock);<br>
> }<br>
><br>
> static int mouse_x = -1;<br>
> diff --git a/libvlc/jni/vout.h b/libvlc/jni/vout.h<br>
> index c3d4fd7..c439c12 100644<br>
> --- a/libvlc/jni/vout.h<br>
> +++ b/libvlc/jni/vout.h<br>
> @@ -21,8 +21,16 @@<br>
> #ifndef LIBVLCJNI_VOUT_H<br>
> #define LIBVLCJNI_VOUT_H<br>
><br>
> -/* vout lock initialized in vout.c */<br>
> -pthread_mutex_t vout_android_lock;<br>
> -pthread_cond_t vout_android_surf_attached;<br>
> +#include <pthread.h><br>
> +<br>
> +typedef struct android_surf_value_t {<br>
> + pthread_mutex_t vout_android_lock;<br>
> + pthread_cond_t vout_android_surf_attached;<br>
> + void *vout_android_surf;<br>
> + void *vout_android_gui;<br>
> + jobject vout_android_java_surf;<br>
> + jobject vout_android_subtitles_surf;<br>
> + bool vout_video_player_activity_created;<br>
> +} android_surf_value_t;<br>
><br>
> #endif // LIBVLCJNI_VOUT_H<br>
> diff --git a/libvlc/src/org/videolan/libvlc/EventHandler.java<br>
> b/libvlc/src/org/videolan/libvlc/EventHandler.java<br>
> index 16a0791..03b8821 100644<br>
> --- a/libvlc/src/org/videolan/libvlc/EventHandler.java<br>
> +++ b/libvlc/src/org/videolan/libvlc/EventHandler.java<br>
> @@ -21,6 +21,9 @@<br>
> package org.videolan.libvlc;<br>
><br>
> import java.util.ArrayList;<br>
> +import java.util.HashMap;<br>
> +import java.util.List;<br>
> +import java.util.Map;<br>
><br>
> import android.os.Bundle;<br>
> import android.os.Handler;<br>
> @@ -96,36 +99,44 @@ public class EventHandler {<br>
><br>
> public static final int HardwareAccelerationError = 0x3000;<br>
><br>
> - private ArrayList<Handler> mEventHandler;<br>
> + private Map<LibVLC, ArrayList<Handler>> mMapHandler;<br>
> private static EventHandler mInstance;<br>
><br>
> EventHandler() {<br>
> - mEventHandler = new ArrayList<Handler>();<br>
> + mMapHandler = new HashMap<LibVLC, ArrayList<Handler>>();<br>
> }<br>
><br>
> - public static EventHandler getInstance() {<br>
> + public synchronized static EventHandler getInstance() {<br>
> if (mInstance == null) {<br>
> mInstance = new EventHandler();<br>
> }<br>
> return mInstance;<br>
> }<br>
><br>
> - public void addHandler(Handler handler) {<br>
> - if (!mEventHandler.contains(handler))<br>
> - mEventHandler.add(handler);<br>
> + public synchronized void addHandler(LibVLC vlcObject, Handler<br>
> handler) {<br>
> + if (!mMapHandler.containsKey(vlcObject)) {<br>
> + mMapHandler.put(vlcObject, new ArrayList<Handler>());<br>
> + }<br>
> + mMapHandler.get(vlcObject).add(handler);<br>
> }<br>
><br>
> - public void removeHandler(Handler handler) {<br>
> - mEventHandler.remove(handler);<br>
> + public synchronized void removeHandler(LibVLC vlcObject, Handler<br>
> handler) {<br>
> + mMapHandler.get(vlcObject).remove(handler);<br>
> }<br>
><br>
> /** This method is called by a native thread **/<br>
> - public void callback(int event, Bundle b) {<br>
> + public synchronized void callback(int event, Bundle b, LibVLC<br>
> vlcObject) {<br>
> + List<Handler> eventHandlers = mMapHandler.get(vlcObject);<br>
> + if (eventHandlers == null) {<br>
> + return;<br>
> + }<br>
> +<br>
> b.putInt("event", event);<br>
> - for (int i = 0; i < mEventHandler.size(); i++) {<br>
> + for (int i = 0; i < eventHandlers.size(); i++) {<br>
> Message msg = Message.obtain();<br>
> msg.setData(b);<br>
> - mEventHandler.get(i).sendMessage(msg);<br>
> + msg.obj = vlcObject;<br>
> + eventHandlers.get(i).sendMessage(msg);<br>
> }<br>
> }<br>
> }<br>
<br>
</div></div>Why not having EventHandler an object inside LibVLC ?<br>
So, To get the EventHandler: mLibVlc.getEventHandler() (from java and<br>
native).<br>
That way, you can get ride of all hashmap and you don't have to call<br>
EventHandler methods with an instance of LibVlc.<br>
<div><div class="h5"><br>
<br>
> diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java<br>
> b/libvlc/src/org/videolan/libvlc/LibVLC.java<br>
> index 8eb25ad..4a2aa2f 100644<br>
> --- a/libvlc/src/org/videolan/libvlc/LibVLC.java<br>
> +++ b/libvlc/src/org/videolan/libvlc/LibVLC.java<br>
> @@ -67,6 +67,9 @@ public class LibVLC {<br>
> private int mInternalMediaPlayerIndex = 0; // Read-only, reserved<br>
> for JNI<br>
> private long mInternalMediaPlayerInstance = 0; // Read-only,<br>
> reserved for JNI<br>
><br>
> + // Android surface structure<br>
> + protected long mAndroidSurfaceValue = 0; // Read-only, reserved for<br>
> JNI<br>
> +<br>
> private MediaList mMediaList; // Pointer to media list being<br>
> followed<br>
> private MediaList mPrimaryList; // Primary/default media list; see<br>
> getPrimaryMediaList()<br>
><br>
> @@ -192,10 +195,9 @@ public class LibVLC {<br>
> }<br>
><br>
> /**<br>
> - * Constructor<br>
> - * It is private because this class is a singleton.<br>
> + * Constructor.<br>
> */<br>
> - private LibVLC() {<br>
> + public LibVLC() {<br>
> mAout = new AudioOutput();<br>
> }<br>
><br>
> @@ -261,7 +263,7 @@ public class LibVLC {<br>
> */<br>
> public native void setSurface(Surface f);<br>
><br>
> - public static synchronized void restart(Context context) {<br>
> + public static synchronized void restartInstance(Context context) {<br>
> if (sInstance != null) {<br>
> try {<br>
> sInstance.destroy();<br>
> @@ -272,6 +274,15 @@ public class LibVLC {<br>
> }<br>
> }<br>
><br>
> + public void restart(Context context) {<br>
> + try {<br>
> + this.destroy();<br>
> + this.init(context);<br>
> + } catch (LibVlcException lve) {<br>
> + Log.e(TAG, "Unable to reinit libvlc: " + lve);<br>
> + }<br>
> + }<br>
> +<br>
> /**<br>
> * those get/is* are called from native code to get settings values.<br>
> */<br>
> @@ -490,7 +501,7 @@ public class LibVLC {<br>
> applyEqualizer();<br>
> }<br>
><br>
> - private void applyEqualizer()<br>
> + protected void applyEqualizer()<br>
> {<br>
> setNativeEqualizer(mInternalMediaPlayerInstance,<br>
> this.equalizer);<br>
> }<br>
> diff --git a/libvlc/src/org/videolan/libvlc/MediaList.java<br>
> b/libvlc/src/org/videolan/libvlc/MediaList.java<br>
> index 666568e..5c60236 100644<br>
> --- a/libvlc/src/org/videolan/libvlc/MediaList.java<br>
> +++ b/libvlc/src/org/videolan/libvlc/MediaList.java<br>
> @@ -105,12 +105,12 @@ public class MediaList {<br>
> ArrayList<String> children = new ArrayList<String>();<br>
> int ret = expandMedia(mLibVLC, position, children);<br>
> if(ret == 0) {<br>
> -<br>
> mEventHandler.callback(EventHandler.CustomMediaListExpanding, new<br>
> Bundle());<br>
> +<br>
> mEventHandler.callback(EventHandler.CustomMediaListExpanding, new<br>
> Bundle(), mLibVLC);<br>
> this.remove(position);<br>
> for(String mrl : children) {<br>
> this.insert(position, mrl);<br>
> }<br>
> -<br>
> mEventHandler.callback(EventHandler.CustomMediaListExpandingEnd, new<br>
> Bundle());<br>
> +<br>
> mEventHandler.callback(EventHandler.CustomMediaListExpandingEnd, new<br>
> Bundle(), mLibVLC);<br>
> }<br>
> return ret;<br>
> }<br>
> @@ -155,7 +155,7 @@ public class MediaList {<br>
> Bundle b = new Bundle();<br>
> b.putInt("index_before", startPosition);<br>
> b.putInt("index_after", endPosition);<br>
> - mEventHandler.callback(EventHandler.CustomMediaListItemMoved,<br>
> b);<br>
> + mEventHandler.callback(EventHandler.CustomMediaListItemMoved, b,<br>
> mLibVLC);<br>
> }<br>
><br>
> public void remove(int position) {<br>
> @@ -231,6 +231,6 @@ public class MediaList {<br>
> Bundle b = new Bundle();<br>
> b.putString("item_uri", uri);<br>
> b.putInt("item_index", position);<br>
> - mEventHandler.callback(event, b);<br>
> + mEventHandler.callback(event, b, mLibVLC);<br>
> }<br>
> }<br>
> diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java<br>
> b/vlc-android/src/org/videolan/vlc/audio/AudioService.java<br>
> index bf4e85f..6420d72 100644<br>
> --- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java<br>
> +++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java<br>
> @@ -618,7 +618,7 @@ public class AudioService extends Service {<br>
> String MRL = mLibVLC.getMediaList().getMRL(mCurrentIndex);<br>
> int index = mCurrentIndex;<br>
> mCurrentIndex = -1;<br>
> - mEventHandler.removeHandler(mVlcEventHandler);<br>
> + mEventHandler.removeHandler(mLibVLC, mVlcEventHandler);<br>
> // Preserve playback when switching to video<br>
> hideNotification(false);<br>
><br>
> @@ -821,8 +821,8 @@ public class AudioService extends Service {<br>
><br>
> private void stop() {<br>
> mLibVLC.stop();<br>
> - mEventHandler.removeHandler(mVlcEventHandler);<br>
> -<br>
> mLibVLC.getMediaList().getEventHandler().removeHandler(mListEventHandler);<br>
> + mEventHandler.removeHandler(mLibVLC, mVlcEventHandler);<br>
> + mLibVLC.getMediaList().getEventHandler().removeHandler(mLibVLC,<br>
> mListEventHandler);<br>
> setRemoteControlClientPlaybackState(EventHandler.MediaPlayerStopped);<br>
> mCurrentIndex = -1;<br>
> mPrevious.clear();<br>
> @@ -1138,9 +1138,9 @@ public class AudioService extends Service {<br>
> throws RemoteException {<br>
><br>
> Log.v(TAG, "Loading position " +<br>
> ((Integer)position).toString() + " in " +<br>
> mediaPathList.toString());<br>
> - mEventHandler.addHandler(mVlcEventHandler);<br>
> + mEventHandler.addHandler(mLibVLC, mVlcEventHandler);<br>
><br>
> -<br>
> mLibVLC.getMediaList().getEventHandler().removeHandler(mListEventHandler);<br>
> +<br>
> mLibVLC.getMediaList().getEventHandler().removeHandler(mLibVLC,<br>
> mListEventHandler);<br>
> mLibVLC.setMediaList();<br>
> mLibVLC.getPrimaryMediaList().clear();<br>
> MediaList mediaList = mLibVLC.getMediaList();<br>
> @@ -1175,7 +1175,7 @@ public class AudioService extends Service {<br>
> }<br>
><br>
> // Add handler after loading the list<br>
> -<br>
> mLibVLC.getMediaList().getEventHandler().addHandler(mListEventHandler);<br>
> + mLibVLC.getMediaList().getEventHandler().addHandler(mLibVLC,<br>
> mListEventHandler);<br>
><br>
> mLibVLC.playIndex(mCurrentIndex);<br>
> mHandler.sendEmptyMessage(SHOW_PROGRESS);<br>
> @@ -1206,7 +1206,7 @@ public class AudioService extends Service {<br>
> mCurrentIndex = 0;<br>
> }<br>
><br>
> - mEventHandler.addHandler(mVlcEventHandler);<br>
> + mEventHandler.addHandler(mLibVLC, mVlcEventHandler);<br>
> mLibVLC.playIndex(mCurrentIndex);<br>
> mHandler.sendEmptyMessage(SHOW_PROGRESS);<br>
> setUpRemoteControlClient();<br>
> @@ -1230,7 +1230,7 @@ public class AudioService extends Service {<br>
><br>
> if(URI == null || !mLibVLC.isPlaying())<br>
> return;<br>
> - mEventHandler.addHandler(mVlcEventHandler);<br>
> + mEventHandler.addHandler(mLibVLC, mVlcEventHandler);<br>
> mCurrentIndex = index;<br>
><br>
> // Notify everyone<br>
> diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java<br>
> b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java<br>
> index f24577c..b80438b 100644<br>
> --- a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java<br>
> +++ b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java<br>
> @@ -56,7 +56,7 @@ public class HistoryAdapter extends BaseAdapter {<br>
> }<br>
><br>
> EventHandler em =<br>
> mLibVLC.getPrimaryMediaList().getEventHandler();<br>
> - em.addHandler(new HistoryEventHandler(this));<br>
> + em.addHandler(mLibVLC, new HistoryEventHandler(this));<br>
> }<br>
><br>
> @Override<br>
> diff --git<br>
> a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java<br>
> b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java<br>
> index 9f0109c..b069452 100644<br>
> --- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java<br>
> +++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java<br>
> @@ -292,7 +292,7 @@ public class PreferencesActivity extends<br>
> PreferenceActivity implements OnSharedP<br>
> || key.equalsIgnoreCase("network_caching")<br>
> || key.equalsIgnoreCase("dev_hardware_decoder")) {<br>
> VLCInstance.updateLibVlcSettings(sharedPreferences);<br>
> - LibVLC.restart(this);<br>
> + LibVLC.restartInstance(this);<br>
> }<br>
> }<br>
><br>
> diff --git<br>
> a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
> b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
> index faf4d10..2fa6236 100644<br>
> --- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
> +++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
> @@ -438,7 +438,7 @@ public class VideoPlayerActivity extends<br>
> ActionBarActivity implements IVideoPlay<br>
> mLibVLC.eventVideoPlayerActivityCreated(true);<br>
><br>
> EventHandler em = EventHandler.getInstance();<br>
> - em.addHandler(eventHandler);<br>
> + em.addHandler(mLibVLC, eventHandler);<br>
><br>
> this.setVolumeControlStream(AudioManager.STREAM_MUSIC);<br>
><br>
> @@ -561,7 +561,7 @@ public class VideoPlayerActivity extends<br>
> ActionBarActivity implements IVideoPlay<br>
> unregisterReceiver(mReceiver);<br>
><br>
> EventHandler em = EventHandler.getInstance();<br>
> - em.removeHandler(eventHandler);<br>
> + em.removeHandler(mLibVLC, eventHandler);<br>
><br>
> // MediaCodec opaque direct rendering should not be used anymore<br>
> since there is no surface to attach.<br>
> mLibVLC.eventVideoPlayerActivityCreated(false);<br>
> @@ -1205,7 +1205,7 @@ public class VideoPlayerActivity extends<br>
> ActionBarActivity implements IVideoPlay<br>
><br>
> public void eventHardwareAccelerationError() {<br>
> EventHandler em = EventHandler.getInstance();<br>
> - em.callback(EventHandler.HardwareAccelerationError, new<br>
> Bundle());<br>
> + em.callback(EventHandler.HardwareAccelerationError, new<br>
> Bundle(), mLibVLC);<br>
> }<br>
><br>
> private void handleHardwareAccelerationError() {<br>
> --<br>
> 1.9.3 (Apple Git-50)<br>
><br>
</div></div>> _______________________________________________<br>
> Android mailing list<br>
> <a href="mailto:Android@videolan.org">Android@videolan.org</a><br>
> <a href="https://mailman.videolan.org/listinfo/android" target="_blank">https://mailman.videolan.org/listinfo/android</a><br>
><br>
<br>
_______________________________________________<br>
Android mailing list<br>
<a href="mailto:Android@videolan.org">Android@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/android" target="_blank">https://mailman.videolan.org/listinfo/android</a><br>
<br>
</blockquote></div><br></div></div></div>