Chromium Code Reviews| Index: media/audio/audio_manager_base.cc |
| =================================================================== |
| --- media/audio/audio_manager_base.cc (revision 187380) |
| +++ media/audio/audio_manager_base.cc (working copy) |
| @@ -9,6 +9,9 @@ |
| #include "base/command_line.h" |
| #include "base/message_loop_proxy.h" |
| #include "base/threading/thread.h" |
| +#if defined(OS_ANDROID) |
| +#include "jni/AudioManagerAndroid_jni.h" |
| +#endif |
| #include "media/audio/audio_output_dispatcher_impl.h" |
| #include "media/audio/audio_output_proxy.h" |
| #include "media/audio/audio_output_resampler.h" |
| @@ -31,6 +34,11 @@ |
| static const int kMaxInputChannels = 2; |
| +#if defined(OS_ANDROID) |
| +static const int kAudioModeNormal = 0x00000000; |
| +static const int kAudioModeInCommunication = 0x00000003; |
| +#endif |
| + |
| const char AudioManagerBase::kDefaultDeviceName[] = "Default"; |
| const char AudioManagerBase::kDefaultDeviceId[] = "default"; |
| @@ -120,6 +128,11 @@ |
| if (stream) |
| ++num_output_streams_; |
| +#if defined(OS_ANDROID) |
| + if (num_input_streams_) |
|
Ami GONE FROM CHROMIUM
2013/03/20 00:30:27
I don't get it - here you're triggering off num_in
|
| + SetAudioMode(kAudioModeInCommunication); |
| +#endif |
| + |
| return stream; |
| } |
| @@ -243,6 +256,10 @@ |
| // streams. |
| --num_output_streams_; |
| delete stream; |
| +#if defined(OS_ANDROID) |
| + if (!num_output_streams_) |
| + SetAudioMode(kAudioModeNormal); |
| +#endif |
| } |
| void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) { |
| @@ -317,6 +334,13 @@ |
| #endif // defined(OS_IOS) |
| } |
| +#if defined(OS_ANDROID) |
| +// static |
| +bool AudioManagerBase::RegisterAudioManager(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| +#endif |
| + |
| void AudioManagerBase::AddOutputDeviceChangeListener( |
| AudioDeviceListener* listener) { |
| DCHECK(message_loop_->BelongsToCurrentThread()); |
| @@ -345,4 +369,14 @@ |
| return AudioParameters(); |
| } |
| +#if defined(OS_ANDROID) |
| +void AudioManagerBase::SetAudioMode(int mode) { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + jobject context = base::android::GetApplicationContext(); |
| + DCHECK(context); |
| + |
| + Java_AudioManagerAndroid_setMode(env, context, mode); |
| +} |
| +#endif |
| + |
| } // namespace media |