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

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

Issue 11410012: Collapse AudioRendererMixer and OnMoreDataResampler into AudioTransform. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename. Comments. Created 8 years, 1 month 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_mixer_unittest.cc ('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 "media/base/audio_converter.h"
8 #include "media/base/audio_renderer_sink.h" 9 #include "media/base/audio_renderer_sink.h"
9 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
10 11
11 namespace media { 12 namespace media {
12 13
13 // Fake RenderCallback which will fill each request with a sine wave. Sine 14 // Fake RenderCallback which will fill each request with a sine wave. Sine
14 // state is kept across callbacks. State can be reset to default via reset(). 15 // state is kept across callbacks. State can be reset to default via reset().
15 class FakeAudioRenderCallback : public AudioRendererSink::RenderCallback { 16 // Also provide an interface to AudioTransformInput.
17 class FakeAudioRenderCallback
18 : public AudioRendererSink::RenderCallback,
19 public AudioConverter::InputCallback {
16 public: 20 public:
17 // The function used to fulfill Render() is f(x) = sin(2 * PI * x * |step|), 21 // The function used to fulfill Render() is f(x) = sin(2 * PI * x * |step|),
18 // where x = [|number_of_frames| * m, |number_of_frames| * (m + 1)] and m = 22 // where x = [|number_of_frames| * m, |number_of_frames| * (m + 1)] and m =
19 // the number of Render() calls fulfilled thus far. 23 // the number of Render() calls fulfilled thus far.
20 explicit FakeAudioRenderCallback(double step); 24 explicit FakeAudioRenderCallback(double step);
21 virtual ~FakeAudioRenderCallback(); 25 virtual ~FakeAudioRenderCallback();
22 26
23 // Renders a sine wave into the provided audio data buffer. If |half_fill_| 27 // Renders a sine wave into the provided audio data buffer. If |half_fill_|
24 // is set, will only fill half the buffer. 28 // is set, will only fill half the buffer.
25 int Render(AudioBus* audio_bus, int audio_delay_milliseconds) OVERRIDE; 29 virtual int Render(AudioBus* audio_bus,
30 int audio_delay_milliseconds) OVERRIDE;
26 MOCK_METHOD0(OnRenderError, void()); 31 MOCK_METHOD0(OnRenderError, void());
27 32
33 // AudioTransform::ProvideAudioTransformInput implementation.
34 virtual double ProvideInput(AudioBus* audio_bus,
35 base::TimeDelta buffer_delay) OVERRIDE;
36
28 // Toggles only filling half the requested amount during Render(). 37 // Toggles only filling half the requested amount during Render().
29 void set_half_fill(bool half_fill) { half_fill_ = half_fill; } 38 void set_half_fill(bool half_fill) { half_fill_ = half_fill; }
30 39
31 // Reset the sine state to initial value. 40 // Reset the sine state to initial value.
32 void reset() { x_ = 0; } 41 void reset() { x_ = 0; }
33 42
34 // Returns the last |audio_delay_milliseconds| provided to Render() or -1 if 43 // Returns the last |audio_delay_milliseconds| provided to Render() or -1 if
35 // no Render() call occurred. 44 // no Render() call occurred.
36 int last_audio_delay_milliseconds() { return last_audio_delay_milliseconds_; } 45 int last_audio_delay_milliseconds() { return last_audio_delay_milliseconds_; }
37 46
47 // Set volume information used by ProvideAudioTransformInput().
48 void set_volume(double volume) { volume_ = volume; }
49
38 private: 50 private:
39 bool half_fill_; 51 bool half_fill_;
40 double x_; 52 double x_;
41 double step_; 53 double step_;
42 int last_audio_delay_milliseconds_; 54 int last_audio_delay_milliseconds_;
55 double volume_;
43 56
44 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback); 57 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback);
45 }; 58 };
46 59
47 } // namespace media 60 } // namespace media
48 61
49 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ 62 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer_unittest.cc ('k') | media/base/fake_audio_render_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698