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

Side by Side Diff: media/base/audio_converter.cc

Issue 1211203006: Fixes issue where Web Speech API drops a frame every 5.1 seconds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // AudioConverter implementation. Uses MultiChannelSincResampler for resampling 5 // AudioConverter implementation. Uses MultiChannelSincResampler for resampling
6 // audio, ChannelMixer for channel mixing, and AudioPullFifo for buffering. 6 // audio, ChannelMixer for channel mixing, and AudioPullFifo for buffering.
7 // 7 //
8 // Delay estimates are provided to InputCallbacks based on the frame delay 8 // Delay estimates are provided to InputCallbacks based on the frame delay
9 // information reported via the resampler and FIFO units. 9 // information reported via the resampler and FIFO units.
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 chunk_size_ = input_params.frames_per_buffer(); 82 chunk_size_ = input_params.frames_per_buffer();
83 audio_fifo_.reset(new AudioPullFifo( 83 audio_fifo_.reset(new AudioPullFifo(
84 downmix_early_ ? output_params.channels() : input_params.channels(), 84 downmix_early_ ? output_params.channels() : input_params.channels(),
85 chunk_size_, 85 chunk_size_,
86 base::Bind(&AudioConverter::SourceCallback, base::Unretained(this)))); 86 base::Bind(&AudioConverter::SourceCallback, base::Unretained(this))));
87 } 87 }
88 } 88 }
89 89
90 AudioConverter::~AudioConverter() {} 90 AudioConverter::~AudioConverter() {}
91 91
92 void AudioConverter::PrimeWithSilence() {
93 if (!resampler_)
94 return;
95 DVLOG(1) << "AudioConverter::PrimeWithSilence";
DaleCurtis 2015/07/07 16:38:17 Remove before submit and invert conditional; i.e.
henrika (OOO until Aug 14) 2015/07/08 12:22:59 Done.
96 resampler_->PrimeWithSilence();
97 }
98
92 void AudioConverter::AddInput(InputCallback* input) { 99 void AudioConverter::AddInput(InputCallback* input) {
93 DCHECK(std::find(transform_inputs_.begin(), transform_inputs_.end(), input) == 100 DCHECK(std::find(transform_inputs_.begin(), transform_inputs_.end(), input) ==
94 transform_inputs_.end()); 101 transform_inputs_.end());
95 transform_inputs_.push_back(input); 102 transform_inputs_.push_back(input);
96 } 103 }
97 104
98 void AudioConverter::RemoveInput(InputCallback* input) { 105 void AudioConverter::RemoveInput(InputCallback* input) {
99 DCHECK(std::find(transform_inputs_.begin(), transform_inputs_.end(), input) != 106 DCHECK(std::find(transform_inputs_.begin(), transform_inputs_.end(), input) !=
100 transform_inputs_.end()); 107 transform_inputs_.end());
101 transform_inputs_.remove(input); 108 transform_inputs_.remove(input);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 else 250 else
244 SourceCallback(0, dest); 251 SourceCallback(0, dest);
245 } 252 }
246 253
247 void AudioConverter::CreateUnmixedAudioIfNecessary(int frames) { 254 void AudioConverter::CreateUnmixedAudioIfNecessary(int frames) {
248 if (!unmixed_audio_ || unmixed_audio_->frames() != frames) 255 if (!unmixed_audio_ || unmixed_audio_->frames() != frames)
249 unmixed_audio_ = AudioBus::Create(input_channel_count_, frames); 256 unmixed_audio_ = AudioBus::Create(input_channel_count_, frames);
250 } 257 }
251 258
252 } // namespace media 259 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698