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

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

Issue 10698066: Switch to pcm_low_latency and enable resampling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments! Created 8 years, 5 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_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 <vector> 8 #include <vector>
9 9
10 #include "base/time.h"
11 #include "media/base/audio_renderer_sink.h" 10 #include "media/base/audio_renderer_sink.h"
12 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
13 12
14 namespace media { 13 namespace media {
15 14
15 // 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().
16 class FakeAudioRenderCallback : public AudioRendererSink::RenderCallback { 17 class FakeAudioRenderCallback : public AudioRendererSink::RenderCallback {
17 public: 18 public:
18 // Initializes |fill_value_| to a random value seeded by current time. 19 // The function used to fulfill Render() is f(x) = sin(2 * PI * x * |step|),
19 explicit FakeAudioRenderCallback(const AudioParameters& params); 20 // where x = [|number_of_frames| * m, |number_of_frames| * (m + 1)] and m =
21 // the number of Render() calls fulfilled thus far.
22 explicit FakeAudioRenderCallback(double step);
20 virtual ~FakeAudioRenderCallback(); 23 virtual ~FakeAudioRenderCallback();
21 24
22 // Renders |fill_value_| into the provided audio data buffer. If |half_fill_| 25 // Renders a sine wave into the provided audio data buffer. If |half_fill_|
23 // is set, will only fill half the buffer. 26 // is set, will only fill half the buffer.
24 int Render(const std::vector<float*>& audio_data, int number_of_frames, 27 int Render(const std::vector<float*>& audio_data, int number_of_frames,
25 int audio_delay_milliseconds) OVERRIDE; 28 int audio_delay_milliseconds) OVERRIDE;
26 MOCK_METHOD0(OnRenderError, void()); 29 MOCK_METHOD0(OnRenderError, void());
27 30
28 // Toggles only filling half the requested amount during Render(). 31 // Toggles only filling half the requested amount during Render().
29 void set_half_fill(bool half_fill) { half_fill_ = half_fill; } 32 void set_half_fill(bool half_fill) { half_fill_ = half_fill; }
30 33
31 float fill_value() { return fill_value_; } 34 // Reset the sine state to initial value.
32 35 void reset() { x_ = 0; }
33 // Generates a fill value between [-1, 1). NextFillValue() is deterministic
34 // based on fill_value_. Which means it will generate the same sequence of
35 // fill values every time unless |fill_value_| is set using set_fill_value().
36 void NextFillValue();
37 36
38 private: 37 private:
39 bool half_fill_; 38 bool half_fill_;
40 float fill_value_; 39 double x_;
41 AudioParameters audio_parameters_; 40 double step_;
42 41
43 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback); 42 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback);
44 }; 43 };
45 44
46 } // namespace media 45 } // namespace media
47 46
48 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ 47 #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