OLD | NEW |
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/media_stream_audio_processor.h" | 5 #include "content/renderer/media/media_stream_audio_processor.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 base::subtle::Release_Store(&render_delay_ms_, audio_delay_milliseconds); | 240 base::subtle::Release_Store(&render_delay_ms_, audio_delay_milliseconds); |
241 | 241 |
242 InitializeRenderConverterIfNeeded(sample_rate, audio_bus->channels(), | 242 InitializeRenderConverterIfNeeded(sample_rate, audio_bus->channels(), |
243 audio_bus->frames()); | 243 audio_bus->frames()); |
244 | 244 |
245 render_converter_->Push(audio_bus); | 245 render_converter_->Push(audio_bus); |
246 while (render_converter_->Convert(&render_frame_)) | 246 while (render_converter_->Convert(&render_frame_)) |
247 audio_processing_->AnalyzeReverseStream(&render_frame_); | 247 audio_processing_->AnalyzeReverseStream(&render_frame_); |
248 } | 248 } |
249 | 249 |
| 250 void MediaStreamAudioProcessor::OnPlayoutDataSourceChanged() { |
| 251 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 252 // There is no need to hold a lock here since the caller guarantees that |
| 253 // there is no more OnPlayoutData() callback on the render thread. |
| 254 render_thread_checker_.DetachFromThread(); |
| 255 render_converter_.reset(); |
| 256 } |
| 257 |
250 void MediaStreamAudioProcessor::GetStats(AudioProcessorStats* stats) { | 258 void MediaStreamAudioProcessor::GetStats(AudioProcessorStats* stats) { |
251 stats->typing_noise_detected = | 259 stats->typing_noise_detected = |
252 (base::subtle::Acquire_Load(&typing_detected_) != false); | 260 (base::subtle::Acquire_Load(&typing_detected_) != false); |
253 GetAecStats(audio_processing_.get(), stats); | 261 GetAecStats(audio_processing_.get(), stats); |
254 } | 262 } |
255 | 263 |
256 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( | 264 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( |
257 const blink::WebMediaConstraints& constraints, int effects, | 265 const blink::WebMediaConstraints& constraints, int effects, |
258 MediaStreamType type) { | 266 MediaStreamType type) { |
259 DCHECK(!audio_processing_); | 267 DCHECK(!audio_processing_); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 } | 488 } |
481 | 489 |
482 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { | 490 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { |
483 const std::string group_name = | 491 const std::string group_name = |
484 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); | 492 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); |
485 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( | 493 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( |
486 switches::kEnableAudioTrackProcessing); | 494 switches::kEnableAudioTrackProcessing); |
487 } | 495 } |
488 | 496 |
489 } // namespace content | 497 } // namespace content |
OLD | NEW |