| 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 namespace media { | 32 namespace media { |
| 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 virtual ~AudioRendererImpl(); | |
| 42 | 41 |
| 43 // Methods called on pipeline thread ---------------------------------------- | 42 // Methods called on pipeline thread ---------------------------------------- |
| 44 // Filter implementation. | 43 // Filter implementation. |
| 45 virtual void Play(const base::Closure& callback) OVERRIDE; | 44 virtual void Play(const base::Closure& callback) OVERRIDE; |
| 46 virtual void Pause(const base::Closure& callback) OVERRIDE; | 45 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| 47 virtual void Flush(const base::Closure& callback) OVERRIDE; | 46 virtual void Flush(const base::Closure& callback) OVERRIDE; |
| 48 virtual void Stop(const base::Closure& callback) OVERRIDE; | 47 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 49 virtual void SetPlaybackRate(float rate) OVERRIDE; | 48 virtual void SetPlaybackRate(float rate) OVERRIDE; |
| 50 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 49 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
| 51 | 50 |
| 52 // AudioRenderer implementation. | 51 // AudioRenderer implementation. |
| 53 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, | 52 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, |
| 54 const PipelineStatusCB& init_cb, | 53 const PipelineStatusCB& init_cb, |
| 55 const base::Closure& underflow_cb, | 54 const base::Closure& underflow_cb, |
| 56 const TimeCB& time_cb) OVERRIDE; | 55 const TimeCB& time_cb) OVERRIDE; |
| 57 virtual bool HasEnded() OVERRIDE; | 56 virtual bool HasEnded() OVERRIDE; |
| 58 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; | 57 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; |
| 59 virtual void SetVolume(float volume) OVERRIDE; | 58 virtual void SetVolume(float volume) OVERRIDE; |
| 60 | 59 |
| 61 private: | 60 private: |
| 62 friend class AudioRendererImplTest; | 61 friend class AudioRendererImplTest; |
| 63 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, EndOfStream); | 62 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, EndOfStream); |
| 64 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, Underflow_EndOfStream); | 63 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, Underflow_EndOfStream); |
| 65 | 64 |
| 65 virtual ~AudioRendererImpl(); |
| 66 |
| 66 // Callback from the audio decoder delivering decoded audio samples. | 67 // Callback from the audio decoder delivering decoded audio samples. |
| 67 void DecodedAudioReady(scoped_refptr<Buffer> buffer); | 68 void DecodedAudioReady(scoped_refptr<Buffer> buffer); |
| 68 | 69 |
| 69 // Fills the given buffer with audio data by delegating to its |algorithm_|. | 70 // Fills the given buffer with audio data by delegating to its |algorithm_|. |
| 70 // FillBuffer() also takes care of updating the clock. Returns the number of | 71 // FillBuffer() also takes care of updating the clock. Returns the number of |
| 71 // frames copied into |dest|, which may be less than or equal to | 72 // frames copied into |dest|, which may be less than or equal to |
| 72 // |requested_frames|. | 73 // |requested_frames|. |
| 73 // | 74 // |
| 74 // If this method returns fewer frames than |requested_frames|, it could | 75 // If this method returns fewer frames than |requested_frames|, it could |
| 75 // be a sign that the pipeline is stalled or unable to stream the data fast | 76 // be a sign that the pipeline is stalled or unable to stream the data fast |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 AudioParameters audio_parameters_; | 203 AudioParameters audio_parameters_; |
| 203 | 204 |
| 204 AudioDecoder::ReadCB read_cb_; | 205 AudioDecoder::ReadCB read_cb_; |
| 205 | 206 |
| 206 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 207 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
| 207 }; | 208 }; |
| 208 | 209 |
| 209 } // namespace media | 210 } // namespace media |
| 210 | 211 |
| 211 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 212 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
| OLD | NEW |