Commit 5b9c94da authored by Alexandre Janniaux's avatar Alexandre Janniaux Committed by 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: default avatarGeoffrey Métais <geoffrey.metais@gmail.com>
(cherry picked from commit f3316483)
parent c3b48fc9
......@@ -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;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment