| Index: content/renderer/media/media_stream_audio_processor.cc
|
| diff --git a/content/renderer/media/media_stream_audio_processor.cc b/content/renderer/media/media_stream_audio_processor.cc
|
| index 5e4c1c0569d0c01044246d82c01ab07a12b74392..b3ae7c6efcc762b4d407ebb0e91f0f18d8409242 100644
|
| --- a/content/renderer/media/media_stream_audio_processor.cc
|
| +++ b/content/renderer/media/media_stream_audio_processor.cc
|
| @@ -279,7 +279,8 @@ MediaStreamAudioProcessor::MediaStreamAudioProcessor(
|
| playout_data_source_(playout_data_source),
|
| audio_mirroring_(false),
|
| typing_detected_(false),
|
| - stopped_(false) {
|
| + stopped_(false),
|
| + skipped_output_frames_(0) {
|
| capture_thread_checker_.DetachFromThread();
|
| render_thread_checker_.DetachFromThread();
|
| InitializeAudioProcessingModule(constraints, input_params);
|
| @@ -432,7 +433,8 @@ void MediaStreamAudioProcessor::OnIpcClosing() {
|
|
|
| void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus,
|
| int sample_rate,
|
| - int audio_delay_milliseconds) {
|
| + int audio_delay_milliseconds,
|
| + uint32_t skipped_frames) {
|
| DCHECK(render_thread_checker_.CalledOnValidThread());
|
| DCHECK(audio_processing_->echo_control_mobile()->is_enabled() ^
|
| audio_processing_->echo_cancellation()->is_enabled());
|
| @@ -447,6 +449,25 @@ void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus,
|
|
|
| render_fifo_->Push(
|
| *audio_bus, base::TimeDelta::FromMilliseconds(audio_delay_milliseconds));
|
| +
|
| + // Feed the APM with empty frames if frames have been skipped. The APM only
|
| + // accepts 10 ms chunks.
|
| + skipped_output_frames_ += skipped_frames;
|
| + uint32_t frames_per_10ms = static_cast<uint32_t>(sample_rate / 100);
|
| + if (skipped_output_frames_ > frames_per_10ms) {
|
| + MediaStreamAudioBus empty_bus(audio_bus->channels(), frames_per_10ms);
|
| + empty_bus.bus()->Zero();
|
| + while (skipped_output_frames_ > frames_per_10ms) {
|
| + audio_processing_->AnalyzeReverseStream(
|
| + empty_bus.channel_ptrs(),
|
| + empty_bus.bus()->frames(),
|
| + sample_rate,
|
| + ChannelsToLayout(empty_bus.bus()->channels()));
|
| + skipped_output_frames_ -= frames_per_10ms;
|
| + }
|
| + }
|
| +
|
| + // Pull data from the fifo and feed the APM.
|
| MediaStreamAudioBus* analysis_bus;
|
| base::TimeDelta audio_delay;
|
| while (render_fifo_->Consume(&analysis_bus, &audio_delay)) {
|
| @@ -455,7 +476,7 @@ void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus,
|
| analysis_bus->channel_ptrs(),
|
| analysis_bus->bus()->frames(),
|
| sample_rate,
|
| - ChannelsToLayout(audio_bus->channels()));
|
| + ChannelsToLayout(analysis_bus->bus()->channels()));
|
| }
|
| }
|
|
|
|
|