| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 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 // AudioRenderer implementation. | 43 // AudioRenderer implementation. |
| 44 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, | 44 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
| 45 const AudioDecoderList& decoders, |
| 45 const PipelineStatusCB& init_cb, | 46 const PipelineStatusCB& init_cb, |
| 47 const StatisticsCB& statistics_cb, |
| 46 const base::Closure& underflow_cb, | 48 const base::Closure& underflow_cb, |
| 47 const TimeCB& time_cb, | 49 const TimeCB& time_cb, |
| 48 const base::Closure& ended_cb, | 50 const base::Closure& ended_cb, |
| 49 const base::Closure& disabled_cb, | 51 const base::Closure& disabled_cb, |
| 50 const PipelineStatusCB& error_cb) OVERRIDE; | 52 const PipelineStatusCB& error_cb) OVERRIDE; |
| 51 virtual void Play(const base::Closure& callback) OVERRIDE; | 53 virtual void Play(const base::Closure& callback) OVERRIDE; |
| 52 virtual void Pause(const base::Closure& callback) OVERRIDE; | 54 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| 53 virtual void Flush(const base::Closure& callback) OVERRIDE; | 55 virtual void Flush(const base::Closure& callback) OVERRIDE; |
| 54 virtual void Stop(const base::Closure& callback) OVERRIDE; | 56 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 55 virtual void SetPlaybackRate(float rate) OVERRIDE; | 57 virtual void SetPlaybackRate(float rate) OVERRIDE; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // increments |pending_reads_|. | 129 // increments |pending_reads_|. |
| 128 // | 130 // |
| 129 // Safe to call from any thread. | 131 // Safe to call from any thread. |
| 130 void ScheduleRead_Locked(); | 132 void ScheduleRead_Locked(); |
| 131 | 133 |
| 132 // Returns true if the data in the buffer is all before | 134 // Returns true if the data in the buffer is all before |
| 133 // |preroll_timestamp_|. This can only return true while | 135 // |preroll_timestamp_|. This can only return true while |
| 134 // in the kPrerolling state. | 136 // in the kPrerolling state. |
| 135 bool IsBeforePrerollTime(const scoped_refptr<Buffer>& buffer); | 137 bool IsBeforePrerollTime(const scoped_refptr<Buffer>& buffer); |
| 136 | 138 |
| 139 // Pops the front of |decoders|, assigns it to |decoder_| and then |
| 140 // calls initialize on the new decoder. |
| 141 void InitializeNextDecoder(const scoped_refptr<DemuxerStream>& demuxer_stream, |
| 142 scoped_ptr<AudioDecoderList> decoders); |
| 143 |
| 144 // Called when |decoder_| initialization completes. |
| 145 // |demuxer_stream| & |decoders| are used if initialization failed and |
| 146 // InitializeNextDecoder() needs to be called again. |
| 147 void OnDecoderInitDone(const scoped_refptr<DemuxerStream>& demuxer_stream, |
| 148 scoped_ptr<AudioDecoderList> decoders, |
| 149 PipelineStatus status); |
| 150 |
| 137 // Audio decoder. | 151 // Audio decoder. |
| 138 scoped_refptr<AudioDecoder> decoder_; | 152 scoped_refptr<AudioDecoder> decoder_; |
| 139 | 153 |
| 140 // Algorithm for scaling audio. | 154 // Algorithm for scaling audio. |
| 141 scoped_ptr<AudioRendererAlgorithm> algorithm_; | 155 scoped_ptr<AudioRendererAlgorithm> algorithm_; |
| 142 | 156 |
| 143 base::Lock lock_; | 157 base::Lock lock_; |
| 144 | 158 |
| 145 // Simple state tracking variable. | 159 // Simple state tracking variable. |
| 146 enum State { | 160 enum State { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 159 | 173 |
| 160 // Keeps track of whether we received and rendered the end of stream buffer. | 174 // Keeps track of whether we received and rendered the end of stream buffer. |
| 161 bool received_end_of_stream_; | 175 bool received_end_of_stream_; |
| 162 bool rendered_end_of_stream_; | 176 bool rendered_end_of_stream_; |
| 163 | 177 |
| 164 // The timestamp of the last frame (i.e. furthest in the future) buffered as | 178 // The timestamp of the last frame (i.e. furthest in the future) buffered as |
| 165 // well as the current time that takes current playback delay into account. | 179 // well as the current time that takes current playback delay into account. |
| 166 base::TimeDelta audio_time_buffered_; | 180 base::TimeDelta audio_time_buffered_; |
| 167 base::TimeDelta current_time_; | 181 base::TimeDelta current_time_; |
| 168 | 182 |
| 183 PipelineStatusCB init_cb_; |
| 184 StatisticsCB statistics_cb_; |
| 185 |
| 169 // Filter callbacks. | 186 // Filter callbacks. |
| 170 base::Closure pause_cb_; | 187 base::Closure pause_cb_; |
| 171 PipelineStatusCB preroll_cb_; | 188 PipelineStatusCB preroll_cb_; |
| 172 | 189 |
| 173 base::Closure underflow_cb_; | 190 base::Closure underflow_cb_; |
| 174 TimeCB time_cb_; | 191 TimeCB time_cb_; |
| 175 base::Closure ended_cb_; | 192 base::Closure ended_cb_; |
| 176 base::Closure disabled_cb_; | 193 base::Closure disabled_cb_; |
| 177 PipelineStatusCB error_cb_; | 194 PipelineStatusCB error_cb_; |
| 178 | 195 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // True if the renderer receives a buffer with kAborted status during preroll, | 232 // True if the renderer receives a buffer with kAborted status during preroll, |
| 216 // false otherwise. This flag is cleared on the next Preroll() call. | 233 // false otherwise. This flag is cleared on the next Preroll() call. |
| 217 bool preroll_aborted_; | 234 bool preroll_aborted_; |
| 218 | 235 |
| 219 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 236 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
| 220 }; | 237 }; |
| 221 | 238 |
| 222 } // namespace media | 239 } // namespace media |
| 223 | 240 |
| 224 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 241 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
| OLD | NEW |