summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-30 16:40:55 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-30 16:40:55 +0000
commit77476ed3ffb102c47b4458584f5adaa79f373ee9 (patch)
tree958d2441a4126194cc9f6b4313e2b1f1f586ae4b /content/renderer
parent0a20df0edbbc7b8c4914a4db8e76affe0a05164d (diff)
downloadchromium_src-77476ed3ffb102c47b4458584f5adaa79f373ee9.zip
chromium_src-77476ed3ffb102c47b4458584f5adaa79f373ee9.tar.gz
chromium_src-77476ed3ffb102c47b4458584f5adaa79f373ee9.tar.bz2
Stop feeding render data to AEC after audio processor has stopped.
BUG=389140 TEST= Review URL: https://codereview.chromium.org/360703002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/media/media_stream_audio_processor.cc44
-rw-r--r--content/renderer/media/media_stream_audio_processor.h12
-rw-r--r--content/renderer/media/webrtc_audio_capturer.cc3
3 files changed, 37 insertions, 22 deletions
diff --git a/content/renderer/media/media_stream_audio_processor.cc b/content/renderer/media/media_stream_audio_processor.cc
index 12e8d34..d2e0695 100644
--- a/content/renderer/media/media_stream_audio_processor.cc
+++ b/content/renderer/media/media_stream_audio_processor.cc
@@ -173,7 +173,8 @@ MediaStreamAudioProcessor::MediaStreamAudioProcessor(
: render_delay_ms_(0),
playout_data_source_(playout_data_source),
audio_mirroring_(false),
- typing_detected_(false) {
+ typing_detected_(false),
+ stopped_(false) {
capture_thread_checker_.DetachFromThread();
render_thread_checker_.DetachFromThread();
InitializeAudioProcessingModule(constraints, effects);
@@ -189,11 +190,7 @@ MediaStreamAudioProcessor::MediaStreamAudioProcessor(
MediaStreamAudioProcessor::~MediaStreamAudioProcessor() {
DCHECK(main_thread_checker_.CalledOnValidThread());
- if (aec_dump_message_filter_) {
- aec_dump_message_filter_->RemoveDelegate(this);
- aec_dump_message_filter_ = NULL;
- }
- StopAudioProcessing();
+ Stop();
}
void MediaStreamAudioProcessor::OnCaptureFormatChanged(
@@ -242,6 +239,29 @@ bool MediaStreamAudioProcessor::ProcessAndConsumeData(
return true;
}
+void MediaStreamAudioProcessor::Stop() {
+ DCHECK(main_thread_checker_.CalledOnValidThread());
+ if (stopped_)
+ return;
+
+ stopped_ = true;
+
+ if (aec_dump_message_filter_) {
+ aec_dump_message_filter_->RemoveDelegate(this);
+ aec_dump_message_filter_ = NULL;
+ }
+
+ if (!audio_processing_.get())
+ return;
+
+ StopEchoCancellationDump(audio_processing_.get());
+
+ if (playout_data_source_) {
+ playout_data_source_->RemovePlayoutSink(this);
+ playout_data_source_ = NULL;
+ }
+}
+
const media::AudioParameters& MediaStreamAudioProcessor::InputFormat() const {
return capture_converter_->source_parameters();
}
@@ -516,16 +536,4 @@ int MediaStreamAudioProcessor::ProcessData(webrtc::AudioFrame* audio_frame,
0 : agc->stream_analog_level();
}
-void MediaStreamAudioProcessor::StopAudioProcessing() {
- if (!audio_processing_.get())
- return;
-
- StopEchoCancellationDump(audio_processing_.get());
-
- if (playout_data_source_)
- playout_data_source_->RemovePlayoutSink(this);
-
- audio_processing_.reset();
-}
-
} // namespace content
diff --git a/content/renderer/media/media_stream_audio_processor.h b/content/renderer/media/media_stream_audio_processor.h
index 7232ae6..08f8ed0 100644
--- a/content/renderer/media/media_stream_audio_processor.h
+++ b/content/renderer/media/media_stream_audio_processor.h
@@ -89,6 +89,10 @@ class CONTENT_EXPORT MediaStreamAudioProcessor :
int* new_volume,
int16** out);
+ // Stops the audio processor, no more AEC dump or render data after calling
+ // this method.
+ void Stop();
+
// The audio format of the input to the processor.
const media::AudioParameters& InputFormat() const;
@@ -146,9 +150,6 @@ class CONTENT_EXPORT MediaStreamAudioProcessor :
int volume,
bool key_pressed);
- // Called when the processor is going away.
- void StopAudioProcessing();
-
// Cached value for the render delay latency. This member is accessed by
// both the capture audio thread and the render audio thread.
base::subtle::Atomic32 render_delay_ms_;
@@ -175,7 +176,7 @@ class CONTENT_EXPORT MediaStreamAudioProcessor :
// Raw pointer to the WebRtcPlayoutDataSource, which is valid for the
// lifetime of RenderThread.
- WebRtcPlayoutDataSource* const playout_data_source_;
+ WebRtcPlayoutDataSource* playout_data_source_;
// Used to DCHECK that the destructor is called on the main render thread.
base::ThreadChecker main_thread_checker_;
@@ -199,6 +200,9 @@ class CONTENT_EXPORT MediaStreamAudioProcessor :
// Communication with browser for AEC dump.
scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_;
+
+ // Flag to avoid executing Stop() more than once.
+ bool stopped_;
};
} // namespace content
diff --git a/content/renderer/media/webrtc_audio_capturer.cc b/content/renderer/media/webrtc_audio_capturer.cc
index 6212a8e..056cb2b 100644
--- a/content/renderer/media/webrtc_audio_capturer.cc
+++ b/content/renderer/media/webrtc_audio_capturer.cc
@@ -425,6 +425,9 @@ void WebRtcAudioCapturer::Stop() {
if (source.get())
source->Stop();
+
+ // Stop the audio processor to avoid feeding render data into the processor.
+ audio_processor_->Stop();
}
void WebRtcAudioCapturer::SetVolume(int volume) {