From dd43bbed8f5bcaeab27750702b367405fb444ebe Mon Sep 17 00:00:00 2001 From: "henrika@webrtc.org" Date: Thu, 6 Nov 2014 15:48:05 +0000 Subject: [PATCH] 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 --- .../audio_device/android/opensles_input.cc | 18 ++++++++++++++++++ .../audio_device/android/opensles_output.cc | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/webrtc/modules/audio_device/android/opensles_input.cc b/webrtc/modules/audio_device/android/opensles_input.cc index f22d8bf7ef..e68a6aa2f8 100644 --- a/webrtc/modules/audio_device/android/opensles_input.cc +++ b/webrtc/modules/audio_device/android/opensles_input.cc @@ -360,6 +360,24 @@ bool OpenSlesInput::CreateAudioRecorder() { 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 377789b237..487e284042 100644 --- a/webrtc/modules/audio_device/android/opensles_output.cc +++ b/webrtc/modules/audio_device/android/opensles_output.cc @@ -407,6 +407,24 @@ bool OpenSlesOutput::CreateAudioPlayer() { &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),