[Android] LibVLC: MediaPlayer: add setAudioDigitalOutputEnabled
Thomas Guillem
git at videolan.org
Fri Mar 30 16:51:26 CEST 2018
vlc-android | branch: 3.0.x | Thomas Guillem <thomas at gllm.fr> | Mon Mar 26 15:06:46 2018 +0200| [4b484911eac5be1849279bb0baf0a3572ea4bd7c] | committer: Geoffrey Métais
LibVLC: MediaPlayer: add setAudioDigitalOutputEnabled
(cherry picked from commit c5cb324deed41dcf720976f357bbbd46ce838c73)
> https://code.videolan.org/videolan/vlc-android/commit/4b484911eac5be1849279bb0baf0a3572ea4bd7c
---
libvlc/src/org/videolan/libvlc/MediaPlayer.java | 26 +++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 5cd6e8f31..8bb52e2fa 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -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) {
More information about the Android
mailing list