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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 502 |
503 bool is_suspending_; | 503 bool is_suspending_; |
504 const bool is_monitoring_; | 504 const bool is_monitoring_; |
505 base::TimeTicks earliest_start_time_; | 505 base::TimeTicks earliest_start_time_; |
506 base::ThreadChecker thread_checker_; | 506 base::ThreadChecker thread_checker_; |
507 size_t num_resume_notifications_; | 507 size_t num_resume_notifications_; |
508 | 508 |
509 DISALLOW_COPY_AND_ASSIGN(AudioPowerObserver); | 509 DISALLOW_COPY_AND_ASSIGN(AudioPowerObserver); |
510 }; | 510 }; |
511 | 511 |
512 AudioManagerMac::AudioManagerMac( | 512 AudioManagerMac::AudioManagerMac(std::unique_ptr<AudioThread> audio_thread, |
513 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 513 AudioLogFactory* audio_log_factory) |
514 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 514 : AudioManagerBase(std::move(audio_thread), audio_log_factory), |
515 AudioLogFactory* audio_log_factory) | |
516 : AudioManagerBase(std::move(task_runner), | |
517 std::move(worker_task_runner), | |
518 audio_log_factory), | |
519 current_sample_rate_(0), | 515 current_sample_rate_(0), |
520 current_output_device_(kAudioDeviceUnknown), | 516 current_output_device_(kAudioDeviceUnknown), |
521 in_shutdown_(false) { | 517 in_shutdown_(false) { |
522 SetMaxOutputStreamsAllowed(kMaxOutputStreams); | 518 SetMaxOutputStreamsAllowed(kMaxOutputStreams); |
523 | 519 |
524 // Task must be posted last to avoid races from handing out "this" to the | 520 // Task must be posted last to avoid races from handing out "this" to the |
525 // audio thread. Always PostTask even if we're on the right thread since | 521 // audio thread. Always PostTask even if we're on the right thread since |
526 // AudioManager creation is on the startup path and this may be slow. | 522 // AudioManager creation is on the startup path and this may be slow. |
527 GetTaskRunner()->PostTask( | 523 GetTaskRunner()->PostTask( |
528 FROM_HERE, base::Bind(&AudioManagerMac::InitializeOnAudioThread, | 524 FROM_HERE, base::Bind(&AudioManagerMac::InitializeOnAudioThread, |
529 base::Unretained(this))); | 525 base::Unretained(this))); |
530 } | 526 } |
531 | 527 |
532 AudioManagerMac::~AudioManagerMac() { | 528 AudioManagerMac::~AudioManagerMac() = default; |
533 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 529 |
| 530 void AudioManagerMac::ShutdownOnAudioThread() { |
534 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() | 531 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() |
535 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio | 532 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio |
536 // APIs and they can fail and disrupt tests during shutdown. | 533 // APIs and they can fail and disrupt tests during shutdown. |
537 in_shutdown_ = true; | 534 in_shutdown_ = true; |
538 Shutdown(); | 535 AudioManagerBase::ShutdownOnAudioThread(); |
539 } | 536 } |
540 | 537 |
541 bool AudioManagerMac::HasAudioOutputDevices() { | 538 bool AudioManagerMac::HasAudioOutputDevices() { |
542 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); | 539 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); |
543 } | 540 } |
544 | 541 |
545 bool AudioManagerMac::HasAudioInputDevices() { | 542 bool AudioManagerMac::HasAudioInputDevices() { |
546 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice); | 543 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice); |
547 } | 544 } |
548 | 545 |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 basic_input_streams_.end(), | 1175 basic_input_streams_.end(), |
1179 stream); | 1176 stream); |
1180 if (stream_it == basic_input_streams_.end()) | 1177 if (stream_it == basic_input_streams_.end()) |
1181 low_latency_input_streams_.remove(static_cast<AUAudioInputStream*>(stream)); | 1178 low_latency_input_streams_.remove(static_cast<AUAudioInputStream*>(stream)); |
1182 else | 1179 else |
1183 basic_input_streams_.erase(stream_it); | 1180 basic_input_streams_.erase(stream_it); |
1184 | 1181 |
1185 AudioManagerBase::ReleaseInputStream(stream); | 1182 AudioManagerBase::ReleaseInputStream(stream); |
1186 } | 1183 } |
1187 | 1184 |
1188 ScopedAudioManagerPtr CreateAudioManager( | 1185 std::unique_ptr<AudioManager> CreateAudioManager( |
1189 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 1186 std::unique_ptr<AudioThread> audio_thread, |
1190 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | |
1191 AudioLogFactory* audio_log_factory) { | 1187 AudioLogFactory* audio_log_factory) { |
1192 return ScopedAudioManagerPtr( | 1188 return base::MakeUnique<AudioManagerMac>(std::move(audio_thread), |
1193 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), | 1189 audio_log_factory); |
1194 audio_log_factory)); | |
1195 } | 1190 } |
1196 | 1191 |
1197 } // namespace media | 1192 } // namespace media |
OLD | NEW |