Chromium Code Reviews| Index: media/audio/audio_manager_base.cc |
| diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc |
| index 92a255d095cfb22ed58b36b766c22aa8084b2d58..8356d5b85d8b944cb479ecc4be1ac6d66db9f409 100644 |
| --- a/media/audio/audio_manager_base.cc |
| +++ b/media/audio/audio_manager_base.cc |
| @@ -343,26 +343,24 @@ void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) { |
| delete stream; |
| } |
| -void AudioManagerBase::ShutdownOnAudioThread() { |
| +void AudioManagerBase::ShutdownOnAudioThread(bool immediately) { |
| DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| // Close all output streams. |
| output_dispatchers_.clear(); |
| -#if defined(OS_MACOSX) |
| - // On mac, AudioManager runs on the main thread, loop for which stops |
| - // processing task queue at this point. So even if tasks to close the |
| - // streams are enqueued, they would not run leading to CHECKs getting hit |
| - // in the destructor about open streams. Close them explicitly here. |
| - // crbug.com/608049. |
| - for (auto iter = input_streams_.begin(); iter != input_streams_.end();) { |
| - // Note: Closing the stream will invalidate the iterator. |
| - // Increment the iterator before closing the stream. |
| - AudioInputStream* stream = *iter++; |
| - stream->Close(); |
| + if (immediately) { |
| + // Even if tasks to close the streams are enqueued, they would not run |
|
alokp
2017/06/09 16:59:17
nit: Would it be better to run this block of code
o1ka
2017/06/09 17:15:48
Hmm.. Won't open streams be a problem on other pla
|
| + // leading to CHECKs getting hit in the destructor about open streams. Close |
| + // them explicitly here. crbug.com/608049. |
| + for (auto iter = input_streams_.begin(); iter != input_streams_.end();) { |
| + // Note: Closing the stream will invalidate the iterator. |
| + // Increment the iterator before closing the stream. |
| + AudioInputStream* stream = *iter++; |
| + stream->Close(); |
| + } |
| + CHECK(input_streams_.empty()); |
| } |
| - CHECK(input_streams_.empty()); |
| -#endif // OS_MACOSX |
| } |
| void AudioManagerBase::AddOutputDeviceChangeListener( |