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

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

Issue 10823175: Switch AudioRenderSink::Callback to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup MCR AudioBus usage. Created 8 years, 4 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/base/fake_audio_render_callback.h ('k') | media/base/multi_channel_resampler.h » ('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 4
5 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "media/base/fake_audio_render_callback.h" 8 #include "media/base/fake_audio_render_callback.h"
9 9
10 #include <cmath> 10 #include <cmath>
11 11
12 namespace media { 12 namespace media {
13 13
14 FakeAudioRenderCallback::FakeAudioRenderCallback(double step) 14 FakeAudioRenderCallback::FakeAudioRenderCallback(double step)
15 : half_fill_(false), 15 : half_fill_(false),
16 step_(step) { 16 step_(step) {
17 reset(); 17 reset();
18 } 18 }
19 19
20 FakeAudioRenderCallback::~FakeAudioRenderCallback() {} 20 FakeAudioRenderCallback::~FakeAudioRenderCallback() {}
21 21
22 int FakeAudioRenderCallback::Render(const std::vector<float*>& audio_data, 22 int FakeAudioRenderCallback::Render(AudioBus* audio_bus,
23 int number_of_frames,
24 int audio_delay_milliseconds) { 23 int audio_delay_milliseconds) {
24 int number_of_frames = audio_bus->frames();
25 if (half_fill_) 25 if (half_fill_)
26 number_of_frames /= 2; 26 number_of_frames /= 2;
27 27
28 // Fill first channel with a sine wave. 28 // Fill first channel with a sine wave.
29 for (int i = 0; i < number_of_frames; ++i) 29 for (int i = 0; i < number_of_frames; ++i)
30 audio_data[0][i] = sin(2 * M_PI * (x_ + step_ * i)); 30 audio_bus->channel(0)[i] = sin(2 * M_PI * (x_ + step_ * i));
31 x_ += number_of_frames * step_; 31 x_ += number_of_frames * step_;
32 32
33 // Copy first channel into the rest of the channels. 33 // Copy first channel into the rest of the channels.
34 for (size_t i = 1; i < audio_data.size(); ++i) 34 for (int i = 1; i < audio_bus->channels(); ++i)
35 memcpy(audio_data[i], audio_data[0], 35 memcpy(audio_bus->channel(i), audio_bus->channel(0),
36 number_of_frames * sizeof(*audio_data[0])); 36 number_of_frames * sizeof(*audio_bus->channel(i)));
37 37
38 return number_of_frames; 38 return number_of_frames;
39 } 39 }
40 40
41 } // namespace media 41 } // namespace media
OLDNEW
« no previous file with comments | « media/base/fake_audio_render_callback.h ('k') | media/base/multi_channel_resampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698