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

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

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/audio_renderer_sink.h ('k') | media/base/fake_audio_render_callback.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 4
5 #ifndef MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ 5 #ifndef MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_
6 #define MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ 6 #define MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_
7 7
8 #include <vector>
9
10 #include "media/base/audio_renderer_sink.h" 8 #include "media/base/audio_renderer_sink.h"
11 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
12 10
13 namespace media { 11 namespace media {
14 12
15 // Fake RenderCallback which will fill each request with a sine wave. Sine 13 // Fake RenderCallback which will fill each request with a sine wave. Sine
16 // state is kept across callbacks. State can be reset to default via reset(). 14 // state is kept across callbacks. State can be reset to default via reset().
17 class FakeAudioRenderCallback : public AudioRendererSink::RenderCallback { 15 class FakeAudioRenderCallback : public AudioRendererSink::RenderCallback {
18 public: 16 public:
19 // The function used to fulfill Render() is f(x) = sin(2 * PI * x * |step|), 17 // The function used to fulfill Render() is f(x) = sin(2 * PI * x * |step|),
20 // where x = [|number_of_frames| * m, |number_of_frames| * (m + 1)] and m = 18 // where x = [|number_of_frames| * m, |number_of_frames| * (m + 1)] and m =
21 // the number of Render() calls fulfilled thus far. 19 // the number of Render() calls fulfilled thus far.
22 explicit FakeAudioRenderCallback(double step); 20 explicit FakeAudioRenderCallback(double step);
23 virtual ~FakeAudioRenderCallback(); 21 virtual ~FakeAudioRenderCallback();
24 22
25 // Renders a sine wave into the provided audio data buffer. If |half_fill_| 23 // Renders a sine wave into the provided audio data buffer. If |half_fill_|
26 // is set, will only fill half the buffer. 24 // is set, will only fill half the buffer.
27 int Render(const std::vector<float*>& audio_data, int number_of_frames, 25 int Render(AudioBus* audio_bus, int audio_delay_milliseconds) OVERRIDE;
28 int audio_delay_milliseconds) OVERRIDE;
29 MOCK_METHOD0(OnRenderError, void()); 26 MOCK_METHOD0(OnRenderError, void());
30 27
31 // Toggles only filling half the requested amount during Render(). 28 // Toggles only filling half the requested amount during Render().
32 void set_half_fill(bool half_fill) { half_fill_ = half_fill; } 29 void set_half_fill(bool half_fill) { half_fill_ = half_fill; }
33 30
34 // Reset the sine state to initial value. 31 // Reset the sine state to initial value.
35 void reset() { x_ = 0; } 32 void reset() { x_ = 0; }
36 33
37 private: 34 private:
38 bool half_fill_; 35 bool half_fill_;
39 double x_; 36 double x_;
40 double step_; 37 double step_;
41 38
42 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback); 39 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback);
43 }; 40 };
44 41
45 } // namespace media 42 } // namespace media
46 43
47 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ 44 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_
OLDNEW
« no previous file with comments | « media/base/audio_renderer_sink.h ('k') | media/base/fake_audio_render_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698