| OLD | NEW |
| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 base::PowerMonitor::Get()->AddObserver(this); | 235 base::PowerMonitor::Get()->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::Get()->RemoveObserver(this); |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool ShouldDeferOutputStreamStart() { | 245 bool ShouldDeferStreamStart() { |
| 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: |
| 253 virtual void OnSuspend() OVERRIDE { | 253 virtual void OnSuspend() OVERRIDE { |
| 254 DCHECK(thread_checker_.CalledOnValidThread()); | 254 DCHECK(thread_checker_.CalledOnValidThread()); |
| 255 is_suspending_ = true; | 255 is_suspending_ = true; |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // to glitching. Adjust upwards by multiples of the default size. | 756 // to glitching. Adjust upwards by multiples of the default size. |
| 757 if (output_sample_rate <= 96000) | 757 if (output_sample_rate <= 96000) |
| 758 buffer_size = 2 * kDefaultLowLatencyBufferSize; | 758 buffer_size = 2 * kDefaultLowLatencyBufferSize; |
| 759 else if (output_sample_rate <= 192000) | 759 else if (output_sample_rate <= 192000) |
| 760 buffer_size = 4 * kDefaultLowLatencyBufferSize; | 760 buffer_size = 4 * kDefaultLowLatencyBufferSize; |
| 761 } | 761 } |
| 762 | 762 |
| 763 return buffer_size; | 763 return buffer_size; |
| 764 } | 764 } |
| 765 | 765 |
| 766 bool AudioManagerMac::ShouldDeferOutputStreamStart() { | 766 bool AudioManagerMac::ShouldDeferStreamStart() { |
| 767 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 767 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 768 return power_observer_->ShouldDeferOutputStreamStart(); | 768 return power_observer_->ShouldDeferStreamStart(); |
| 769 } | 769 } |
| 770 | 770 |
| 771 void AudioManagerMac::ReleaseOutputStream(AudioOutputStream* stream) { | 771 void AudioManagerMac::ReleaseOutputStream(AudioOutputStream* stream) { |
| 772 output_streams_.remove(stream); | 772 output_streams_.remove(stream); |
| 773 AudioManagerBase::ReleaseOutputStream(stream); | 773 AudioManagerBase::ReleaseOutputStream(stream); |
| 774 } | 774 } |
| 775 | 775 |
| 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 |
| OLD | NEW |