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

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

Issue 233823003: Defer input stream start around suspend and resume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests. Created 6 years, 8 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_input_mac.h ('k') | media/audio/mac/audio_low_latency_input_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_input_mac.cc
diff --git a/media/audio/mac/audio_input_mac.cc b/media/audio/mac/audio_input_mac.cc
index 8f98eed4c9fc24300ff2e6289c21eccbf82f8c8a..aeeac4315098e25b9caff962624f260eb051828a 100644
--- a/media/audio/mac/audio_input_mac.cc
+++ b/media/audio/mac/audio_input_mac.cc
@@ -9,13 +9,12 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/mac/mac_logging.h"
-#include "media/audio/audio_manager_base.h"
-
+#include "media/audio/mac/audio_manager_mac.h"
namespace media {
PCMQueueInAudioInputStream::PCMQueueInAudioInputStream(
- AudioManagerBase* manager, const AudioParameters& params)
+ AudioManagerMac* manager, const AudioParameters& params)
: manager_(manager),
callback_(NULL),
audio_queue_(NULL),
@@ -65,6 +64,22 @@ void PCMQueueInAudioInputStream::Start(AudioInputCallback* callback) {
DLOG_IF(ERROR, !audio_queue_) << "Open() has not been called successfully";
if (callback_ || !audio_queue_)
return;
+
+ // Check if we should defer Start() for http://crbug.com/160920.
+ if (manager_->ShouldDeferStreamStart()) {
+ // 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(
+ &PCMQueueInAudioInputStream::Start, base::Unretained(this), callback));
+ manager_->GetTaskRunner()->PostDelayedTask(
+ FROM_HERE,
+ deferred_start_cb_.callback(),
+ base::TimeDelta::FromSeconds(
+ AudioManagerMac::kStartDelayInSecsForPowerEvents));
+ return;
+ }
+
callback_ = callback;
OSStatus err = AudioQueueStart(audio_queue_, NULL);
if (err != noErr) {
@@ -75,6 +90,7 @@ void PCMQueueInAudioInputStream::Start(AudioInputCallback* callback) {
}
void PCMQueueInAudioInputStream::Stop() {
+ deferred_start_cb_.Cancel();
if (!audio_queue_ || !started_)
return;
« no previous file with comments | « media/audio/mac/audio_input_mac.h ('k') | media/audio/mac/audio_low_latency_input_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698