OLD | NEW |
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_converter.h" |
9 #include "media/base/audio_renderer_sink.h" | 9 #include "media/base/audio_renderer_sink.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 // 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 |
15 // 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(). |
16 // Also provide an interface to AudioTransformInput. | 16 // Also provide an interface to AudioTransformInput. |
17 class FakeAudioRenderCallback | 17 class FakeAudioRenderCallback |
18 : public AudioRendererSink::RenderCallback, | 18 : public AudioRendererSink::RenderCallback, |
19 public AudioConverter::InputCallback { | 19 public AudioConverter::InputCallback { |
20 public: | 20 public: |
21 // 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|), |
22 // 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 = |
23 // the number of Render() calls fulfilled thus far. | 23 // the number of Render() calls fulfilled thus far. |
24 explicit FakeAudioRenderCallback(double step); | 24 explicit FakeAudioRenderCallback(double step); |
25 ~FakeAudioRenderCallback() override; | 25 ~FakeAudioRenderCallback() override; |
26 | 26 |
27 // 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_| |
28 // is set, will only fill half the buffer. | 28 // is set, will only fill half the buffer. |
29 int Render(AudioBus* audio_bus, | 29 int Render(AudioBus* audio_bus, int audio_delay_milliseconds) override; |
30 uint32_t audio_delay_milliseconds, | |
31 uint32_t frames_skipped) override; | |
32 MOCK_METHOD0(OnRenderError, void()); | 30 MOCK_METHOD0(OnRenderError, void()); |
33 | 31 |
34 // AudioTransform::ProvideAudioTransformInput implementation. | 32 // AudioTransform::ProvideAudioTransformInput implementation. |
35 double ProvideInput(AudioBus* audio_bus, | 33 double ProvideInput(AudioBus* audio_bus, |
36 base::TimeDelta buffer_delay) override; | 34 base::TimeDelta buffer_delay) override; |
37 | 35 |
38 // Toggles only filling half the requested amount during Render(). | 36 // Toggles only filling half the requested amount during Render(). |
39 void set_half_fill(bool half_fill) { half_fill_ = half_fill; } | 37 void set_half_fill(bool half_fill) { half_fill_ = half_fill; } |
40 | 38 |
41 // Reset the sine state to initial value. | 39 // Reset the sine state to initial value. |
(...skipping 17 matching lines...) Expand all Loading... |
59 int last_audio_delay_milliseconds_; | 57 int last_audio_delay_milliseconds_; |
60 int last_channel_count_; | 58 int last_channel_count_; |
61 double volume_; | 59 double volume_; |
62 | 60 |
63 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback); | 61 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback); |
64 }; | 62 }; |
65 | 63 |
66 } // namespace media | 64 } // namespace media |
67 | 65 |
68 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ | 66 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ |
OLD | NEW |