Commit 4b484911 authored by Thomas Guillem's avatar Thomas Guillem Committed by Geoffrey Métais

LibVLC: MediaPlayer: add setAudioDigitalOutputEnabled

(cherry picked from commit c5cb324d)
parent 3e81856d
......@@ -369,6 +369,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
private String mAudioOutputDevice = null;
private boolean mAudioPlugRegistered = false;
private boolean mAudioDigitalOutputEnabled = false;
private String mAudioPlugOutputDevice = "stereo";
private final AWindow mWindow = new AWindow(new AWindow.SurfaceCallback() {
......@@ -400,8 +401,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
}
});
private void updateAudioOutputDevice(long encodingFlags, String defaultDevice) {
final String newDeviceId = encodingFlags != 0 ? "encoded:" + encodingFlags : defaultDevice;
private synchronized void updateAudioOutputDevice(long encodingFlags, String defaultDevice) {
final String newDeviceId = mAudioDigitalOutputEnabled && encodingFlags != 0 ? "encoded:" + encodingFlags : defaultDevice;
if (!newDeviceId.equals(mAudioPlugOutputDevice)) {
mAudioPlugOutputDevice = newDeviceId;
setAudioOutputDeviceInternal(mAudioPlugOutputDevice, false);
......@@ -742,6 +743,27 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
return ret;
}
/**
* Enable or disable Digital Output
*
* Works only with AudioTrack AudioOutput.
* If {@link #setAudioOutputDevice} was previously called, this method won't have any effects.
*
* @param enabled true to enable Digital Output
* @return true on success
*/
public synchronized boolean setAudioDigitalOutputEnabled(boolean enabled) {
if (enabled == mAudioDigitalOutputEnabled)
return true;
if (!mListenAudioPlug || !isAudioTrack())
return false;
registerAudioPlug(false);
mAudioDigitalOutputEnabled = enabled;
registerAudioPlug(true);
return true;
}
private synchronized boolean setAudioOutputDeviceInternal(String id, boolean fromUser) {
mAudioOutputDevice = id;
if (fromUser) {
......
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