| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 AudioManagerMac::~AudioManagerMac() { | 381 AudioManagerMac::~AudioManagerMac() { |
| 382 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 382 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 383 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() | 383 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() |
| 384 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio | 384 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio |
| 385 // APIs and they can fail and disrupt tests during shutdown. | 385 // APIs and they can fail and disrupt tests during shutdown. |
| 386 in_shutdown_ = true; | 386 in_shutdown_ = true; |
| 387 // We have seen cases where active input audio is not closed down properly | 387 // We have seen cases where active input audio is not closed down properly |
| 388 // at browser shutdown. AudioInputController::Close() is called but tasks | 388 // at browser shutdown. AudioInputController::Close() is called but tasks |
| 389 // in AudioInputController::DoClose() are not executed. Hence, input streams | 389 // in AudioInputController::DoClose() are not executed. Hence, input streams |
| 390 // might remain even at this late state. | 390 // might remain even at this late state. |low_latency_input_streams_| will be |
| 391 // modified during the call to stream->Close(), so we can't iterate over it |
| 392 // here. Instead iterate over a copy. |
| 391 // TODO(henrika): figure out the real cause why streams are not closed | 393 // TODO(henrika): figure out the real cause why streams are not closed |
| 392 // properly by the AIC for all cases and then remove this loop. | 394 // properly by the AIC for all cases and then remove this loop. |
| 393 for (auto* stream : low_latency_input_streams_) { | 395 auto low_latency_input_streams_copy = low_latency_input_streams_; |
| 396 for (auto* stream : low_latency_input_streams_copy) { |
| 394 LOG(WARNING) << "Closing existing audio input stream at destruction"; | 397 LOG(WARNING) << "Closing existing audio input stream at destruction"; |
| 395 // Prevents active Core Audio callbacks to use possibly invalid objects | 398 // Prevents active Core Audio callbacks to use possibly invalid objects |
| 396 // in its OnData() callback. | 399 // in its OnData() callback. |
| 397 stream->Stop(); | 400 stream->Stop(); |
| 398 // Avoids hitting CHECK in dtor of AudioManagerBase. | 401 // Avoids hitting CHECK in dtor of AudioManagerBase. |
| 399 stream->Close(); | 402 stream->Close(); |
| 400 } | 403 } |
| 401 Shutdown(); | 404 Shutdown(); |
| 402 } | 405 } |
| 403 | 406 |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 ScopedAudioManagerPtr CreateAudioManager( | 1097 ScopedAudioManagerPtr CreateAudioManager( |
| 1095 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 1098 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 1096 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 1099 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
| 1097 AudioLogFactory* audio_log_factory) { | 1100 AudioLogFactory* audio_log_factory) { |
| 1098 return ScopedAudioManagerPtr( | 1101 return ScopedAudioManagerPtr( |
| 1099 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), | 1102 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), |
| 1100 audio_log_factory)); | 1103 audio_log_factory)); |
| 1101 } | 1104 } |
| 1102 | 1105 |
| 1103 } // namespace media | 1106 } // namespace media |
| OLD | NEW |