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

Unified Diff: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.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/WebRtcAudioUtils.java
diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java
index 9d7a600190c5151e689a75c8f4d156f2249ef2bd..f08e11dad88833cce0efe144176025214ac8920e 100644
--- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java
+++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java
@@ -193,5 +193,37 @@ public final class WebRtcAudioUtils {
permission,
Process.myPid(),
Process.myUid()) == PackageManager.PERMISSION_GRANTED;
+ }
+
+ // Convert the provided audio |mode| into most suitable audio output stream
+ // type. The stream type is used for creating audio streams and for volume
+ // changes. It is essential that the mode and type are in-line to ensure
+ // correct behavior. If for example a STREAM_MUSIC type of stream is created
+ // in a MODE_IN_COMMUNICATION mode, audio will be played out and the volume
+ // icon will look OK but the actual volume will not be changed when the user
+ // changes the volume slider.
+ // TODO(henrika): there is currently no mapping to STREAM_ALARM, STREAM_DTMF,
+ // or STREAM_NOTIFICATION types since I am unable to see a reason for using
+ // them. There are only four different modes.
+ public static int getOutputStreamTypeFromAudioMode(int mode) {
+ Logging.d(TAG, "getOutputStreamTypeFromAudioMode(mode=" + mode + ")");
+ switch (mode) {
+ case AudioManager.MODE_NORMAL:
+ // The audio stream for music playback.
+ Logging.d(TAG, "AudioManager.STREAM_MUSIC");
+ return AudioManager.STREAM_MUSIC;
+ case AudioManager.MODE_RINGTONE:
+ // Audio stream for the phone ring.
+ Logging.d(TAG, "AudioManager.STREAM_RING");
+ return AudioManager.STREAM_RING;
+ case AudioManager.MODE_IN_CALL:
+ case AudioManager.MODE_IN_COMMUNICATION:
+ // Audio stream for phone calls.
+ Logging.d(TAG, "AudioManager.STREAM_VOICE_CALL");
+ return AudioManager.STREAM_VOICE_CALL;
+ default:
+ Logging.d(TAG, "AudioManager.USE_DEFAULT_STREAM_TYPE");
+ return AudioManager.USE_DEFAULT_STREAM_TYPE;
}
+ }
}

Powered by Google App Engine
This is Rietveld 408576698