Volume buttons in AppRTCDemo should affect output audio volume (part II).
See https://webrtc-codereview.appspot.com/32399004/ for part I.
BUG=3279
TEST=AppRTC demo
R=perkj@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/27059004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7654 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_device/android/opensles_input.cc b/webrtc/modules/audio_device/android/opensles_input.cc
index f22d8bf..e68a6aa 100644
--- a/webrtc/modules/audio_device/android/opensles_input.cc
+++ b/webrtc/modules/audio_device/android/opensles_input.cc
@@ -360,6 +360,24 @@
req),
false);
+ SLAndroidConfigurationItf recorder_config;
+ OPENSL_RETURN_ON_FAILURE(
+ (*sles_recorder_)->GetInterface(sles_recorder_,
+ SL_IID_ANDROIDCONFIGURATION,
+ &recorder_config),
+ false);
+
+ // Set audio recorder configuration to
+ // SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION which ensures that we
+ // use the main microphone tuned for audio communications.
+ SLint32 stream_type = SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
+ OPENSL_RETURN_ON_FAILURE(
+ (*recorder_config)->SetConfiguration(recorder_config,
+ SL_ANDROID_KEY_RECORDING_PRESET,
+ &stream_type,
+ sizeof(SLint32)),
+ false);
+
// Realize the recorder in synchronous mode.
OPENSL_RETURN_ON_FAILURE((*sles_recorder_)->Realize(sles_recorder_,
SL_BOOLEAN_FALSE),
diff --git a/webrtc/modules/audio_device/android/opensles_output.cc b/webrtc/modules/audio_device/android/opensles_output.cc
index 377789b..487e284 100644
--- a/webrtc/modules/audio_device/android/opensles_output.cc
+++ b/webrtc/modules/audio_device/android/opensles_output.cc
@@ -407,6 +407,24 @@
&audio_source, &audio_sink,
kNumInterfaces, ids, req),
false);
+
+ SLAndroidConfigurationItf player_config;
+ OPENSL_RETURN_ON_FAILURE(
+ (*sles_player_)->GetInterface(sles_player_,
+ SL_IID_ANDROIDCONFIGURATION,
+ &player_config),
+ false);
+
+ // Set audio player configuration to SL_ANDROID_STREAM_VOICE which corresponds
+ // to android.media.AudioManager.STREAM_VOICE_CALL.
+ SLint32 stream_type = SL_ANDROID_STREAM_VOICE;
+ OPENSL_RETURN_ON_FAILURE(
+ (*player_config)->SetConfiguration(player_config,
+ SL_ANDROID_KEY_STREAM_TYPE,
+ &stream_type,
+ sizeof(SLint32)),
+ false);
+
// Realize the player in synchronous mode.
OPENSL_RETURN_ON_FAILURE((*sles_player_)->Realize(sles_player_,
SL_BOOLEAN_FALSE),