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

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: Review fixes. 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
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.
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 explicit FakeAudioRenderCallback(double step);
scherkus (not reviewing) 2012/07/12 23:02:52 docs for step
DaleCurtis 2012/07/13 00:01:25 Done.
19 explicit FakeAudioRenderCallback(const AudioParameters& params);
20 virtual ~FakeAudioRenderCallback(); 20 virtual ~FakeAudioRenderCallback();
21 21
22 // Renders |fill_value_| into the provided audio data buffer. If |half_fill_| 22 // Renders a sine wave into the provided audio data buffer. If |half_fill_|
23 // is set, will only fill half the buffer. 23 // is set, will only fill half the buffer.
24 int Render(const std::vector<float*>& audio_data, int number_of_frames, 24 int Render(const std::vector<float*>& audio_data, int number_of_frames,
25 int audio_delay_milliseconds) OVERRIDE; 25 int audio_delay_milliseconds) OVERRIDE;
26 MOCK_METHOD0(OnRenderError, void()); 26 MOCK_METHOD0(OnRenderError, void());
27 27
28 // Toggles only filling half the requested amount during Render(). 28 // Toggles only filling half the requested amount during Render().
29 void set_half_fill(bool half_fill) { half_fill_ = half_fill; } 29 void set_half_fill(bool half_fill) { half_fill_ = half_fill; }
30 30
31 float fill_value() { return fill_value_; } 31 // Reset the sine state to initial value.
32 32 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 33
38 private: 34 private:
39 bool half_fill_; 35 bool half_fill_;
40 float fill_value_; 36 double x_;
41 AudioParameters audio_parameters_; 37 double step_;
42 38
43 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback); 39 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback);
44 }; 40 };
45 41
46 } // namespace media 42 } // namespace media
47 43
48 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ 44 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698