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

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

Issue 379343005: Introduce media::TimeSource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // |set_decryptor_ready_cb| is fired when the audio decryptor is available 57 // |set_decryptor_ready_cb| is fired when the audio decryptor is available
58 // (only applicable if the stream is encrypted and we have a decryptor). 58 // (only applicable if the stream is encrypted and we have a decryptor).
59 AudioRendererImpl( 59 AudioRendererImpl(
60 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 60 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
61 AudioRendererSink* sink, 61 AudioRendererSink* sink,
62 ScopedVector<AudioDecoder> decoders, 62 ScopedVector<AudioDecoder> decoders,
63 const SetDecryptorReadyCB& set_decryptor_ready_cb, 63 const SetDecryptorReadyCB& set_decryptor_ready_cb,
64 AudioHardwareConfig* hardware_params); 64 AudioHardwareConfig* hardware_params);
65 virtual ~AudioRendererImpl(); 65 virtual ~AudioRendererImpl();
66 66
67 // TimeSource implementation.
68 virtual void StartTicking() OVERRIDE;
69 virtual void StopTicking() OVERRIDE;
70 virtual void SetPlaybackRate(float rate) OVERRIDE;
71 virtual void SetMediaTimestamp(base::TimeDelta timestamp) OVERRIDE;
72 virtual base::TimeDelta CurrentMediaTimestamp() OVERRIDE;
73
67 // AudioRenderer implementation. 74 // AudioRenderer implementation.
68 virtual void Initialize(DemuxerStream* stream, 75 virtual void Initialize(DemuxerStream* stream,
69 const PipelineStatusCB& init_cb, 76 const PipelineStatusCB& init_cb,
70 const StatisticsCB& statistics_cb, 77 const StatisticsCB& statistics_cb,
71 const TimeCB& time_cb,
72 const BufferingStateCB& buffering_state_cb, 78 const BufferingStateCB& buffering_state_cb,
73 const base::Closure& ended_cb, 79 const base::Closure& ended_cb,
74 const PipelineStatusCB& error_cb) OVERRIDE; 80 const PipelineStatusCB& error_cb) OVERRIDE;
75 virtual void StartRendering() OVERRIDE;
76 virtual void StopRendering() OVERRIDE;
77 virtual void Flush(const base::Closure& callback) OVERRIDE; 81 virtual void Flush(const base::Closure& callback) OVERRIDE;
78 virtual void Stop(const base::Closure& callback) OVERRIDE; 82 virtual void Stop(const base::Closure& callback) OVERRIDE;
79 virtual void SetPlaybackRate(float rate) OVERRIDE; 83 virtual void StartPlaying() OVERRIDE;
80 virtual void StartPlayingFrom(base::TimeDelta timestamp) OVERRIDE;
81 virtual void SetVolume(float volume) OVERRIDE; 84 virtual void SetVolume(float volume) OVERRIDE;
82 85
83 private: 86 private:
84 friend class AudioRendererImplTest; 87 friend class AudioRendererImplTest;
85 88
86 // Important detail: being in kPlaying doesn't imply that audio is being 89 // Important detail: being in kPlaying doesn't imply that audio is being
87 // rendered. Rather, it means that the renderer is ready to go. The actual 90 // rendered. Rather, it means that the renderer is ready to go. The actual
88 // rendering of audio is controlled via Start/StopRendering(). 91 // rendering of audio is controlled via Start/StopRendering().
89 // 92 //
90 // kUninitialized 93 // kUninitialized
91 // | Initialize() 94 // | Initialize()
92 // | 95 // |
93 // V 96 // V
94 // kInitializing 97 // kInitializing
95 // | Decoders initialized 98 // | Decoders initialized
96 // | 99 // |
97 // V Decoders reset 100 // V Decoders reset
98 // kFlushed <------------------ kFlushing 101 // kFlushed <------------------ kFlushing
99 // | StartPlayingFrom() ^ 102 // | StartPlaying() ^
100 // | | 103 // | |
101 // | | Flush() 104 // | | Flush()
102 // `---------> kPlaying --------' 105 // `---------> kPlaying --------'
103 enum State { 106 enum State {
104 kUninitialized, 107 kUninitialized,
105 kInitializing, 108 kInitializing,
106 kFlushing, 109 kFlushing,
107 kFlushed, 110 kFlushed,
108 kPlaying, 111 kPlaying,
109 kStopped, 112 kStopped,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 250
248 // NOTE: Weak pointers must be invalidated before all other member variables. 251 // NOTE: Weak pointers must be invalidated before all other member variables.
249 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; 252 base::WeakPtrFactory<AudioRendererImpl> weak_factory_;
250 253
251 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 254 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
252 }; 255 };
253 256
254 } // namespace media 257 } // namespace media
255 258
256 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 259 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698