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

Side by Side Diff: media/audio/simple_sources.cc

Issue 481193003: Remove AudioBuffersState usage in Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix audio muter build buster. Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/simple_sources.h ('k') | media/audio/simple_sources_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // MSVC++ requires this to be set before any other includes to get M_PI. 4 // MSVC++ requires this to be set before any other includes to get M_PI.
5 #define _USE_MATH_DEFINES 5 #define _USE_MATH_DEFINES
6 #include <cmath> 6 #include <cmath>
7 7
8 #include "media/audio/simple_sources.h" 8 #include "media/audio/simple_sources.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 11 matching lines...) Expand all
22 f_(freq / sample_freq), 22 f_(freq / sample_freq),
23 time_state_(0), 23 time_state_(0),
24 cap_(0), 24 cap_(0),
25 callbacks_(0), 25 callbacks_(0),
26 errors_(0) { 26 errors_(0) {
27 } 27 }
28 28
29 // The implementation could be more efficient if a lookup table is constructed 29 // The implementation could be more efficient if a lookup table is constructed
30 // but it is efficient enough for our simple needs. 30 // but it is efficient enough for our simple needs.
31 int SineWaveAudioSource::OnMoreData(AudioBus* audio_bus, 31 int SineWaveAudioSource::OnMoreData(AudioBus* audio_bus,
32 AudioBuffersState audio_buffers) { 32 uint32 total_bytes_delay) {
33 base::AutoLock auto_lock(time_lock_); 33 base::AutoLock auto_lock(time_lock_);
34 callbacks_++; 34 callbacks_++;
35 35
36 // The table is filled with s(t) = kint16max*sin(Theta*t), 36 // The table is filled with s(t) = kint16max*sin(Theta*t),
37 // where Theta = 2*PI*fs. 37 // where Theta = 2*PI*fs.
38 // We store the discrete time value |t| in a member to ensure that the 38 // We store the discrete time value |t| in a member to ensure that the
39 // next pass starts at a correct state. 39 // next pass starts at a correct state.
40 int max_frames = cap_ > 0 ? 40 int max_frames = cap_ > 0 ?
41 std::min(audio_bus->frames(), cap_ - time_state_) : audio_bus->frames(); 41 std::min(audio_bus->frames(), cap_ - time_state_) : audio_bus->frames();
42 for (int i = 0; i < max_frames; ++i) 42 for (int i = 0; i < max_frames; ++i)
(...skipping 14 matching lines...) Expand all
57 DCHECK_GT(cap, 0); 57 DCHECK_GT(cap, 0);
58 cap_ = cap; 58 cap_ = cap;
59 } 59 }
60 60
61 void SineWaveAudioSource::Reset() { 61 void SineWaveAudioSource::Reset() {
62 base::AutoLock auto_lock(time_lock_); 62 base::AutoLock auto_lock(time_lock_);
63 time_state_ = 0; 63 time_state_ = 0;
64 } 64 }
65 65
66 } // namespace media 66 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/simple_sources.h ('k') | media/audio/simple_sources_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698