[Android] [PATCH 2/4] LibVLC: add a method to activate spdif and surround

Thomas Guillem thomas at gllm.fr
Tue Apr 7 11:40:34 CEST 2015


---
 libvlc/jni/libvlcjni.c                     | 10 ++++++++--
 libvlc/src/org/videolan/libvlc/LibVLC.java |  9 +++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 0cea0f5..2b6fba4 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -461,7 +461,10 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
         (*env)->ReleaseStringUTFChars(env, cachePath, cache_path);
     }
 
-#define MAX_ARGV 20
+    methodId = (*env)->GetMethodID(env, cls, "isHdmiAudioEnabled", "()Z");
+    bool hdmi_audio = (*env)->CallBooleanMethod(env, thiz, methodId);
+
+#define MAX_ARGV 21
     const char *argv[MAX_ARGV];
     int argc = 0;
 
@@ -500,7 +503,10 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
         argv[argc++] = "--no-omxil-dr";
 #endif
     }
-    argv[argc++] = "--spdif";
+    if (hdmi_audio) {
+        argv[argc++] = "--spdif";
+        argv[argc++] = "--audiotrack-surround";
+    }
     argv[argc++] = b_verbose ? "-vvv" : "-vv";
 
     /* Reconnect on lost HTTP streams, e.g. network change */
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 4bcaad1..2712414 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -86,6 +86,7 @@ public class LibVLC {
     private boolean frameSkip = false;
     private int networkCaching = 0;
     private boolean httpReconnect = false;
+    private boolean hdmiAudioEnabled = false;
 
     /** Path of application-specific cache */
     private String mCachePath = "";
@@ -338,6 +339,14 @@ public class LibVLC {
             this.vout = VOUT_ANDROID_WINDOW;
     }
 
+    public void setHdmiAudioEnabled(boolean enable) {
+        this.hdmiAudioEnabled = enable;
+    }
+
+    public boolean isHdmiAudioEnabled() {
+        return this.hdmiAudioEnabled;
+    }
+
     public boolean useCompatSurface() {
         return this.vout != VOUT_ANDROID_WINDOW;
     }
-- 
2.1.3



More information about the Android mailing list