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

Side by Side Diff: media/audio/audio_manager_base.cc

Issue 9104043: Monitor the IO message loop in the AudioDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indent Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/scoped_loop_observer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "media/audio/audio_output_dispatcher.h" 10 #include "media/audio/audio_output_dispatcher.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void AudioManagerBase::Shutdown() { 100 void AudioManagerBase::Shutdown() {
101 // To avoid running into deadlocks while we stop the thread, shut it down 101 // To avoid running into deadlocks while we stop the thread, shut it down
102 // via a local variable while not holding the audio thread lock. 102 // via a local variable while not holding the audio thread lock.
103 scoped_ptr<base::Thread> audio_thread; 103 scoped_ptr<base::Thread> audio_thread;
104 { 104 {
105 base::AutoLock lock(audio_thread_lock_); 105 base::AutoLock lock(audio_thread_lock_);
106 audio_thread_.swap(audio_thread); 106 audio_thread_.swap(audio_thread);
107 } 107 }
108 108
109 if (!audio_thread.get()) 109 if (!audio_thread.get())
110 return; 110 return;
111 111
112 CHECK_NE(MessageLoop::current(), audio_thread->message_loop()); 112 CHECK_NE(MessageLoop::current(), audio_thread->message_loop());
113 113
114 // We must use base::Unretained since Shutdown might have been called from 114 // We must use base::Unretained since Shutdown might have been called from
115 // the destructor and we can't alter the refcount of the object at that point. 115 // the destructor and we can't alter the refcount of the object at that point.
116 audio_thread->message_loop()->PostTask(FROM_HERE, base::Bind( 116 audio_thread->message_loop()->PostTask(FROM_HERE, base::Bind(
117 &AudioManagerBase::ShutdownOnAudioThread, 117 &AudioManagerBase::ShutdownOnAudioThread,
118 base::Unretained(this))); 118 base::Unretained(this)));
119 119
120 // Stop() will wait for any posted messages to be processed first. 120 // Stop() will wait for any posted messages to be processed first.
(...skipping 15 matching lines...) Expand all
136 // both physical audio stream objects that belong to the dispatcher as 136 // both physical audio stream objects that belong to the dispatcher as
137 // well as the message loop of the audio thread that will soon go away. 137 // well as the message loop of the audio thread that will soon go away.
138 // So, better crash now than later. 138 // So, better crash now than later.
139 CHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; 139 CHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive";
140 dispatcher = NULL; 140 dispatcher = NULL;
141 } 141 }
142 } 142 }
143 143
144 output_dispatchers_.clear(); 144 output_dispatchers_.clear();
145 } 145 }
OLDNEW
« no previous file with comments | « content/renderer/media/scoped_loop_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698