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

Side by Side Diff: media/audio/mac/audio_manager_mac.cc

Issue 179923006: Attempting to resolve a race condition with PowerMonitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win64 fixes 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
« no previous file with comments | « content/gpu/gpu_watchdog_thread.cc ('k') | net/http/http_network_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_manager_mac.h" 5 #include "media/audio/mac/audio_manager_mac.h"
6 6
7 #include <CoreAudio/AudioHardware.h> 7 #include <CoreAudio/AudioHardware.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // has already been stopped. 219 // has already been stopped.
220 (*it)->Stop(); 220 (*it)->Stop();
221 } 221 }
222 streams->clear(); 222 streams->clear();
223 } 223 }
224 224
225 class AudioManagerMac::AudioPowerObserver : public base::PowerObserver { 225 class AudioManagerMac::AudioPowerObserver : public base::PowerObserver {
226 public: 226 public:
227 AudioPowerObserver() 227 AudioPowerObserver()
228 : is_suspending_(false), 228 : is_suspending_(false),
229 is_monitoring_(base::PowerMonitor::Get()) { 229 is_monitoring_(base::PowerMonitor::IsInitialized()) {
230 // The PowerMonitor requires signifcant setup (a CFRunLoop and preallocated 230 // The PowerMonitor requires signifcant setup (a CFRunLoop and preallocated
231 // IO ports) so it's not available under unit tests. See the OSX impl of 231 // IO ports) so it's not available under unit tests. See the OSX impl of
232 // base::PowerMonitorDeviceSource for more details. 232 // base::PowerMonitorDeviceSource for more details.
233 if (!is_monitoring_) 233 if (!is_monitoring_)
234 return; 234 return;
235 base::PowerMonitor::Get()->AddObserver(this); 235 base::PowerMonitor::AddObserver(this);
236 } 236 }
237 237
238 virtual ~AudioPowerObserver() { 238 virtual ~AudioPowerObserver() {
239 DCHECK(thread_checker_.CalledOnValidThread()); 239 DCHECK(thread_checker_.CalledOnValidThread());
240 if (!is_monitoring_) 240 if (!is_monitoring_)
241 return; 241 return;
242 base::PowerMonitor::Get()->RemoveObserver(this); 242 base::PowerMonitor::RemoveObserver(this);
243 } 243 }
244 244
245 bool ShouldDeferOutputStreamStart() { 245 bool ShouldDeferOutputStreamStart() {
246 DCHECK(thread_checker_.CalledOnValidThread()); 246 DCHECK(thread_checker_.CalledOnValidThread());
247 // Start() should be deferred if the system is in the middle of a suspend or 247 // Start() should be deferred if the system is in the middle of a suspend or
248 // has recently started the process of resuming. 248 // has recently started the process of resuming.
249 return is_suspending_ || base::TimeTicks::Now() < earliest_start_time_; 249 return is_suspending_ || base::TimeTicks::Now() < earliest_start_time_;
250 } 250 }
251 251
252 private: 252 private:
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 void AudioManagerMac::ReleaseInputStream(AudioInputStream* stream) { 776 void AudioManagerMac::ReleaseInputStream(AudioInputStream* stream) {
777 input_streams_.remove(stream); 777 input_streams_.remove(stream);
778 AudioManagerBase::ReleaseInputStream(stream); 778 AudioManagerBase::ReleaseInputStream(stream);
779 } 779 }
780 780
781 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { 781 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
782 return new AudioManagerMac(audio_log_factory); 782 return new AudioManagerMac(audio_log_factory);
783 } 783 }
784 784
785 } // namespace media 785 } // namespace media
OLDNEW
« no previous file with comments | « content/gpu/gpu_watchdog_thread.cc ('k') | net/http/http_network_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698