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

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

Issue 1195633003: Add a silent audio sink to consume WebAudio data on silence detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify the CL to use NullAudioSink Created 5 years, 6 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/audio_bus.h" 5 #include "media/base/audio_bus.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "media/audio/audio_parameters.h" 9 #include "media/audio/audio_parameters.h"
10 #include "media/base/limits.h" 10 #include "media/base/limits.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 void AudioBus::ZeroFrames(int frames) { 213 void AudioBus::ZeroFrames(int frames) {
214 ZeroFramesPartial(0, frames); 214 ZeroFramesPartial(0, frames);
215 } 215 }
216 216
217 void AudioBus::Zero() { 217 void AudioBus::Zero() {
218 ZeroFrames(frames_); 218 ZeroFrames(frames_);
219 } 219 }
220 220
221 bool AudioBus::AreFramesZero() const {
222 if (frames_ <= 0)
DaleCurtis 2015/06/22 19:14:41 Seems unnecessary, loop will exit quickly anyway.
qinmin 2015/06/22 22:23:16 Done.
223 return true;
224
225 for (size_t i = 0; i < channel_data_.size(); ++i) {
226 for (int j = 0; j < frames_; j++) {
227 if (*(channel_data_[i] + j) != 0.0f)
DaleCurtis 2015/06/22 19:14:41 Just use "if (channel_data_[i][j]) return false;"
qinmin 2015/06/22 22:23:16 Done.
228 return false;
229 }
230 }
231 return true;
232 }
233
221 int AudioBus::CalculateMemorySize(const AudioParameters& params) { 234 int AudioBus::CalculateMemorySize(const AudioParameters& params) {
222 return CalculateMemorySizeInternal( 235 return CalculateMemorySizeInternal(
223 params.channels(), params.frames_per_buffer(), NULL); 236 params.channels(), params.frames_per_buffer(), NULL);
224 } 237 }
225 238
226 int AudioBus::CalculateMemorySize(int channels, int frames) { 239 int AudioBus::CalculateMemorySize(int channels, int frames) {
227 return CalculateMemorySizeInternal(channels, frames, NULL); 240 return CalculateMemorySizeInternal(channels, frames, NULL);
228 } 241 }
229 242
230 void AudioBus::BuildChannelData(int channels, int aligned_frames, float* data) { 243 void AudioBus::BuildChannelData(int channels, int aligned_frames, float* data) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 return scoped_refptr<AudioBusRefCounted>( 358 return scoped_refptr<AudioBusRefCounted>(
346 new AudioBusRefCounted(channels, frames)); 359 new AudioBusRefCounted(channels, frames));
347 } 360 }
348 361
349 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames) 362 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames)
350 : AudioBus(channels, frames) {} 363 : AudioBus(channels, frames) {}
351 364
352 AudioBusRefCounted::~AudioBusRefCounted() {} 365 AudioBusRefCounted::~AudioBusRefCounted() {}
353 366
354 } // namespace media 367 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698