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

Unified Diff: content/renderer/media/webrtc_audio_renderer.cc

Issue 178153007: Avoid hitting the thread check when WebRtcAudioRenderer is going away. (Closed) Base URL: http://git.chromium.org/chromium/src.git@libjingle_get_stats
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_audio_renderer.cc
diff --git a/content/renderer/media/webrtc_audio_renderer.cc b/content/renderer/media/webrtc_audio_renderer.cc
index c341d0fb3c6b0ad379f81fc01a92becec05f930c..c1c04b8e532acecd2f6e532ea39c9b4c8ec38920 100644
--- a/content/renderer/media/webrtc_audio_renderer.cc
+++ b/content/renderer/media/webrtc_audio_renderer.cc
@@ -422,6 +422,13 @@ void WebRtcAudioRenderer::EnterPauseState() {
void WebRtcAudioRenderer::Stop() {
DVLOG(1) << "WebRtcAudioRenderer::Stop()";
DCHECK(thread_checker_.CalledOnValidThread());
+ // Make sure to stop the sink while _not_ holding the lock since the Render()
+ // callback may currently be executing and try to grab the lock while we're
+ // stopping the thread on which it runs.
+ // Stop the sink before calling RemoveAudioRenderer() to make sure that no
+ // more callbacks will be made while the renderer is being removed.
+ sink_->Stop();
+
{
base::AutoLock auto_lock(lock_);
if (state_ == UNINITIALIZED)
@@ -436,11 +443,6 @@ void WebRtcAudioRenderer::Stop() {
source_ = NULL;
state_ = UNINITIALIZED;
}
-
- // Make sure to stop the sink while _not_ holding the lock since the Render()
- // callback may currently be executing and try to grab the lock while we're
- // stopping the thread on which it runs.
- sink_->Stop();
}
void WebRtcAudioRenderer::SetVolume(float volume) {
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698