Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java

Issue 1419693004: Fix for "Android audio playout doesn't support non-call media stream" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback from magjed@ Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
index 0602e44c2376ba0daa0359ed506d1ab67bab09fa..ec0e10916945e4f79e09b4c96234cbc6352dea0f 100644
--- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
+++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
@@ -39,6 +39,7 @@ class WebRtcAudioTrack {
private final Context context;
private final long nativeAudioTrack;
private final AudioManager audioManager;
+ private final int streamType;
private ByteBuffer byteBuffer;
@@ -141,6 +142,9 @@ class WebRtcAudioTrack {
this.nativeAudioTrack = nativeAudioTrack;
audioManager = (AudioManager) context.getSystemService(
Context.AUDIO_SERVICE);
+ this.streamType =
+ WebRtcAudioUtils.getOutputStreamTypeFromAudioMode(
+ audioManager.getMode());
if (DEBUG) {
WebRtcAudioUtils.logDeviceInfo(TAG);
}
@@ -177,7 +181,7 @@ class WebRtcAudioTrack {
// Create an AudioTrack object and initialize its associated audio buffer.
// The size of this buffer determines how long an AudioTrack can play
// before running out of data.
- audioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
+ audioTrack = new AudioTrack(streamType,
sampleRate,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
@@ -189,7 +193,7 @@ class WebRtcAudioTrack {
}
assertTrue(audioTrack.getState() == AudioTrack.STATE_INITIALIZED);
assertTrue(audioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED);
- assertTrue(audioTrack.getStreamType() == AudioManager.STREAM_VOICE_CALL);
+ assertTrue(audioTrack.getStreamType() == streamType);
}
private boolean startPlayout() {
@@ -213,14 +217,14 @@ class WebRtcAudioTrack {
return true;
}
- /** Get max possible volume index for a phone call audio stream. */
+ /** Get max possible volume index given type of audio stream. */
private int getStreamMaxVolume() {
Logging.d(TAG, "getStreamMaxVolume");
assertTrue(audioManager != null);
- return audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
+ return audioManager.getStreamMaxVolume(streamType);
}
- /** Set current volume level for a phone call audio stream. */
+ /** Set current volume level given type of audio stream. */
private boolean setStreamVolume(int volume) {
Logging.d(TAG, "setStreamVolume(" + volume + ")");
assertTrue(audioManager != null);
@@ -230,15 +234,15 @@ class WebRtcAudioTrack {
return false;
}
}
- audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, volume, 0);
+ audioManager.setStreamVolume(streamType, volume, 0);
return true;
}
- /** Get current volume level for a phone call audio stream. */
+ /** Get current volume level given type of audio stream. */
private int getStreamVolume() {
Logging.d(TAG, "getStreamVolume");
assertTrue(audioManager != null);
- return audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
+ return audioManager.getStreamVolume(streamType);
}
/** Helper method which throws an exception when an assertion has failed. */

Powered by Google App Engine
This is Rietveld 408576698