[Android] [PATCH 3/4] Use HWDecoderUtil.getAudioOutputFromDevice

Thomas Guillem thomas at gllm.fr
Tue Mar 31 17:24:27 CEST 2015


---
 libvlc/src/org/videolan/libvlc/LibVLC.java                   |  9 +++++----
 .../src/org/videolan/vlc/gui/PreferencesActivity.java        | 12 +++++++-----
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 0dfe95b..4bcaad1 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -318,10 +318,11 @@ public class LibVLC {
     }
 
     public void setAout(int aout) {
-        if (aout == AOUT_OPENSLES && LibVlcUtil.isICSOrLater())
-            this.aout = AOUT_OPENSLES;
-        else
-            this.aout = AOUT_AUDIOTRACK;
+        final HWDecoderUtil.AudioOutput hwaout = HWDecoderUtil.getAudioOutputFromDevice();
+        if (hwaout == HWDecoderUtil.AudioOutput.AUDIOTRACK || hwaout == HWDecoderUtil.AudioOutput.OPENSLES)
+            aout = hwaout == HWDecoderUtil.AudioOutput.OPENSLES ? AOUT_OPENSLES : AOUT_AUDIOTRACK;
+
+        this.aout = aout == AOUT_OPENSLES ? AOUT_OPENSLES : AOUT_AUDIOTRACK;
     }
 
     public int getVout() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index d3fa303..89e5e37 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -20,6 +20,7 @@
 
 package org.videolan.vlc.gui;
 
+import org.videolan.libvlc.HWDecoderUtil;
 import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.LibVlcUtil;
 import org.videolan.vlc.MediaDatabase;
@@ -219,7 +220,12 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
 
         // Audio output
         ListPreference aoutPref = (ListPreference) findPreference("aout");
-        if (LibVlcUtil.isGingerbreadOrLater()) {
+        final HWDecoderUtil.AudioOutput aout = HWDecoderUtil.getAudioOutputFromDevice();
+        if (aout == HWDecoderUtil.AudioOutput.AUDIOTRACK || aout == HWDecoderUtil.AudioOutput.OPENSLES) {
+            /* no AudioOutput choice */
+            PreferenceGroup group = (PreferenceGroup) findPreference("advanced_prefs_group");
+            group.removePreference(aoutPref);
+        } else {
             int aoutEntriesId = R.array.aouts;
             int aoutEntriesIdValues = R.array.aouts_values;
             aoutPref.setEntries(aoutEntriesId);
@@ -233,10 +239,6 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
                 if (intValue != LibVLC.AOUT_AUDIOTRACK && intValue != LibVLC.AOUT_OPENSLES)
                     aoutPref.setValue(String.valueOf(LibVLC.AOUT_AUDIOTRACK));
             }
-        } else {
-            /* only audiotrack before gingerbread */
-            PreferenceGroup group = (PreferenceGroup) findPreference("advanced_prefs_group");
-            group.removePreference(aoutPref);
         }
         // Video output
 //        FIXME : This setting is disable until OpenGL it's fixed
-- 
2.1.3



More information about the Android mailing list