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

Side by Side Diff: media/audio/mac/audio_low_latency_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/mac/audio_low_latency_input_mac.h" 5 #include "media/audio/mac/audio_low_latency_input_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 number_of_channels_in_frame_ = GetNumberOfChannelsFromStream(); 267 number_of_channels_in_frame_ = GetNumberOfChannelsFromStream();
268 268
269 return true; 269 return true;
270 } 270 }
271 271
272 void AUAudioInputStream::Start(AudioInputCallback* callback) { 272 void AUAudioInputStream::Start(AudioInputCallback* callback) {
273 DCHECK(callback); 273 DCHECK(callback);
274 DLOG_IF(ERROR, !audio_unit_) << "Open() has not been called successfully"; 274 DLOG_IF(ERROR, !audio_unit_) << "Open() has not been called successfully";
275 if (started_ || !audio_unit_) 275 if (started_ || !audio_unit_)
276 return; 276 return;
277
278 // Check if we should defer Start() for http://crbug.com/160920.
279 if (manager_->ShouldDeferStreamStart()) {
280 // Use a cancellable closure so that if Stop() is called before Start()
281 // actually runs, we can cancel the pending start.
282 DCHECK(deferred_start_cb_.IsCancelled());
283 deferred_start_cb_.Reset(base::Bind(
284 &AUAudioInputStream::Start, base::Unretained(this), callback));
285 manager_->GetTaskRunner()->PostDelayedTask(
286 FROM_HERE,
287 deferred_start_cb_.callback(),
288 base::TimeDelta::FromSeconds(
289 AudioManagerMac::kStartDelayInSecsForPowerEvents));
290 return;
291 }
292
277 sink_ = callback; 293 sink_ = callback;
278 StartAgc(); 294 StartAgc();
279 OSStatus result = AudioOutputUnitStart(audio_unit_); 295 OSStatus result = AudioOutputUnitStart(audio_unit_);
280 if (result == noErr) { 296 if (result == noErr) {
281 started_ = true; 297 started_ = true;
282 } 298 }
283 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 299 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
284 << "Failed to start acquiring data"; 300 << "Failed to start acquiring data";
285 } 301 }
286 302
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 kAudioDevicePropertyScopeInput, 671 kAudioDevicePropertyScopeInput,
656 static_cast<UInt32>(channel) 672 static_cast<UInt32>(channel)
657 }; 673 };
658 OSStatus result = AudioObjectIsPropertySettable(input_device_id_, 674 OSStatus result = AudioObjectIsPropertySettable(input_device_id_,
659 &property_address, 675 &property_address,
660 &is_settable); 676 &is_settable);
661 return (result == noErr) ? is_settable : false; 677 return (result == noErr) ? is_settable : false;
662 } 678 }
663 679
664 } // namespace media 680 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.h ('k') | media/audio/mac/audio_low_latency_input_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698