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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 SetMaxOutputStreamsAllowed(kMaxOutputStreams); | 411 SetMaxOutputStreamsAllowed(kMaxOutputStreams); |
412 | 412 |
413 // Task must be posted last to avoid races from handing out "this" to the | 413 // Task must be posted last to avoid races from handing out "this" to the |
414 // audio thread. Always PostTask even if we're on the right thread since | 414 // audio thread. Always PostTask even if we're on the right thread since |
415 // AudioManager creation is on the startup path and this may be slow. | 415 // AudioManager creation is on the startup path and this may be slow. |
416 GetTaskRunner()->PostTask( | 416 GetTaskRunner()->PostTask( |
417 FROM_HERE, base::Bind(&AudioManagerMac::InitializeOnAudioThread, | 417 FROM_HERE, base::Bind(&AudioManagerMac::InitializeOnAudioThread, |
418 base::Unretained(this))); | 418 base::Unretained(this))); |
419 } | 419 } |
420 | 420 |
421 AudioManagerMac::~AudioManagerMac() { | 421 AudioManagerMac::~AudioManagerMac() = default; |
422 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 422 |
| 423 void AudioManagerMac::Shutdown() { |
423 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() | 424 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() |
424 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio | 425 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio |
425 // APIs and they can fail and disrupt tests during shutdown. | 426 // APIs and they can fail and disrupt tests during shutdown. |
426 in_shutdown_ = true; | 427 in_shutdown_ = true; |
427 Shutdown(); | 428 AudioManagerBase::Shutdown(); |
428 } | 429 } |
429 | 430 |
430 bool AudioManagerMac::HasAudioOutputDevices() { | 431 bool AudioManagerMac::HasAudioOutputDevices() { |
431 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); | 432 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); |
432 } | 433 } |
433 | 434 |
434 bool AudioManagerMac::HasAudioInputDevices() { | 435 bool AudioManagerMac::HasAudioInputDevices() { |
435 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice); | 436 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice); |
436 } | 437 } |
437 | 438 |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 basic_input_streams_.end(), | 1159 basic_input_streams_.end(), |
1159 stream); | 1160 stream); |
1160 if (stream_it == basic_input_streams_.end()) | 1161 if (stream_it == basic_input_streams_.end()) |
1161 low_latency_input_streams_.remove(static_cast<AUAudioInputStream*>(stream)); | 1162 low_latency_input_streams_.remove(static_cast<AUAudioInputStream*>(stream)); |
1162 else | 1163 else |
1163 basic_input_streams_.erase(stream_it); | 1164 basic_input_streams_.erase(stream_it); |
1164 | 1165 |
1165 AudioManagerBase::ReleaseInputStream(stream); | 1166 AudioManagerBase::ReleaseInputStream(stream); |
1166 } | 1167 } |
1167 | 1168 |
1168 ScopedAudioManagerPtr CreateAudioManager( | 1169 std::unique_ptr<AudioManager> CreateAudioManager( |
1169 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 1170 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
1170 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 1171 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
1171 AudioLogFactory* audio_log_factory) { | 1172 AudioLogFactory* audio_log_factory) { |
1172 return ScopedAudioManagerPtr( | 1173 return base::MakeUnique<AudioManagerMac>( |
1173 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), | 1174 std::move(task_runner), std::move(worker_task_runner), audio_log_factory); |
1174 audio_log_factory)); | |
1175 } | 1175 } |
1176 | 1176 |
1177 } // namespace media | 1177 } // namespace media |
OLD | NEW |