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

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

Issue 16823003: Replace erroneous use of base::Time with base::TimeTicks throughout media code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/PresubmitPromptWarning/PresubmitPromptOrNotify/ Created 7 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 | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline_unittest.cc ('k') | media/filters/audio_renderer_impl.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 // 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 // Where the object is created. 9 // Where the object is created.
10 // 2. Media thread (provided via constructor) 10 // 2. Media thread (provided via constructor)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 virtual void ResumeAfterUnderflow() OVERRIDE; 81 virtual void ResumeAfterUnderflow() OVERRIDE;
82 virtual void SetVolume(float volume) OVERRIDE; 82 virtual void SetVolume(float volume) OVERRIDE;
83 83
84 // Disables underflow support. When used, |state_| will never transition to 84 // Disables underflow support. When used, |state_| will never transition to
85 // kUnderflow resulting in Render calls that underflow returning 0 frames 85 // kUnderflow resulting in Render calls that underflow returning 0 frames
86 // instead of some number of silence frames. Must be called prior to 86 // instead of some number of silence frames. Must be called prior to
87 // Initialize(). 87 // Initialize().
88 void DisableUnderflowForTesting(); 88 void DisableUnderflowForTesting();
89 89
90 // Allows injection of a custom time callback for non-realtime testing. 90 // Allows injection of a custom time callback for non-realtime testing.
91 typedef base::Callback<base::Time()> NowCB; 91 typedef base::Callback<base::TimeTicks()> NowCB;
92 void set_now_cb_for_testing(const NowCB& now_cb) { 92 void set_now_cb_for_testing(const NowCB& now_cb) {
93 now_cb_ = now_cb; 93 now_cb_ = now_cb;
94 } 94 }
95 95
96 private: 96 private:
97 friend class AudioRendererImplTest; 97 friend class AudioRendererImplTest;
98 98
99 // Callback from the audio decoder delivering decoded audio samples. 99 // Callback from the audio decoder delivering decoded audio samples.
100 void DecodedAudioReady(AudioDecoder::Status status, 100 void DecodedAudioReady(AudioDecoder::Status status,
101 const scoped_refptr<DataBuffer>& buffer); 101 const scoped_refptr<DataBuffer>& buffer);
(...skipping 22 matching lines...) Expand all
124 // this case |playback_delay| should be used to indicate when in the future 124 // this case |playback_delay| should be used to indicate when in the future
125 // should the filled buffer be played. 125 // should the filled buffer be played.
126 // 126 //
127 // Safe to call on any thread. 127 // Safe to call on any thread.
128 uint32 FillBuffer(uint8* dest, 128 uint32 FillBuffer(uint8* dest,
129 uint32 requested_frames, 129 uint32 requested_frames,
130 int audio_delay_milliseconds); 130 int audio_delay_milliseconds);
131 131
132 // Estimate earliest time when current buffer can stop playing. 132 // Estimate earliest time when current buffer can stop playing.
133 void UpdateEarliestEndTime_Locked(int frames_filled, 133 void UpdateEarliestEndTime_Locked(int frames_filled,
134 base::TimeDelta playback_delay, 134 const base::TimeDelta& playback_delay,
135 base::Time time_now); 135 const base::TimeTicks& time_now);
136 136
137 void DoPlay(); 137 void DoPlay();
138 void DoPause(); 138 void DoPause();
139 139
140 // AudioRendererSink::RenderCallback implementation. 140 // AudioRendererSink::RenderCallback implementation.
141 // 141 //
142 // NOTE: These are called on the audio callback thread! 142 // NOTE: These are called on the audio callback thread!
143 virtual int Render(AudioBus* audio_bus, 143 virtual int Render(AudioBus* audio_bus,
144 int audio_delay_milliseconds) OVERRIDE; 144 int audio_delay_milliseconds) OVERRIDE;
145 virtual void OnRenderError() OVERRIDE; 145 virtual void OnRenderError() OVERRIDE;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 base::Closure ended_cb_; 196 base::Closure ended_cb_;
197 base::Closure disabled_cb_; 197 base::Closure disabled_cb_;
198 PipelineStatusCB error_cb_; 198 PipelineStatusCB error_cb_;
199 199
200 // Callback provided to Pause(). 200 // Callback provided to Pause().
201 base::Closure pause_cb_; 201 base::Closure pause_cb_;
202 202
203 // Callback provided to Preroll(). 203 // Callback provided to Preroll().
204 PipelineStatusCB preroll_cb_; 204 PipelineStatusCB preroll_cb_;
205 205
206 // Typically calls base::Time::Now() but can be overridden by a test. 206 // Typically calls base::TimeTicks::Now() but can be overridden by a test.
207 NowCB now_cb_; 207 NowCB now_cb_;
208 208
209 // After Initialize() has completed, all variables below must be accessed 209 // After Initialize() has completed, all variables below must be accessed
210 // under |lock_|. ------------------------------------------------------------ 210 // under |lock_|. ------------------------------------------------------------
211 base::Lock lock_; 211 base::Lock lock_;
212 212
213 // Algorithm for scaling audio. 213 // Algorithm for scaling audio.
214 scoped_ptr<AudioRendererAlgorithm> algorithm_; 214 scoped_ptr<AudioRendererAlgorithm> algorithm_;
215 215
216 // Simple state tracking variable. 216 // Simple state tracking variable.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // As a result we cannot use it to find when stream ends. If we just ignore 249 // As a result we cannot use it to find when stream ends. If we just ignore
250 // buffered data we will notify host that stream ended before it is actually 250 // buffered data we will notify host that stream ended before it is actually
251 // did so, I've seen it done ~140ms too early when playing ~150ms file. 251 // did so, I've seen it done ~140ms too early when playing ~150ms file.
252 // 252 //
253 // Instead of trying to invent OS-specific solution for each and every OS we 253 // Instead of trying to invent OS-specific solution for each and every OS we
254 // are supporting, use simple workaround: every time we fill the buffer we 254 // are supporting, use simple workaround: every time we fill the buffer we
255 // remember when it should stop playing, and do not assume that buffer is 255 // remember when it should stop playing, and do not assume that buffer is
256 // empty till that time. Workaround is not bulletproof, as we don't exactly 256 // empty till that time. Workaround is not bulletproof, as we don't exactly
257 // know when that particular data would start playing, but it is much better 257 // know when that particular data would start playing, but it is much better
258 // than nothing. 258 // than nothing.
259 base::Time earliest_end_time_; 259 base::TimeTicks earliest_end_time_;
260 size_t total_frames_filled_; 260 size_t total_frames_filled_;
261 261
262 bool underflow_disabled_; 262 bool underflow_disabled_;
263 bool increase_preroll_on_underflow_; 263 bool increase_preroll_on_underflow_;
264 264
265 // True if the renderer receives a buffer with kAborted status during preroll, 265 // True if the renderer receives a buffer with kAborted status during preroll,
266 // false otherwise. This flag is cleared on the next Preroll() call. 266 // false otherwise. This flag is cleared on the next Preroll() call.
267 bool preroll_aborted_; 267 bool preroll_aborted_;
268 268
269 // End variables which must be accessed under |lock_|. ---------------------- 269 // End variables which must be accessed under |lock_|. ----------------------
270 270
271 // Variables used only on the audio thread. --------------------------------- 271 // Variables used only on the audio thread. ---------------------------------
272 int actual_frames_per_buffer_; 272 int actual_frames_per_buffer_;
273 scoped_ptr<uint8[]> audio_buffer_; 273 scoped_ptr<uint8[]> audio_buffer_;
274 274
275 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 275 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
276 }; 276 };
277 277
278 } // namespace media 278 } // namespace media
279 279
280 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 280 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/base/pipeline_unittest.cc ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698