Chromium Code Reviews| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 base::Unretained(this))); | 522 base::Unretained(this))); |
| 523 } | 523 } |
| 524 | 524 |
| 525 AudioManagerMac::~AudioManagerMac() = default; | 525 AudioManagerMac::~AudioManagerMac() = default; |
| 526 | 526 |
| 527 void AudioManagerMac::ShutdownOnAudioThread() { | 527 void AudioManagerMac::ShutdownOnAudioThread() { |
| 528 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() | 528 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() |
| 529 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio | 529 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio |
| 530 // APIs and they can fail and disrupt tests during shutdown. | 530 // APIs and they can fail and disrupt tests during shutdown. |
| 531 in_shutdown_ = true; | 531 in_shutdown_ = true; |
| 532 AudioManagerBase::ShutdownOnAudioThread(); | 532 AudioManagerBase::ShutdownOnAudioThread(); |
|
alokp
2017/07/14 18:58:53
nit: May be release base class resources *after* l
| |
| 533 | |
| 534 // Even if tasks to close the streams are enqueued, they would not run | |
| 535 // leading to CHECKs getting hit in the destructor about open streams. Close | |
| 536 // them explicitly here. crbug.com/608049. | |
| 537 for (auto iter = basic_input_streams_.begin(); | |
| 538 iter != basic_input_streams_.end();) { | |
| 539 // Note: Closing the stream will invalidate the iterator. | |
| 540 // Increment the iterator before closing the stream. | |
| 541 AudioInputStream* stream = *iter++; | |
| 542 stream->Close(); | |
| 543 } | |
| 544 for (auto iter = low_latency_input_streams_.begin(); | |
| 545 iter != low_latency_input_streams_.end();) { | |
| 546 // Note: Closing the stream will invalidate the iterator. | |
| 547 // Increment the iterator before closing the stream. | |
| 548 AudioInputStream* stream = *iter++; | |
| 549 stream->Close(); | |
| 550 } | |
| 551 CHECK(basic_input_streams_.empty()); | |
| 552 CHECK(low_latency_input_streams_.empty()); | |
| 533 } | 553 } |
| 534 | 554 |
| 535 bool AudioManagerMac::HasAudioOutputDevices() { | 555 bool AudioManagerMac::HasAudioOutputDevices() { |
| 536 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); | 556 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); |
| 537 } | 557 } |
| 538 | 558 |
| 539 bool AudioManagerMac::HasAudioInputDevices() { | 559 bool AudioManagerMac::HasAudioInputDevices() { |
| 540 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice); | 560 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice); |
| 541 } | 561 } |
| 542 | 562 |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1178 } | 1198 } |
| 1179 | 1199 |
| 1180 std::unique_ptr<AudioManager> CreateAudioManager( | 1200 std::unique_ptr<AudioManager> CreateAudioManager( |
| 1181 std::unique_ptr<AudioThread> audio_thread, | 1201 std::unique_ptr<AudioThread> audio_thread, |
| 1182 AudioLogFactory* audio_log_factory) { | 1202 AudioLogFactory* audio_log_factory) { |
| 1183 return base::MakeUnique<AudioManagerMac>(std::move(audio_thread), | 1203 return base::MakeUnique<AudioManagerMac>(std::move(audio_thread), |
| 1184 audio_log_factory); | 1204 audio_log_factory); |
| 1185 } | 1205 } |
| 1186 | 1206 |
| 1187 } // namespace media | 1207 } // namespace media |
| OLD | NEW |