Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: media/audio/android/audio_manager_android.cc

Issue 93233003: Mute audio when volume is zero on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: henrika@'s comment Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/android/audio_manager_android.h ('k') | media/audio/android/opensles_output.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(),
« no previous file with comments | « media/audio/android/audio_manager_android.h ('k') | media/audio/android/opensles_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698