| 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. */
|
|
|