Index: media/audio/android/audio_manager_android.cc |
diff --git a/media/audio/android/audio_manager_android.cc b/media/audio/android/audio_manager_android.cc |
index 34665103b2856c9ac7917a86f136c9c221189693..868a58044344036d51fabd7ba4923d601a3c41a0 100644 |
--- a/media/audio/android/audio_manager_android.cc |
+++ b/media/audio/android/audio_manager_android.cc |
@@ -52,7 +52,8 @@ AudioManagerAndroid::AudioManagerAndroid() { |
j_audio_manager_.Reset( |
Java_AudioManagerAndroid_createAudioManagerAndroid( |
base::android::AttachCurrentThread(), |
- base::android::GetApplicationContext())); |
+ base::android::GetApplicationContext(), |
+ reinterpret_cast<intptr_t>(this))); |
Init(); |
} |
@@ -125,6 +126,12 @@ AudioOutputStream* AudioManagerAndroid::MakeAudioOutputStream( |
if (stream && output_stream_count() == 1) { |
SetAudioMode(kAudioModeInCommunication); |
} |
+ |
+ { |
+ base::AutoLock lock(streams_lock_); |
+ streams_.insert(static_cast<OpenSLESOutputStream*>(stream)); |
+ } |
+ |
return stream; |
} |
@@ -140,6 +147,8 @@ void AudioManagerAndroid::ReleaseOutputStream(AudioOutputStream* stream) { |
if (!output_stream_count()) { |
SetAudioMode(kAudioModeNormal); |
} |
+ base::AutoLock lock(streams_lock_); |
+ streams_.erase(static_cast<OpenSLESOutputStream*>(stream)); |
} |
void AudioManagerAndroid::ReleaseInputStream(AudioInputStream* stream) { |
@@ -237,6 +246,23 @@ void AudioManagerAndroid::Close() { |
j_audio_manager_.obj()); |
} |
+void AudioManagerAndroid::SetMute(JNIEnv* env, jobject obj, jboolean muted) { |
+ GetMessageLoop()->PostTask( |
+ FROM_HERE, |
+ base::Bind( |
+ &AudioManagerAndroid::DoSetMuteOnAudioThread, |
+ base::Unretained(this), |
+ muted)); |
+} |
+ |
+void AudioManagerAndroid::DoSetMuteOnAudioThread(bool muted) { |
+ base::AutoLock lock(streams_lock_); |
+ for (OutputStreams::iterator it = streams_.begin(); |
+ it != streams_.end(); ++it) { |
+ (*it)->SetMute(muted); |
+ } |
+} |
+ |
void AudioManagerAndroid::SetAudioMode(int mode) { |
Java_AudioManagerAndroid_setMode( |
base::android::AttachCurrentThread(), |