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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/media/webrtc_audio_device_impl.h" 5 #include "content/renderer/media/webrtc_audio_device_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 return 0; 241 return 0;
242 242
243 StopRecording(); 243 StopRecording();
244 StopPlayout(); 244 StopPlayout();
245 245
246 DCHECK(!renderer_.get() || !renderer_->IsStarted()) 246 DCHECK(!renderer_.get() || !renderer_->IsStarted())
247 << "The shared audio renderer shouldn't be running"; 247 << "The shared audio renderer shouldn't be running";
248 248
249 DisableAecDump(); 249 DisableAecDump();
250 250
251 capturers_.clear(); 251 // Stop all the capturers to ensure no further OnData() and
252 // RemoveAudioCapturer() callback.
253 // Cache the capturers in a local list since WebRtcAudioCapturer::Stop()
254 // will trigger RemoveAudioCapturer() callback.
255 CapturerList capturers;
256 capturers.swap(capturers_);
257 for (CapturerList::const_iterator iter = capturers.begin();
258 iter != capturers.end(); ++iter) {
259 (*iter)->Stop();
260 }
252 261
253 initialized_ = false; 262 initialized_ = false;
254 return 0; 263 return 0;
255 } 264 }
256 265
257 bool WebRtcAudioDeviceImpl::Initialized() const { 266 bool WebRtcAudioDeviceImpl::Initialized() const {
258 return initialized_; 267 return initialized_;
259 } 268 }
260 269
261 int32_t WebRtcAudioDeviceImpl::PlayoutIsAvailable(bool* available) { 270 int32_t WebRtcAudioDeviceImpl::PlayoutIsAvailable(bool* available) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 568
560 // Start the Aec dump on the current default capturer. 569 // Start the Aec dump on the current default capturer.
561 scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer()); 570 scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer());
562 if (!default_capturer) 571 if (!default_capturer)
563 return; 572 return;
564 573
565 default_capturer->StartAecDump(aec_dump_file_.Pass()); 574 default_capturer->StartAecDump(aec_dump_file_.Pass());
566 } 575 }
567 576
568 } // namespace content 577 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698