summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhenrika@webrtc.org <henrika@webrtc.org>2014-11-06 15:48:05 +0000
committerhenrika@webrtc.org <henrika@webrtc.org>2014-11-06 15:48:05 +0000
commiteb46bb84a37bc9384ec3941a97966bec87d2476c (patch)
tree7ed7e5913737ac904090b349342e1569b5480d76
parent98dd0b827ba88221c3a0f2de6f00266bc8da7266 (diff)
downloadwebrtc-eb46bb84a37bc9384ec3941a97966bec87d2476c.tar.gz
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/webrtc@7654 4adac7df-926f-26a2-2b94-8c16560cd09d
-rw-r--r--modules/audio_device/android/opensles_input.cc18
-rw-r--r--modules/audio_device/android/opensles_output.cc18
2 files changed, 36 insertions, 0 deletions
diff --git a/modules/audio_device/android/opensles_input.cc b/modules/audio_device/android/opensles_input.cc
index f22d8bf7..e68a6aa2 100644
--- a/modules/audio_device/android/opensles_input.cc
+++ b/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/modules/audio_device/android/opensles_output.cc b/modules/audio_device/android/opensles_output.cc
index 377789b2..487e2840 100644
--- a/modules/audio_device/android/opensles_output.cc
+++ b/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),