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

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

Issue 310013002: Fix the race when the WebRtcAudioDeviceImpl goes away before capturers stop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed unittests Created 6 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
Index: content/renderer/media/webrtc_audio_device_impl.cc
diff --git a/content/renderer/media/webrtc_audio_device_impl.cc b/content/renderer/media/webrtc_audio_device_impl.cc
index aca12bdb82ddbd75cd7e6881f2f47149eb8429be..c0bc6dd0daa777d833880dca159eac2e905d038c 100644
--- a/content/renderer/media/webrtc_audio_device_impl.cc
+++ b/content/renderer/media/webrtc_audio_device_impl.cc
@@ -248,7 +248,16 @@ int32_t WebRtcAudioDeviceImpl::Terminate() {
DisableAecDump();
- capturers_.clear();
+ // Stop all the capturers to ensure no further OnData() and
+ // RemoveAudioCapturer() callback.
+ // Cache the capturers in a local list since WebRtcAudioCapturer::Stop()
+ // will trigger RemoveAudioCapturer() callback.
+ CapturerList capturers;
+ capturers.swap(capturers_);
+ for (CapturerList::const_iterator iter = capturers.begin();
+ iter != capturers.end(); ++iter) {
+ (*iter)->Stop();
+ }
initialized_ = false;
return 0;

Powered by Google App Engine
This is Rietveld 408576698