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

Side by Side Diff: media/base/multi_channel_resampler.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 #include "media/base/multi_channel_resampler.h" 5 #include "media/base/multi_channel_resampler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 24 matching lines...) Expand all
35 resampler_audio_bus_ = AudioBus::Create(channels - 1, request_size); 35 resampler_audio_bus_ = AudioBus::Create(channels - 1, request_size);
36 for (int i = 0; i < resampler_audio_bus_->channels(); ++i) { 36 for (int i = 0; i < resampler_audio_bus_->channels(); ++i) {
37 wrapped_resampler_audio_bus_->SetChannelData( 37 wrapped_resampler_audio_bus_->SetChannelData(
38 i + 1, resampler_audio_bus_->channel(i)); 38 i + 1, resampler_audio_bus_->channel(i));
39 } 39 }
40 } 40 }
41 } 41 }
42 42
43 MultiChannelResampler::~MultiChannelResampler() {} 43 MultiChannelResampler::~MultiChannelResampler() {}
44 44
45 void MultiChannelResampler::PrimeWithSilence() {
46 DCHECK(!resamplers_.empty());
47 for (size_t i = 0; i < resamplers_.size(); ++i) {
DaleCurtis 2015/07/07 16:38:17 No {} for single line please.
henrika (OOO until Aug 14) 2015/07/08 12:22:59 Done.
48 resamplers_[i]->PrimeWithSilence();
49 }
50 }
51
45 void MultiChannelResampler::Resample(int frames, AudioBus* audio_bus) { 52 void MultiChannelResampler::Resample(int frames, AudioBus* audio_bus) {
46 DCHECK_EQ(static_cast<size_t>(audio_bus->channels()), resamplers_.size()); 53 DCHECK_EQ(static_cast<size_t>(audio_bus->channels()), resamplers_.size());
47 54
48 // Optimize the single channel case to avoid the chunking process below. 55 // Optimize the single channel case to avoid the chunking process below.
49 if (audio_bus->channels() == 1) { 56 if (audio_bus->channels() == 1) {
50 resamplers_[0]->Resample(frames, audio_bus->channel(0)); 57 resamplers_[0]->Resample(frames, audio_bus->channel(0));
51 return; 58 return;
52 } 59 }
53 60
54 // We need to ensure that SincResampler only calls ProvideInput once for each 61 // We need to ensure that SincResampler only calls ProvideInput once for each
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 121 }
115 122
116 123
117 double MultiChannelResampler::BufferedFrames() const { 124 double MultiChannelResampler::BufferedFrames() const {
118 DCHECK(!resamplers_.empty()); 125 DCHECK(!resamplers_.empty());
119 return resamplers_[0]->BufferedFrames(); 126 return resamplers_[0]->BufferedFrames();
120 } 127 }
121 128
122 129
123 } // namespace media 130 } // namespace media
OLDNEW
« media/base/audio_converter.cc ('K') | « media/base/multi_channel_resampler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698