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

Unified Diff: ppapi/shared_impl/ppb_audio_shared.cc

Issue 879403002: Plugin Power Saver: Mute throttled plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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: ppapi/shared_impl/ppb_audio_shared.cc
diff --git a/ppapi/shared_impl/ppb_audio_shared.cc b/ppapi/shared_impl/ppb_audio_shared.cc
index 99af9d7e7e20bfece9fd2f2870c13a1d2d2f13d9..05985e9d2ba4f889287b031af225f90a16913db1 100644
--- a/ppapi/shared_impl/ppb_audio_shared.cc
+++ b/ppapi/shared_impl/ppb_audio_shared.cc
@@ -50,7 +50,9 @@ void AudioCallbackCombined::Run(void* sample_buffer,
PPB_Audio_Shared::PPB_Audio_Shared()
: playing_(false),
+ muted_for_power_saver_(false),
shared_memory_size_(0),
+ nacl_thread_id_(0),
nacl_thread_active_(false),
user_data_(NULL),
client_buffer_size_bytes_(0),
@@ -197,6 +199,16 @@ void PPB_Audio_Shared::SetThreadFunctions(
g_thread_functions = *functions;
}
+void PPB_Audio_Shared::SetMutedForPowerSaver(bool muted_for_power_saver) {
+ base::AutoLock lock(mute_lock_);
+ muted_for_power_saver_ = muted_for_power_saver;
+}
+
+bool PPB_Audio_Shared::IsMutedForPowerSaver() {
+ base::AutoLock lock(mute_lock_);
+ return muted_for_power_saver_;
+}
+
// static
void PPB_Audio_Shared::CallRun(void* self) {
PPB_Audio_Shared* audio = static_cast<PPB_Audio_Shared*>(self);
@@ -221,6 +233,10 @@ void PPB_Audio_Shared::Run() {
client_buffer_.get(), client_buffer_size_bytes_, latency, user_data_);
}
+ if (IsMutedForPowerSaver()) {
tommycli 2015/01/28 20:41:24 This doesn't actually work! As far as I can tell,
+ memset(client_buffer_.get(), 0, client_buffer_size_bytes_);
+ }
+
// Deinterleave the audio data into the shared memory as floats.
audio_bus_->FromInterleaved(client_buffer_.get(),
audio_bus_->frames(),
« ppapi/shared_impl/ppb_audio_shared.h ('K') | « ppapi/shared_impl/ppb_audio_shared.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698