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

Unified Diff: media/audio/android/opensles_output.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
Index: media/audio/android/opensles_output.cc
diff --git a/media/audio/android/opensles_output.cc b/media/audio/android/opensles_output.cc
index 5643f833c3dd98f53eeb578e13e6ff4aaf9c6887..77e6778dbcf618dae106561239b7b9c563fd73f8 100644
--- a/media/audio/android/opensles_output.cc
+++ b/media/audio/android/opensles_output.cc
@@ -28,6 +28,7 @@ OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager,
active_buffer_index_(0),
buffer_size_bytes_(0),
started_(false),
+ muted_(false),
volume_(1.0) {
DVLOG(2) << "OpenSLESOutputStream::OpenSLESOutputStream()";
format_.formatType = SL_DATAFORMAT_PCM;
@@ -172,6 +173,12 @@ void OpenSLESOutputStream::GetVolume(double* volume) {
*volume = static_cast<double>(volume_);
}
+void OpenSLESOutputStream::SetMute(bool muted) {
+ DVLOG(2) << "OpenSLESOutputStream::SetMute(" << muted << ")";
+ DCHECK(thread_checker_.CalledOnValidThread());
+ muted_ = muted;
+}
+
bool OpenSLESOutputStream::CreatePlayer() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!engine_object_.Get());
@@ -324,7 +331,7 @@ void OpenSLESOutputStream::FillBufferQueueNoLock() {
// Note: If the internal representation ever changes from 16-bit PCM to
// raw float, the data must be clipped and sanitized since it may come
// from an untrusted source such as NaCl.
- audio_bus_->Scale(volume_);
+ audio_bus_->Scale(muted_ ? 0.0f : volume_);
audio_bus_->ToInterleaved(frames_filled,
format_.bitsPerSample / 8,
audio_data_[active_buffer_index_]);
« no previous file with comments | « media/audio/android/opensles_output.h ('k') | media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698