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

Side by Side Diff: media/filters/audio_renderer_impl.h

Issue 10753021: Move AudioRenderer out of Filter heirarchy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: woot for RunInSeries/Parallel 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 // Audio rendering unit utilizing an AudioRendererSink to output data. 5 // Audio rendering unit utilizing an AudioRendererSink to output data.
6 // 6 //
7 // This class lives inside three threads during it's lifetime, namely: 7 // This class lives inside three threads during it's lifetime, namely:
8 // 1. Render thread. 8 // 1. Render thread.
9 // This object is created on the render thread. 9 // This object is created on the render thread.
10 // 2. Pipeline thread 10 // 2. Pipeline thread
(...skipping 22 matching lines...) Expand all
33 33
34 class MEDIA_EXPORT AudioRendererImpl 34 class MEDIA_EXPORT AudioRendererImpl
35 : public AudioRenderer, 35 : public AudioRenderer,
36 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback) { 36 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback) {
37 public: 37 public:
38 // Methods called on Render thread ------------------------------------------ 38 // Methods called on Render thread ------------------------------------------
39 // An AudioRendererSink is used as the destination for the rendered audio. 39 // An AudioRendererSink is used as the destination for the rendered audio.
40 explicit AudioRendererImpl(media::AudioRendererSink* sink); 40 explicit AudioRendererImpl(media::AudioRendererSink* sink);
41 41
42 // Methods called on pipeline thread ---------------------------------------- 42 // Methods called on pipeline thread ----------------------------------------
43 // Filter implementation. 43 // AudioRenderer implementation.
44 virtual void SetHost(FilterHost* host) OVERRIDE; 44 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder,
45 const PipelineStatusCB& init_cb,
46 const base::Closure& underflow_cb,
47 const TimeCB& time_cb,
48 const base::Closure& ended_cb,
49 const base::Closure& disabled_cb) OVERRIDE;
45 virtual void Play(const base::Closure& callback) OVERRIDE; 50 virtual void Play(const base::Closure& callback) OVERRIDE;
46 virtual void Pause(const base::Closure& callback) OVERRIDE; 51 virtual void Pause(const base::Closure& callback) OVERRIDE;
47 virtual void Flush(const base::Closure& callback) OVERRIDE; 52 virtual void Flush(const base::Closure& callback) OVERRIDE;
48 virtual void Stop(const base::Closure& callback) OVERRIDE; 53 virtual void Stop(const base::Closure& callback) OVERRIDE;
49 virtual void SetPlaybackRate(float rate) OVERRIDE; 54 virtual void SetPlaybackRate(float rate) OVERRIDE;
50 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; 55 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE;
51
52 // AudioRenderer implementation.
53 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder,
54 const PipelineStatusCB& init_cb,
55 const base::Closure& underflow_cb,
56 const TimeCB& time_cb) OVERRIDE;
57 virtual bool HasEnded() OVERRIDE; 56 virtual bool HasEnded() OVERRIDE;
58 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; 57 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE;
59 virtual void SetVolume(float volume) OVERRIDE; 58 virtual void SetVolume(float volume) OVERRIDE;
60 59
61 // Disables underflow support. When used, |state_| will never transition to 60 // Disables underflow support. When used, |state_| will never transition to
62 // kUnderflow resulting in Render calls that underflow returning 0 frames 61 // kUnderflow resulting in Render calls that underflow returning 0 frames
63 // instead of some number of silence frames. Must be called prior to 62 // instead of some number of silence frames. Must be called prior to
64 // Initialize(). 63 // Initialize().
65 void DisableUnderflowForTesting(); 64 void DisableUnderflowForTesting();
66 65
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // increments |pending_reads_|. 123 // increments |pending_reads_|.
125 // 124 //
126 // Safe to call from any thread. 125 // Safe to call from any thread.
127 void ScheduleRead_Locked(); 126 void ScheduleRead_Locked();
128 127
129 // Returns true if the data in the buffer is all before 128 // Returns true if the data in the buffer is all before
130 // |seek_timestamp_|. This can only return true while 129 // |seek_timestamp_|. This can only return true while
131 // in the kSeeking state. 130 // in the kSeeking state.
132 bool IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer); 131 bool IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer);
133 132
134 FilterHost* host_;
135
136 // Audio decoder. 133 // Audio decoder.
137 scoped_refptr<AudioDecoder> decoder_; 134 scoped_refptr<AudioDecoder> decoder_;
138 135
139 // Algorithm for scaling audio. 136 // Algorithm for scaling audio.
140 scoped_ptr<AudioRendererAlgorithm> algorithm_; 137 scoped_ptr<AudioRendererAlgorithm> algorithm_;
141 138
142 base::Lock lock_; 139 base::Lock lock_;
143 140
144 // Simple state tracking variable. 141 // Simple state tracking variable.
145 enum State { 142 enum State {
(...skipping 17 matching lines...) Expand all
163 // The timestamp of the last frame (i.e. furthest in the future) buffered as 160 // The timestamp of the last frame (i.e. furthest in the future) buffered as
164 // well as the current time that takes current playback delay into account. 161 // well as the current time that takes current playback delay into account.
165 base::TimeDelta audio_time_buffered_; 162 base::TimeDelta audio_time_buffered_;
166 base::TimeDelta current_time_; 163 base::TimeDelta current_time_;
167 164
168 // Filter callbacks. 165 // Filter callbacks.
169 base::Closure pause_cb_; 166 base::Closure pause_cb_;
170 PipelineStatusCB seek_cb_; 167 PipelineStatusCB seek_cb_;
171 168
172 base::Closure underflow_cb_; 169 base::Closure underflow_cb_;
173
174 TimeCB time_cb_; 170 TimeCB time_cb_;
171 base::Closure ended_cb_;
172 base::Closure disabled_cb_;
175 173
176 base::TimeDelta seek_timestamp_; 174 base::TimeDelta seek_timestamp_;
177 175
178 uint32 bytes_per_frame_; 176 uint32 bytes_per_frame_;
179 177
180 // Used to calculate audio delay given bytes. 178 // Used to calculate audio delay given bytes.
181 uint32 bytes_per_second_; 179 uint32 bytes_per_second_;
182 180
183 // A flag that indicates this filter is called to stop. 181 // A flag that indicates this filter is called to stop.
184 bool stopped_; 182 bool stopped_;
(...skipping 25 matching lines...) Expand all
210 bool underflow_disabled_; 208 bool underflow_disabled_;
211 209
212 AudioDecoder::ReadCB read_cb_; 210 AudioDecoder::ReadCB read_cb_;
213 211
214 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 212 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
215 }; 213 };
216 214
217 } // namespace media 215 } // namespace media
218 216
219 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 217 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698