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

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

Issue 380893002: Use base::TickClock in media::AudioRendererImpl instead of a callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove now_cb_ entirely Created 6 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 | « no previous file | 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const base::Closure& ended_cb, 73 const base::Closure& ended_cb,
74 const PipelineStatusCB& error_cb) OVERRIDE; 74 const PipelineStatusCB& error_cb) OVERRIDE;
75 virtual void StartRendering() OVERRIDE; 75 virtual void StartRendering() OVERRIDE;
76 virtual void StopRendering() OVERRIDE; 76 virtual void StopRendering() OVERRIDE;
77 virtual void Flush(const base::Closure& callback) OVERRIDE; 77 virtual void Flush(const base::Closure& callback) OVERRIDE;
78 virtual void Stop(const base::Closure& callback) OVERRIDE; 78 virtual void Stop(const base::Closure& callback) OVERRIDE;
79 virtual void SetPlaybackRate(float rate) OVERRIDE; 79 virtual void SetPlaybackRate(float rate) OVERRIDE;
80 virtual void StartPlayingFrom(base::TimeDelta timestamp) OVERRIDE; 80 virtual void StartPlayingFrom(base::TimeDelta timestamp) OVERRIDE;
81 virtual void SetVolume(float volume) OVERRIDE; 81 virtual void SetVolume(float volume) OVERRIDE;
82 82
83 // Allows injection of a custom time callback for non-realtime testing.
84 typedef base::Callback<base::TimeTicks()> NowCB;
85 void set_now_cb_for_testing(const NowCB& now_cb) {
86 now_cb_ = now_cb;
87 }
88
89 private: 83 private:
90 friend class AudioRendererImplTest; 84 friend class AudioRendererImplTest;
91 85
92 // Important detail: being in kPlaying doesn't imply that audio is being 86 // Important detail: being in kPlaying doesn't imply that audio is being
93 // rendered. Rather, it means that the renderer is ready to go. The actual 87 // rendered. Rather, it means that the renderer is ready to go. The actual
94 // rendering of audio is controlled via Start/StopRendering(). 88 // rendering of audio is controlled via Start/StopRendering().
95 // 89 //
96 // kUninitialized 90 // kUninitialized
97 // | Initialize() 91 // | Initialize()
98 // | 92 // |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // Callbacks provided during Initialize(). 208 // Callbacks provided during Initialize().
215 PipelineStatusCB init_cb_; 209 PipelineStatusCB init_cb_;
216 TimeCB time_cb_; 210 TimeCB time_cb_;
217 BufferingStateCB buffering_state_cb_; 211 BufferingStateCB buffering_state_cb_;
218 base::Closure ended_cb_; 212 base::Closure ended_cb_;
219 PipelineStatusCB error_cb_; 213 PipelineStatusCB error_cb_;
220 214
221 // Callback provided to Flush(). 215 // Callback provided to Flush().
222 base::Closure flush_cb_; 216 base::Closure flush_cb_;
223 217
224 // Typically calls base::TimeTicks::Now() but can be overridden by a test.
225 NowCB now_cb_;
226
227 // After Initialize() has completed, all variables below must be accessed 218 // After Initialize() has completed, all variables below must be accessed
228 // under |lock_|. ------------------------------------------------------------ 219 // under |lock_|. ------------------------------------------------------------
229 base::Lock lock_; 220 base::Lock lock_;
230 221
231 // Algorithm for scaling audio. 222 // Algorithm for scaling audio.
232 scoped_ptr<AudioRendererAlgorithm> algorithm_; 223 scoped_ptr<AudioRendererAlgorithm> algorithm_;
233 224
234 // Simple state tracking variable. 225 // Simple state tracking variable.
235 State state_; 226 State state_;
236 227
(...skipping 19 matching lines...) Expand all
256 247
257 // NOTE: Weak pointers must be invalidated before all other member variables. 248 // NOTE: Weak pointers must be invalidated before all other member variables.
258 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; 249 base::WeakPtrFactory<AudioRendererImpl> weak_factory_;
259 250
260 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 251 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
261 }; 252 };
262 253
263 } // namespace media 254 } // namespace media
264 255
265 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 256 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698