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

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

Issue 2004283002: AudioConverter: Express delay in frames rather than msec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed files & removed rounding Created 4 years, 6 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
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 // The function used to fulfill Render() is f(x) = sin(2 * PI * x * |step|), 24 // The function used to fulfill Render() is f(x) = sin(2 * PI * x * |step|),
25 // where x = [|number_of_frames| * m, |number_of_frames| * (m + 1)] and m = 25 // where x = [|number_of_frames| * m, |number_of_frames| * (m + 1)] and m =
26 // the number of Render() calls fulfilled thus far. 26 // the number of Render() calls fulfilled thus far.
27 explicit FakeAudioRenderCallback(double step); 27 explicit FakeAudioRenderCallback(double step);
28 ~FakeAudioRenderCallback() override; 28 ~FakeAudioRenderCallback() override;
29 29
30 // Renders a sine wave into the provided audio data buffer. If |half_fill_| 30 // Renders a sine wave into the provided audio data buffer. If |half_fill_|
31 // is set, will only fill half the buffer. 31 // is set, will only fill half the buffer.
32 int Render(AudioBus* audio_bus, 32 int Render(AudioBus* audio_bus,
33 uint32_t audio_delay_milliseconds, 33 uint32_t frames_delayed,
34 uint32_t frames_skipped) override; 34 uint32_t frames_skipped) override;
35 MOCK_METHOD0(OnRenderError, void()); 35 MOCK_METHOD0(OnRenderError, void());
36 36
37 // AudioTransform::ProvideAudioTransformInput implementation. 37 // AudioTransform::ProvideAudioTransformInput implementation.
38 double ProvideInput(AudioBus* audio_bus, 38 double ProvideInput(AudioBus* audio_bus, uint32_t frames_delayed) override;
39 base::TimeDelta buffer_delay) override;
40 39
41 // Toggles only filling half the requested amount during Render(). 40 // Toggles only filling half the requested amount during Render().
42 void set_half_fill(bool half_fill) { half_fill_ = half_fill; } 41 void set_half_fill(bool half_fill) { half_fill_ = half_fill; }
43 42
44 // Reset the sine state to initial value. 43 // Reset the sine state to initial value.
45 void reset() { x_ = 0; } 44 void reset() { x_ = 0; }
46 45
47 // Returns the last |audio_delay_milliseconds| provided to Render() or -1 if 46 // Returns the last |frames_delayed| provided to Render() or -1 if
48 // no Render() call occurred. 47 // no Render() call occurred.
49 int last_audio_delay_milliseconds() const { 48 int last_frames_delayed() const { return last_frames_delayed_; }
50 return last_audio_delay_milliseconds_;
51 }
52 49
53 // Set volume information used by ProvideAudioTransformInput(). 50 // Set volume information used by ProvideAudioTransformInput().
54 void set_volume(double volume) { volume_ = volume; } 51 void set_volume(double volume) { volume_ = volume; }
55 52
56 int last_channel_count() const { return last_channel_count_; } 53 int last_channel_count() const { return last_channel_count_; }
57 54
58 private: 55 private:
59 bool half_fill_; 56 bool half_fill_;
60 double x_; 57 double x_;
61 double step_; 58 double step_;
62 int last_audio_delay_milliseconds_; 59 int last_frames_delayed_;
63 int last_channel_count_; 60 int last_channel_count_;
64 double volume_; 61 double volume_;
65 62
66 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback); 63 DISALLOW_COPY_AND_ASSIGN(FakeAudioRenderCallback);
67 }; 64 };
68 65
69 } // namespace media 66 } // namespace media
70 67
71 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_ 68 #endif // MEDIA_BASE_FAKE_AUDIO_RENDER_CALLBACK_H_
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer_input_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