Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: media/audio/audio_manager_base.cc

Issue 2929823002: Making AudioManagerBase::ShutdownOnAudioThread() platform-agnostic (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698