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

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

Issue 10830268: Allow audio system to handle synchronized low-latency audio I/O (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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/win/audio_low_latency_output_win_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 28 matching lines...) Expand all
39 std::min(audio_bus->frames(), cap_ - time_state_) : audio_bus->frames(); 39 std::min(audio_bus->frames(), cap_ - time_state_) : audio_bus->frames();
40 for (int i = 0; i < max_frames; ++i) 40 for (int i = 0; i < max_frames; ++i)
41 audio_bus->channel(0)[i] = sin(2.0 * M_PI * f_ * time_state_++); 41 audio_bus->channel(0)[i] = sin(2.0 * M_PI * f_ * time_state_++);
42 for (int i = 1; i < audio_bus->channels(); ++i) { 42 for (int i = 1; i < audio_bus->channels(); ++i) {
43 memcpy(audio_bus->channel(i), audio_bus->channel(0), 43 memcpy(audio_bus->channel(i), audio_bus->channel(0),
44 max_frames * sizeof(*audio_bus->channel(i))); 44 max_frames * sizeof(*audio_bus->channel(i)));
45 } 45 }
46 return max_frames; 46 return max_frames;
47 } 47 }
48 48
49 int SineWaveAudioSource::OnMoreIOData(AudioBus* source,
50 AudioBus* dest,
51 AudioBuffersState audio_buffers) {
52 NOTREACHED();
53 return 0;
54 }
55
49 void SineWaveAudioSource::OnError(AudioOutputStream* stream, int code) { 56 void SineWaveAudioSource::OnError(AudioOutputStream* stream, int code) {
50 NOTREACHED(); 57 NOTREACHED();
51 } 58 }
52 59
53 void SineWaveAudioSource::CapSamples(int cap) { 60 void SineWaveAudioSource::CapSamples(int cap) {
54 base::AutoLock auto_lock(time_lock_); 61 base::AutoLock auto_lock(time_lock_);
55 DCHECK_GT(cap, 0); 62 DCHECK_GT(cap, 0);
56 cap_ = cap; 63 cap_ = cap;
57 } 64 }
58 65
59 void SineWaveAudioSource::Reset() { 66 void SineWaveAudioSource::Reset() {
60 base::AutoLock auto_lock(time_lock_); 67 base::AutoLock auto_lock(time_lock_);
61 time_state_ = 0; 68 time_state_ = 0;
62 } 69 }
63 70
64 } // namespace media 71 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/simple_sources.h ('k') | media/audio/win/audio_low_latency_output_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698