[Android] Generate audio session id in VLCOptions for libVLC
Alexandre Janniaux
git at videolan.org
Fri Feb 23 17:32:16 CET 2018
vlc-android | branch: 3.0.x | Alexandre Janniaux <alexandre.janniaux at gmail.com> | Thu Feb 22 18:31:26 2018 +0100| [5b9c94da477c042e4c4c518388daf63d31cc07e5] | committer: Geoffrey Métais
Generate audio session id in VLCOptions for libVLC
Generate an audio session id from AudioManager and pass it to libVLC as
a command line argument so that it creates AudioTrack in this session.
Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>
(cherry picked from commit f3316483e3bf3060910ef386590d6ffdfb7780df)
> https://code.videolan.org/videolan/vlc-android/commit/5b9c94da477c042e4c4c518388daf63d31cc07e5
---
vlc-android/src/org/videolan/vlc/util/VLCOptions.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
index 46b2f72aa..2aeadd669 100644
--- a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
+++ b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
@@ -22,6 +22,8 @@ package org.videolan.vlc.util;
import android.content.Context;
import android.content.SharedPreferences;
+import android.media.AudioManager;
+import android.os.Build;
import android.preference.PreferenceManager;
import android.support.annotation.MainThread;
import android.util.Log;
@@ -52,11 +54,19 @@ public class VLCOptions {
public static final int HW_ACCELERATION_DECODING = 1;
public static final int HW_ACCELERATION_FULL = 2;
+ private static int AUDIOTRACK_SESSION_ID = 0;
+
// TODO should return List<String>
public static ArrayList<String> getLibOptions() {
final Context context = VLCApplication.getAppContext();
final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
+ /* generate an audio session id so as to share audio output with external equalizer */
+ if (Build.VERSION.SDK_INT >= 21 && AUDIOTRACK_SESSION_ID == 0) {
+ AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+ AUDIOTRACK_SESSION_ID = audioManager.generateAudioSessionId();
+ }
+
ArrayList<String> options = new ArrayList<String>(50);
final boolean timeStrechingDefault = VLCApplication.getAppResources().getBoolean(R.bool.time_stretching_default);
@@ -103,6 +113,7 @@ public class VLCOptions {
options.add(chroma);
options.add("--audio-resampler");
options.add(getResampler());
+ options.add("--audiotrack-session-id=" + AUDIOTRACK_SESSION_ID);
options.add("--freetype-rel-fontsize=" + freetypeRelFontsize);
if (freetypeBold)
@@ -323,4 +334,8 @@ public class VLCOptions {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean("equalizer_enabled", false);
}
+
+ public static int getAudiotrackSessionId() {
+ return AUDIOTRACK_SESSION_ID;
+ }
}
More information about the Android
mailing list