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

Unified Diff: media/audio/mac/audio_auhal_mac.cc

Issue 135853022: Defer OSX output stream Start() around system supend and resume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wait for initialization. Created 6 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
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_auhal_mac_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_auhal_mac.cc
diff --git a/media/audio/mac/audio_auhal_mac.cc b/media/audio/mac/audio_auhal_mac.cc
index 9fcd46a6a95a71fdd63a3680bb76d91f6277c487..abbb4bfcbfa43ed531db05463163be2ac4f97cb4 100644
--- a/media/audio/mac/audio_auhal_mac.cc
+++ b/media/audio/mac/audio_auhal_mac.cc
@@ -7,9 +7,12 @@
#include <CoreServices/CoreServices.h>
#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/mac/mac_logging.h"
+#include "base/time/time.h"
#include "media/audio/mac/audio_manager_mac.h"
#include "media/base/audio_pull_fifo.h"
@@ -148,6 +151,19 @@ void AUHALStream::Start(AudioSourceCallback* callback) {
return;
}
+ // Check if we should defer Start() for http://crbug.com/160920.
+ if (manager_->ShouldDeferOutputStreamStart()) {
+ // Use a cancellable closure so that if Stop() is called before Start()
+ // actually runs, we can cancel the pending start.
+ DCHECK(deferred_start_cb_.IsCancelled());
+ deferred_start_cb_.Reset(
+ base::Bind(&AUHALStream::Start, base::Unretained(this), callback));
+ manager_->GetTaskRunner()->PostDelayedTask(
+ FROM_HERE, deferred_start_cb_.callback(), base::TimeDelta::FromSeconds(
+ AudioManagerMac::kStartDelayInSecsForPowerEvents));
+ return;
+ }
+
stopped_ = false;
audio_fifo_.reset();
{
@@ -165,6 +181,7 @@ void AUHALStream::Start(AudioSourceCallback* callback) {
}
void AUHALStream::Stop() {
+ deferred_start_cb_.Cancel();
if (stopped_)
return;
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_auhal_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698