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

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

Issue 15979027: start/stop the source of the capturer when 1st audiotrack/last audiotrack is added/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Henrik's comments. Created 7 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 5edd967430883a8b6d8eca7df1a0824a762e0f2e..3d9527da80e5ae926655328dc60d021aa269b34d 100644
--- a/content/renderer/media/webrtc_audio_device_impl.cc
+++ b/content/renderer/media/webrtc_audio_device_impl.cc
@@ -222,13 +222,13 @@ int32_t WebRtcAudioDeviceImpl::Init() {
DCHECK(!capturer_.get());
capturer_ = WebRtcAudioCapturer::CreateCapturer();
+
// Add itself as an audio track to the |capturer_|. This is because WebRTC
// supports only one ADM but multiple audio tracks, so the ADM can't be the
// sink of certain audio track now.
// TODO(xians): Register the ADM as the sink of the audio track if WebRTC
- // supports one ADM for each audio track.
- if (capturer_.get())
- capturer_->AddSink(this);
+ // supports one ADM for each audio track. See http://crbug/247027.
+ capturer_->SetDefaultSink(this);
// We need to return a success to continue the initialization of WebRtc VoE
// because failure on the capturer_ initialization should not prevent WebRTC
@@ -261,7 +261,7 @@ int32_t WebRtcAudioDeviceImpl::Terminate() {
if (capturer_.get()) {
// |capturer_| is stopped by the media stream, so do not need to
// call Stop() here.
- capturer_->RemoveSink(this);
+ capturer_->SetDefaultSink(NULL);
capturer_ = NULL;
}
@@ -343,18 +343,27 @@ int32_t WebRtcAudioDeviceImpl::StartRecording() {
return -1;
}
- start_capture_time_ = base::Time::Now();
+ {
+ base::AutoLock auto_lock(lock_);
+ if (recording_)
+ return 0;
- base::AutoLock auto_lock(lock_);
- recording_ = true;
+ recording_ = true;
+ }
+
+ start_capture_time_ = base::Time::Now();
return 0;
}
int32_t WebRtcAudioDeviceImpl::StopRecording() {
DVLOG(1) << "WebRtcAudioDeviceImpl::StopRecording()";
- if (!recording_) {
- return 0;
+ {
+ base::AutoLock auto_lock(lock_);
+ if (!recording_)
+ return 0;
+
+ recording_ = false;
}
// Add histogram data to be uploaded as part of an UMA logging event.
@@ -364,9 +373,6 @@ int32_t WebRtcAudioDeviceImpl::StopRecording() {
UMA_HISTOGRAM_LONG_TIMES("WebRTC.AudioCaptureTime", capture_time);
}
- base::AutoLock auto_lock(lock_);
- recording_ = false;
-
return 0;
}
« no previous file with comments | « content/renderer/media/webrtc_audio_capturer.cc ('k') | content/renderer/media/webrtc_audio_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698