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

LibVLC: MediaPlayer: add setAudioDigitalOutputEnabled

parent bfa84f3c
...@@ -369,6 +369,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> { ...@@ -369,6 +369,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
private String mAudioOutputDevice = null; private String mAudioOutputDevice = null;
private boolean mAudioPlugRegistered = false; private boolean mAudioPlugRegistered = false;
private boolean mAudioDigitalOutputEnabled = false;
private String mAudioPlugOutputDevice = "stereo"; private String mAudioPlugOutputDevice = "stereo";
private final AWindow mWindow = new AWindow(new AWindow.SurfaceCallback() { private final AWindow mWindow = new AWindow(new AWindow.SurfaceCallback() {
...@@ -400,8 +401,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> { ...@@ -400,8 +401,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
} }
}); });
private void updateAudioOutputDevice(long encodingFlags, String defaultDevice) { private synchronized void updateAudioOutputDevice(long encodingFlags, String defaultDevice) {
final String newDeviceId = encodingFlags != 0 ? "encoded:" + encodingFlags : defaultDevice; final String newDeviceId = mAudioDigitalOutputEnabled && encodingFlags != 0 ? "encoded:" + encodingFlags : defaultDevice;
if (!newDeviceId.equals(mAudioPlugOutputDevice)) { if (!newDeviceId.equals(mAudioPlugOutputDevice)) {
mAudioPlugOutputDevice = newDeviceId; mAudioPlugOutputDevice = newDeviceId;
setAudioOutputDeviceInternal(mAudioPlugOutputDevice, false); setAudioOutputDeviceInternal(mAudioPlugOutputDevice, false);
...@@ -742,6 +743,27 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> { ...@@ -742,6 +743,27 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
return ret; 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) { private synchronized boolean setAudioOutputDeviceInternal(String id, boolean fromUser) {
mAudioOutputDevice = id; mAudioOutputDevice = id;
if (fromUser) { 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