[Android] HWDecoderUtil: add getAudioOutputFromDevice()
Thomas Guillem
git at videolan.org
Wed Apr 1 12:11:41 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Mar 31 17:11:36 2015 +0200| [71e7822675ab28a638be27277c6f70c7b9a06477] | committer: Thomas Guillem
HWDecoderUtil: add getAudioOutputFromDevice()
Return the audio output known to work for the running device.
Only AudioTrack before GingerBread, OpenSles and AudioTrack after.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=71e7822675ab28a638be27277c6f70c7b9a06477
---
libvlc/src/org/videolan/libvlc/HWDecoderUtil.java | 52 +++++++++++++++++++--
1 file changed, 47 insertions(+), 5 deletions(-)
diff --git a/libvlc/src/org/videolan/libvlc/HWDecoderUtil.java b/libvlc/src/org/videolan/libvlc/HWDecoderUtil.java
index 58ffd25..3b335b7 100644
--- a/libvlc/src/org/videolan/libvlc/HWDecoderUtil.java
+++ b/libvlc/src/org/videolan/libvlc/HWDecoderUtil.java
@@ -32,6 +32,9 @@ public class HWDecoderUtil {
UNKNOWN, NONE, OMX, MEDIACODEC, ALL
}
+ public enum AudioOutput {
+ OPENSLES, AUDIOTRACK, ALL
+ }
private static class DecoderBySOC {
public final String key;
@@ -44,6 +47,18 @@ public class HWDecoderUtil {
}
}
+ private static class AudioOutputBySOC {
+ public final String key;
+ public final String value;
+ public final AudioOutput aout;
+
+ public AudioOutputBySOC(String key, String value, AudioOutput aout) {
+ this.key = key;
+ this.value = value;
+ this.aout = aout;
+ }
+ }
+
private static final DecoderBySOC[] sDecoderBySOCList = new DecoderBySOC[] {
/*
* Put first devices you want to blacklist
@@ -81,6 +96,9 @@ public class HWDecoderUtil {
new DecoderBySOC("ro.hardware", "mt83", Decoder.ALL), //MTK
};
+ private static final AudioOutputBySOC[] sAudioOutputBySOCList = new AudioOutputBySOC[] {
+ };
+
private static final HashMap<String, String> sSystemPropertyMap = new HashMap<String, String>();
/**
@@ -97,11 +115,7 @@ public class HWDecoderUtil {
return Decoder.ALL;
else if (LibVlcUtil.isHoneycombOrLater()) {
for (DecoderBySOC decBySOC : sDecoderBySOCList) {
- String prop = sSystemPropertyMap.get(decBySOC.key);
- if (prop == null) {
- prop = getSystemProperty(decBySOC.key, "none");
- sSystemPropertyMap.put(decBySOC.key, prop);
- }
+ final String prop = getSystemPropertyCached(decBySOC.key);
if (prop != null) {
if (prop.contains(decBySOC.value))
return decBySOC.dec;
@@ -111,6 +125,34 @@ public class HWDecoderUtil {
return Decoder.UNKNOWN;
}
+ /**
+ * @return the audio output known to work for the running device
+ * (By default, returns ALL, i.e AudioTrack + OpenSles)
+ */
+ public static AudioOutput getAudioOutputFromDevice() {
+ if (!LibVlcUtil.isGingerbreadOrLater()) {
+ return AudioOutput.AUDIOTRACK;
+ } else {
+ for (AudioOutputBySOC aoutBySOC : sAudioOutputBySOCList) {
+ final String prop = getSystemPropertyCached(aoutBySOC.key);
+ if (prop != null) {
+ if (prop.contains(aoutBySOC.value))
+ return aoutBySOC.aout;
+ }
+ }
+ return AudioOutput.ALL;
+ }
+ }
+
+ private static String getSystemPropertyCached(String key) {
+ String prop = sSystemPropertyMap.get(key);
+ if (prop == null) {
+ prop = getSystemProperty(key, "none");
+ sSystemPropertyMap.put(key, prop);
+ }
+ return prop;
+ }
+
private static String getSystemProperty(String key, String def) {
try {
final ClassLoader cl = ClassLoader.getSystemClassLoader();
More information about the Android
mailing list