| 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 22 matching lines...) Expand all Loading... |
| 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 SetHost(AudioRendererHost* host) OVERRIDE; |
| 45 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, |
| 46 const PipelineStatusCB& init_cb, |
| 47 const base::Closure& underflow_cb, |
| 48 const TimeCB& time_cb) OVERRIDE; |
| 45 virtual void Play(const base::Closure& callback) OVERRIDE; | 49 virtual void Play(const base::Closure& callback) OVERRIDE; |
| 46 virtual void Pause(const base::Closure& callback) OVERRIDE; | 50 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| 47 virtual void Flush(const base::Closure& callback) OVERRIDE; | 51 virtual void Flush(const base::Closure& callback) OVERRIDE; |
| 48 virtual void Stop(const base::Closure& callback) OVERRIDE; | 52 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 49 virtual void SetPlaybackRate(float rate) OVERRIDE; | 53 virtual void SetPlaybackRate(float rate) OVERRIDE; |
| 50 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 54 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; | 55 virtual bool HasEnded() OVERRIDE; |
| 58 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; | 56 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; |
| 59 virtual void SetVolume(float volume) OVERRIDE; | 57 virtual void SetVolume(float volume) OVERRIDE; |
| 60 | 58 |
| 61 // Disables underflow support. When used, |state_| will never transition to | 59 // Disables underflow support. When used, |state_| will never transition to |
| 62 // kUnderflow resulting in Render calls that underflow returning 0 frames | 60 // kUnderflow resulting in Render calls that underflow returning 0 frames |
| 63 // instead of some number of silence frames. Must be called prior to | 61 // instead of some number of silence frames. Must be called prior to |
| 64 // Initialize(). | 62 // Initialize(). |
| 65 void DisableUnderflowForTesting(); | 63 void DisableUnderflowForTesting(); |
| 66 | 64 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // increments |pending_reads_|. | 122 // increments |pending_reads_|. |
| 125 // | 123 // |
| 126 // Safe to call from any thread. | 124 // Safe to call from any thread. |
| 127 void ScheduleRead_Locked(); | 125 void ScheduleRead_Locked(); |
| 128 | 126 |
| 129 // Returns true if the data in the buffer is all before | 127 // Returns true if the data in the buffer is all before |
| 130 // |seek_timestamp_|. This can only return true while | 128 // |seek_timestamp_|. This can only return true while |
| 131 // in the kSeeking state. | 129 // in the kSeeking state. |
| 132 bool IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer); | 130 bool IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer); |
| 133 | 131 |
| 134 FilterHost* host_; | 132 AudioRendererHost* host_; |
| 135 | 133 |
| 136 // Audio decoder. | 134 // Audio decoder. |
| 137 scoped_refptr<AudioDecoder> decoder_; | 135 scoped_refptr<AudioDecoder> decoder_; |
| 138 | 136 |
| 139 // Algorithm for scaling audio. | 137 // Algorithm for scaling audio. |
| 140 scoped_ptr<AudioRendererAlgorithm> algorithm_; | 138 scoped_ptr<AudioRendererAlgorithm> algorithm_; |
| 141 | 139 |
| 142 base::Lock lock_; | 140 base::Lock lock_; |
| 143 | 141 |
| 144 // Simple state tracking variable. | 142 // Simple state tracking variable. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_ |
| OLD | NEW |