From 645e32af3f009d7dbcbcdd206d9c68c96d19633c Mon Sep 17 00:00:00 2001 From: Thomas Guillem Date: Tue, 7 Apr 2015 11:36:30 +0200 Subject: [PATCH] LibVLC: add a method to activate spdif and surround --- libvlc/jni/libvlcjni.c | 11 +++++++++-- libvlc/src/org/videolan/libvlc/LibVLC.java | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c index 0cea0f5cd..3b8fe8e16 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 22 const char *argv[MAX_ARGV]; int argc = 0; @@ -500,7 +503,11 @@ 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-audio-channels"; + argv[argc++] = "8"; // 7.1 maximum + } 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 4bcaad1d6..271241418 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; } -- GitLab