<div dir="ltr"><div><div><div><div>Hi,<br></div><br>Thanks for the input.<br></div><div>A few answers.<br><br></div><div>1- Each instance of the java LibVLC class holds a pointer to the libvlc instance. So there is no issue here. The main issue was the Surface object. A static global variable was being used initially. This was solved by creating android_surf_value_t structure that is attached to each LibVLC class. This works rather well.<br>
</div><div>2- Event handling: I see your point. Just need to make it non-static and add it as instance variable inside the LibVLC class. And pass to vlc_event_callback data the EventHandler instance pointer.<br></div><div>
3- The restartInstance was added to avoid breaking the VLC android application which still uses a singleton. In the future the VLC android application will need to refactored.<br>4- "protected void applyEqualizer()" - This is to allow LibVLC subclassing.<br>
</div><div>5- synchronized was used around nativeInit and nativeDestroy, but I am not really sure if it's actually needed. Have to test further as well.<br></div><br></div>Will continue developing and should post a few more updates on this one.<br>
<br></div><div>Thanks<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-25 2:17 GMT-03:00 Edward Wang <span dir="ltr"><<a href="mailto:edward.c.wang@compdigitec.com" target="_blank">edward.c.wang@compdigitec.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 2014-07-24 22:14, Paulo Vitor Magacho da Silva <<a href="mailto:pvmagacho@gmail.com" target="_blank">pvmagacho@gmail.com</a>> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
  vlc-android/jni/libvlcjni.c                        |  39 ++++--<br>
  vlc-android/jni/utils.h                            |  12 ++<br>
  vlc-android/jni/vout.c                             | 135 +++++++++++----------<br>
  vlc-android/jni/vout.h                             |   4 -<br>
  vlc-android/src/org/videolan/<u></u>libvlc/LibVLC.java    |  33 +++--<br>
  vlc-android/src/org/videolan/<u></u>libvlc/MediaList.java |   2 +-<br>
  .../org/videolan/vlc/gui/<u></u>PreferencesActivity.java  |   2 +-<br>
  7 files changed, 139 insertions(+), 88 deletions(-)<br>
</blockquote>
<br></div>
Most notably, you have to keep track of which objects belong to which libVLC, and that could get messy.<br>
<br>
I'd like to test this out first, but that will be for tomorrow.<br>
<br>
Some comments inline below.<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c<br>
index 6a08d85..1f11b20 100644<br>
--- a/vlc-android/jni/libvlcjni.c<br>
+++ b/vlc-android/jni/libvlcjni.c<br>
@@ -200,16 +200,12 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)<br>
      // Keep a reference on the Java VM.<br>
      myVm = vm;<br>
  -    pthread_mutex_init(&vout_<u></u>android_lock, NULL);<br>
-    pthread_cond_init(&vout_<u></u>android_surf_attached, NULL);<br>
-<br>
      LOGD("JNI interface loaded.");<br>
      return JNI_VERSION_1_2;<br>
  }<br>
    void JNI_OnUnload(JavaVM* vm, void* reserved) {<br>
-    pthread_mutex_destroy(&vout_<u></u>android_lock);<br>
-    pthread_cond_destroy(&vout_<u></u>android_surf_attached);<br>
+    LOGD("JNI interface un-loaded.");<br>
  }<br>
    // FIXME: use atomics<br>
@@ -217,6 +213,18 @@ static bool verbosity;<br>
    void Java_org_videolan_libvlc_<u></u>LibVLC_nativeInit(JNIEnv *env, jobject thiz)<br>
  {<br>
+    android_surf_value_t *object = (android_surf_value_t *) malloc(sizeof(android_surf_<u></u>value_t));<br>
</blockquote>
<br></div>
More descriptive variable name than 'object' possible?<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+    object->vout_android_surf = NULL;<br>
+    object->vout_android_gui = NULL;<br>
+    object->vout_android_java_surf = NULL;<br>
+    object->vout_android_<u></u>subtitles_surf = NULL;<br>
+<br>
+    pthread_mutex_init(&object-><u></u>vout_android_lock, NULL);<br>
+    pthread_cond_init(&object-><u></u>vout_android_surf_attached, NULL);<br>
+<br>
+    setLong(env, thiz, "mAndroidSurfaceValue", (jlong)(intptr_t)object);<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", "()I");<br>
@@ -318,12 +326,23 @@ void Java_org_videolan_libvlc_<u></u>LibVLC_nativeInit(JNIEnv *env, jobject thiz)<br>
        libvlc_log_set(instance, debug_log, &verbosity);<br>
  -    init_native_crash_handler(env, thiz);<br>
+    // init_native_crash_handler(env, thiz);<br>
</blockquote>
<br></div>
Why?<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  }<br>
    void Java_org_videolan_libvlc_<u></u>LibVLC_nativeDestroy(JNIEnv *env, jobject thiz)<br>
  {<br>
-    destroy_native_crash_handler(<u></u>env);<br>
+    // clear surface lock and condition<br>
+    android_surf_value_t *object = (android_surf_value_t *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
+<br>
+    if (object != NULL) {<br>
+        pthread_mutex_destroy(&object-<u></u>>vout_android_lock);<br>
+        pthread_cond_destroy(&object-><u></u>vout_android_surf_attached);<br>
+<br>
+        free(object);<br>
+    }<br>
+    setLong(env, thiz, "mAndroidSurfaceValue", 0);<br>
+<br>
+    // destroy_native_crash_handler(<u></u>env);<br>
</blockquote></div>
Ditto.<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        releaseMediaPlayer(env, thiz);<br>
      jlong libVlcInstance = getLong(env, thiz, "mLibVlcInstance");<br>
@@ -413,9 +432,13 @@ void Java_org_videolan_libvlc_<u></u>LibVLC_playMRL(JNIEnv *env, jobject thiz, jlong in<br>
              (*env)->ReleaseStringUTFChars(<u></u>env, option, p_st);<br>
          }<br>
      }<br>
-<br>
+<br>
</blockquote>
<br>
?<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
      (*env)->ReleaseStringUTFChars(<u></u>env, mrl, p_mrl);<br>
  +    // set the Android surface value structure<br>
+    android_surf_value_t *object = (android_surf_value_t *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
+    libvlc_media_player_set_<u></u>surfacevalue(mp, object);<br>
+<br>
      /* Connect the media event manager. */<br>
</blockquote>
<br></div>
What about events? How does each instance deal with its own events?<div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
      libvlc_event_manager_t *ev_media = libvlc_media_event_manager(p_<u></u>md);<br>
      static const libvlc_event_type_t mp_media_events[] = {<br>
diff --git a/vlc-android/jni/utils.h b/vlc-android/jni/utils.h<br>
index f8502d9..ccf23aa 100644<br>
--- a/vlc-android/jni/utils.h<br>
+++ b/vlc-android/jni/utils.h<br>
@@ -21,6 +21,18 @@<br>
  #ifndef LIBVLCJNI_UTILS_H<br>
  #define LIBVLCJNI_UTILS_H<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_<u></u>created;<br>
+} android_surf_value_t;<br>
+<br>
  libvlc_media_t *new_media(jlong instance, JNIEnv *env, jobject thiz, jstring fileLocation, bool noOmx, bool noVideo);<br>
    libvlc_media_player_t *getMediaPlayer(JNIEnv *env, jobject thiz);<br>
diff --git a/vlc-android/jni/vout.c b/vlc-android/jni/vout.c<br>
index f2f4346..74e1f1e 100644<br>
--- a/vlc-android/jni/vout.c<br>
+++ b/vlc-android/jni/vout.c<br>
@@ -23,96 +23,94 @@<br>
    #include <jni.h><br>
  +#include "utils.h"<br>
+<br>
  /** Unique Java VM instance, as defined in libvlcjni.c */<br>
  extern JavaVM *myVm;<br>
  -pthread_mutex_t vout_android_lock;<br>
-pthread_cond_t vout_android_surf_attached;<br>
-static void *vout_android_surf = NULL;<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_<u></u>created = false;<br>
-<br>
-void *jni_<u></u>LockAndGetSubtitlesSurface() {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    while (vout_android_subtitles_surf == NULL)<br>
-        pthread_cond_wait(&vout_<u></u>android_surf_attached, &vout_android_lock);<br>
-    return vout_android_subtitles_surf;<br>
+void *jni_<u></u>LockAndGetSubtitlesSurface(<u></u>android_surf_value_t *object) {<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    while (object->vout_android_<u></u>subtitles_surf == NULL)<br>
+        pthread_cond_wait(&object-><u></u>vout_android_surf_attached, &object->vout_android_lock);<br>
+    return object->vout_android_<u></u>subtitles_surf;<br>
  }<br>
  -void *jni_LockAndGetAndroidSurface(<u></u>) {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    while (vout_android_surf == NULL)<br>
-        pthread_cond_wait(&vout_<u></u>android_surf_attached, &vout_android_lock);<br>
-    return vout_android_surf;<br>
+void *jni_LockAndGetAndroidSurface(<u></u>android_surf_value_t *object) {<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    while (object->vout_android_surf == NULL)<br>
+        pthread_cond_wait(&object-><u></u>vout_android_surf_attached, &object->vout_android_lock);<br>
+    return object->vout_android_surf;<br>
  }<br>
  -jobject jni_<u></u>LockAndGetAndroidJavaSurface() {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    while (vout_android_java_surf == NULL)<br>
-        pthread_cond_wait(&vout_<u></u>android_surf_attached, &vout_android_lock);<br>
-    return vout_android_java_surf;<br>
+jobject jni_<u></u>LockAndGetAndroidJavaSurface(<u></u>android_surf_value_t *object) {<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    while (object->vout_android_java_<u></u>surf == NULL)<br>
+        pthread_cond_wait(&object-><u></u>vout_android_surf_attached, &object->vout_android_lock);<br>
+    return object->vout_android_java_<u></u>surf;<br>
  }<br>
  -void jni_UnlockAndroidSurface() {<br>
-    pthread_mutex_unlock(&vout_<u></u>android_lock);<br>
+void jni_UnlockAndroidSurface(<u></u>android_surf_value_t *object) {<br>
+    pthread_mutex_unlock(&object-><u></u>vout_android_lock);<br>
  }<br>
  -void jni_<u></u>EventHardwareAccelerationError<u></u>()<br>
+void jni_<u></u>EventHardwareAccelerationError<u></u>(android_surf_value_t *object)<br>
  {<br>
-    if (vout_android_gui == NULL)<br>
+    if (object->vout_android_gui == NULL)<br>
          return;<br>
        JNIEnv *env;<br>
      (*myVm)->AttachCurrentThread(<u></u>myVm, &env, NULL);<br>
  -    jclass cls = (*env)->GetObjectClass(env, vout_android_gui);<br>
+    jclass cls = (*env)->GetObjectClass(env, object->vout_android_gui);<br>
      jmethodID methodId = (*env)->GetMethodID(env, cls, "<u></u>eventHardwareAccelerationError<u></u>", "()V");<br>
-    (*env)->CallVoidMethod(env, vout_android_gui, methodId);<br>
+    (*env)->CallVoidMethod(env, object->vout_android_gui, methodId);<br>
        (*env)->DeleteLocalRef(env, cls);<br>
      (*myVm)->DetachCurrentThread(<u></u>myVm);<br>
  }<br>
  -void jni_SetAndroidSurfaceSizeEnv(<u></u>JNIEnv *p_env, int width, int height, int visible_width, int visible_height, int sar_num, int sar_den)<br>
+void jni_SetAndroidSurfaceSizeEnv(<u></u>JNIEnv *p_env, android_surf_value_t *object, int width, int height, int visible_width, int visible_height, int sar_num, int sar_den)<br>
  {<br>
-    if (vout_android_gui == NULL)<br>
+    if (object->vout_android_gui == NULL)<br>
          return;<br>
  -    jclass cls = (*p_env)->GetObjectClass (p_env, vout_android_gui);<br>
+    jclass cls = (*p_env)->GetObjectClass (p_env, object->vout_android_gui);<br>
      jmethodID methodId = (*p_env)->GetMethodID (p_env, cls, "setSurfaceSize", "(IIIIII)V");<br>
  -    (*p_env)->CallVoidMethod (p_env, vout_android_gui, methodId, width, height, visible_width, visible_height, sar_num, sar_den);<br>
+    (*p_env)->CallVoidMethod (p_env, object->vout_android_gui, methodId, width, height, visible_width, visible_height, sar_num, sar_den);<br>
        (*p_env)->DeleteLocalRef(p_<u></u>env, cls);<br>
  }<br>
  -void jni_SetAndroidSurfaceSize(int width, int height, int visible_width, int visible_height, int sar_num, int sar_den)<br>
+void jni_SetAndroidSurfaceSize(<u></u>android_surf_value_t *object, int width, int height, int visible_width, int visible_height, int sar_num, int sar_den)<br>
  {<br>
      JNIEnv *p_env;<br>
        (*myVm)->AttachCurrentThread (myVm, &p_env, NULL);<br>
-    jni_SetAndroidSurfaceSizeEnv(<u></u>p_env, width, height, visible_width, visible_height, sar_num, sar_den);<br>
+    jni_SetAndroidSurfaceSizeEnv(<u></u>p_env, object, width, height, visible_width, visible_height, sar_num, sar_den);<br>
        (*myVm)->DetachCurrentThread (myVm);<br>
  }<br>
  -bool jni_<u></u>IsVideoPlayerActivityCreated() {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    bool result = vout_video_player_activity_<u></u>created;<br>
-    pthread_mutex_unlock(&vout_<u></u>android_lock);<br>
+bool jni_<u></u>IsVideoPlayerActivityCreated(<u></u>android_surf_value_t *object) {<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    bool result = object->vout_video_player_<u></u>activity_created;<br>
+    pthread_mutex_unlock(&object-><u></u>vout_android_lock);<br>
      return result;<br>
  }<br>
    void Java_org_videolan_libvlc_<u></u>LibVLC_<u></u>eventVideoPlayerActivityCreate<u></u>d(JNIEnv *env, jobject thiz, jboolean created) {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    vout_video_player_activity_<u></u>created = created;<br>
-    pthread_mutex_unlock(&vout_<u></u>android_lock);<br>
+    android_surf_value_t * object = (android_surf_value_t *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
+<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    object->vout_video_player_<u></u>activity_created = created;<br>
+    pthread_mutex_unlock(&object-><u></u>vout_android_lock);<br>
  }<br>
    void Java_org_videolan_libvlc_<u></u>LibVLC_attachSurface(JNIEnv *env, jobject thiz, jobject surf, jobject gui) {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
+    android_surf_value_t * object = (android_surf_value_t *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
+<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
      jclass clz;<br>
      jfieldID fid;<br>
  @@ -131,39 +129,46 @@ void Java_org_videolan_libvlc_<u></u>LibVLC_attachSurface(JNIEnv *env, jobject thiz, jo<br>
              }<br>
              fid = (*env)->GetFieldID(env, clz, "mNativeSurface", "I");<br>
          }<br>
-        vout_android_surf = (void*)(*env)->GetIntField(<u></u>env, surf, fid);<br>
+<br>
+        object->vout_android_surf = (void*)(*env)->GetIntField(<u></u>env, surf, fid);<br>
          (*env)->DeleteLocalRef(env, clz);<br>
      }<br>
-    vout_android_gui = (*env)->NewGlobalRef(env, gui);<br>
-    vout_android_java_surf = (*env)->NewGlobalRef(env, surf);<br>
-    pthread_cond_signal(&vout_<u></u>android_surf_attached);<br>
-    pthread_mutex_unlock(&vout_<u></u>android_lock);<br>
+    object->vout_android_gui = (*env)->NewGlobalRef(env, gui);<br>
+    object->vout_android_java_surf = (*env)->NewGlobalRef(env, surf);<br>
+    pthread_cond_signal(&object-><u></u>vout_android_surf_attached);<br>
+    pthread_mutex_unlock(&object-><u></u>vout_android_lock);<br>
  }<br>
    void Java_org_videolan_libvlc_<u></u>LibVLC_detachSurface(JNIEnv *env, jobject thiz) {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    vout_android_surf = NULL;<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_<u></u>android_lock);<br>
+    android_surf_value_t *object = (android_surf_value_t *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
+<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    object->vout_android_surf = NULL;<br>
+    if (object->vout_android_gui != NULL)<br>
+        (*env)->DeleteGlobalRef(env, object->vout_android_gui);<br>
+    if (object->vout_android_java_<u></u>surf != NULL)<br>
+        (*env)->DeleteGlobalRef(env, object->vout_android_java_<u></u>surf);<br>
+    object->vout_android_gui = NULL;<br>
+    object->vout_android_java_surf = NULL;<br>
+    pthread_mutex_unlock(&object-><u></u>vout_android_lock);<br>
  }<br>
    void Java_org_videolan_libvlc_<u></u>LibVLC_attachSubtitlesSurface(<u></u>JNIEnv *env, jobject thiz, jobject surf) {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    vout_android_subtitles_surf = (*env)->NewGlobalRef(env, surf);<br>
-    pthread_cond_signal(&vout_<u></u>android_surf_attached);<br>
-    pthread_mutex_unlock(&vout_<u></u>android_lock);<br>
+    android_surf_value_t *object = (android_surf_value_t *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
+<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    object->vout_android_<u></u>subtitles_surf = (*env)->NewGlobalRef(env, surf);<br>
+    pthread_cond_signal(&object-><u></u>vout_android_surf_attached);<br>
+    pthread_mutex_unlock(&object-><u></u>vout_android_lock);<br>
  }<br>
    void Java_org_videolan_libvlc_<u></u>LibVLC_detachSubtitlesSurface(<u></u>JNIEnv *env, jobject thiz) {<br>
-    pthread_mutex_lock(&vout_<u></u>android_lock);<br>
-    (*env)->DeleteGlobalRef(env, vout_android_subtitles_surf);<br>
-    vout_android_subtitles_surf = NULL;<br>
-    pthread_mutex_unlock(&vout_<u></u>android_lock);<br>
+    android_surf_value_t *object = (android_surf_value_t *)(intptr_t)getLong(env, thiz, "mAndroidSurfaceValue");<br>
+<br>
+    pthread_mutex_lock(&object-><u></u>vout_android_lock);<br>
+    (*env)->DeleteGlobalRef(env, object->vout_android_<u></u>subtitles_surf);<br>
+    object->vout_android_<u></u>subtitles_surf = NULL;<br>
+    pthread_mutex_unlock(&object-><u></u>vout_android_lock);<br>
  }<br>
    static int mouse_x = -1;<br>
diff --git a/vlc-android/jni/vout.h b/vlc-android/jni/vout.h<br>
index c3d4fd7..d14957a 100644<br>
--- a/vlc-android/jni/vout.h<br>
+++ b/vlc-android/jni/vout.h<br>
@@ -21,8 +21,4 @@<br>
  #ifndef LIBVLCJNI_VOUT_H<br>
  #define LIBVLCJNI_VOUT_H<br>
  -/* vout lock initialized in vout.c */<br>
-pthread_mutex_t vout_android_lock;<br>
-pthread_cond_t vout_android_surf_attached;<br>
-<br>
  #endif // LIBVLCJNI_VOUT_H<br>
diff --git a/vlc-android/src/org/<u></u>videolan/libvlc/LibVLC.java b/vlc-android/src/org/<u></u>videolan/libvlc/LibVLC.java<br>
index 5ac201e..abc50a7 100644<br>
--- a/vlc-android/src/org/<u></u>videolan/libvlc/LibVLC.java<br>
+++ b/vlc-android/src/org/<u></u>videolan/libvlc/LibVLC.java<br>
@@ -51,6 +51,9 @@ public class LibVLC {<br>
      private int mInternalMediaPlayerIndex = 0; // Read-only, reserved for JNI<br>
      private long mInternalMediaPlayerInstance = 0; // Read-only, reserved for JNI<br>
  +    private long mAndroidSurfaceValue = 0; // Read-only, reserved for JNI<br>
+    private long mInternalSurface = 0; // Read-only, reserved for JNI<br>
+<br>
      private MediaList mMediaList; // Pointer to media list being followed<br>
      private MediaList mPrimaryList; // Primary/default media list; see getPrimaryMediaList()<br>
  @@ -128,7 +131,7 @@ public class LibVLC {<br>
      public static LibVLC getInstance() throws LibVlcException {<br>
          synchronized (LibVLC.class) {<br>
              if (sInstance == null) {<br>
-                /* First call */<br>
+                // First call //<br>
</blockquote>
<br></div></div>
Unneeded change.<div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  sInstance = new LibVLC();<br>
              }<br>
          }<br>
@@ -149,10 +152,9 @@ public class LibVLC {<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>
  @@ -218,7 +220,7 @@ public class LibVLC {<br>
       */<br>
      public native void setSurface(Surface f);<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>
@@ -226,6 +228,15 @@ public class LibVLC {<br>
              } catch (LibVlcException lve) {<br>
                  Log.e(TAG, "Unable to reinit libvlc: " + lve);<br>
              }<br>
+       }<br>
+    }<br>
+<br>
+    public synchronized 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>
  @@ -341,7 +352,7 @@ public class LibVLC {<br>
          applyEqualizer();<br>
      }<br>
  -    private void applyEqualizer()<br>
+    protected void applyEqualizer()<br>
</blockquote>
<br></div></div>
Why?<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
      {<br>
          setNativeEqualizer(<u></u>mInternalMediaPlayerInstance, this.equalizer);<br>
      }<br>
@@ -381,7 +392,9 @@ public class LibVLC {<br>
                File cacheDir = context.getCacheDir();<br>
              mCachePath = (cacheDir != null) ? cacheDir.getAbsolutePath() : null;<br>
-            nativeInit();<br>
+            synchronized (LibVLC.class) {<br>
+                nativeInit();<br>
+            }<br>
</blockquote>
<br></div>
Why?<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              mMediaList = mPrimaryList = new MediaList(this);<br>
              setEventHandler(EventHandler.<u></u>getInstance());<br>
              mIsInitialized = true;<br>
@@ -394,7 +407,9 @@ public class LibVLC {<br>
       */<br>
      public void destroy() {<br>
          Log.v(TAG, "Destroying LibVLC instance");<br>
-        nativeDestroy();<br>
+        synchronized (LibVLC.class) {<br>
+            nativeDestroy();<br>
+        }<br>
</blockquote>
<br></div>
Ditto.<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          detachEventHandler();<br>
          mIsInitialized = false;<br>
      }<br>
@@ -647,7 +662,7 @@ public class LibVLC {<br>
      public native int getSpuTracksCount();<br>
        public static native String nativeToURI(String path);<br>
-<br>
+<br>
</blockquote>
<br>
?<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
      public native static void sendMouseEvent( int action, int button, int x, int y);<br>
        /**<br>
diff --git a/vlc-android/src/org/<u></u>videolan/libvlc/MediaList.java b/vlc-android/src/org/<u></u>videolan/libvlc/MediaList.java<br>
index 85b2d2a..1889481 100644<br>
--- a/vlc-android/src/org/<u></u>videolan/libvlc/MediaList.java<br>
+++ b/vlc-android/src/org/<u></u>videolan/libvlc/MediaList.java<br>
@@ -32,7 +32,7 @@ public class MediaList {<br>
        /* Since the libvlc_media_t is not created until the media plays, we have<br>
       * to cache them here. */<br>
-    private static class MediaHolder {<br>
+    private class MediaHolder {<br>
</blockquote>
<br></div>
Why?<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          Media m;<br>
          boolean noVideo; // default false<br>
          boolean noHardwareAcceleration; // default false<br>
diff --git a/vlc-android/src/org/<u></u>videolan/vlc/gui/<u></u>PreferencesActivity.java b/vlc-android/src/org/<u></u>videolan/vlc/gui/<u></u>PreferencesActivity.java<br>
index 4c9539f..eedadf5 100644<br>
--- a/vlc-android/src/org/<u></u>videolan/vlc/gui/<u></u>PreferencesActivity.java<br>
+++ b/vlc-android/src/org/<u></u>videolan/vlc/gui/<u></u>PreferencesActivity.java<br>
@@ -291,7 +291,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP<br>
                  || key.equalsIgnoreCase("enable_<u></u>verbose_mode")<br>
                  || key.equalsIgnoreCase("network_<u></u>caching")) {<br>
              VLCInstance.<u></u>updateLibVlcSettings(<u></u>sharedPreferences);<br>
-            LibVLC.restart(this);<br>
+            LibVLC.restartInstance(this);<br>
          }<br>
      }<br>
  <br>
</blockquote>
<br></div>
______________________________<u></u>_________________<br>
Android mailing list<br>
<a href="mailto:Android@videolan.org" target="_blank">Android@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/android" target="_blank">https://mailman.videolan.org/<u></u>listinfo/android</a><br>
</blockquote></div><br></div>