Skip to content
Snippets Groups Projects
Commit f3316483 authored by Alexandre Janniaux's avatar Alexandre Janniaux Committed by Geoffrey Métais
Browse files

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>
parent fcb45f49
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment