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 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 #include <deque> | 23 #include <deque> |
24 | 24 |
25 #include "base/gtest_prod_util.h" | 25 #include "base/gtest_prod_util.h" |
26 #include "base/synchronization/lock.h" | 26 #include "base/synchronization/lock.h" |
27 #include "base/threading/thread_checker.h" | 27 #include "base/threading/thread_checker.h" |
28 #include "media/base/audio_decoder.h" | 28 #include "media/base/audio_decoder.h" |
29 #include "media/base/audio_renderer.h" | 29 #include "media/base/audio_renderer.h" |
30 #include "media/base/audio_renderer_sink.h" | 30 #include "media/base/audio_renderer_sink.h" |
31 #include "media/base/buffers.h" | 31 #include "media/base/buffers.h" |
32 #include "media/base/decryptor.h" | |
32 #include "media/filters/audio_renderer_algorithm.h" | 33 #include "media/filters/audio_renderer_algorithm.h" |
33 | 34 |
34 namespace media { | 35 namespace media { |
35 | 36 |
37 class AudioDecoderFactory; | |
36 class AudioSplicer; | 38 class AudioSplicer; |
39 class DecryptingDemuxerStream; | |
37 | 40 |
38 class MEDIA_EXPORT AudioRendererImpl | 41 class MEDIA_EXPORT AudioRendererImpl |
39 : public AudioRenderer, | 42 : public AudioRenderer, |
40 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback) { | 43 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { |
41 public: | 44 public: |
42 // Methods called on Render thread ------------------------------------------ | 45 // Methods called on Render thread ------------------------------------------ |
43 // An AudioRendererSink is used as the destination for the rendered audio. | 46 // An AudioRendererSink is used as the destination for the rendered audio. |
44 explicit AudioRendererImpl(media::AudioRendererSink* sink); | 47 explicit AudioRendererImpl(AudioRendererSink* sink); |
45 | 48 |
46 // Methods called on pipeline thread ---------------------------------------- | 49 // Methods called on pipeline thread ---------------------------------------- |
47 // AudioRenderer implementation. | 50 // AudioRenderer implementation. |
48 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 51 virtual void Initialize( |
49 const AudioDecoderList& decoders, | 52 const scoped_refptr<DemuxerStream>& stream, |
50 const PipelineStatusCB& init_cb, | 53 const AudioDecoderList& decoders, |
51 const StatisticsCB& statistics_cb, | 54 const RequestDecryptorNotificationCB& request_decryptor_notification_cb, |
52 const base::Closure& underflow_cb, | 55 const PipelineStatusCB& init_cb, |
53 const TimeCB& time_cb, | 56 const StatisticsCB& statistics_cb, |
54 const base::Closure& ended_cb, | 57 const base::Closure& underflow_cb, |
55 const base::Closure& disabled_cb, | 58 const TimeCB& time_cb, |
56 const PipelineStatusCB& error_cb) OVERRIDE; | 59 const base::Closure& ended_cb, |
60 const base::Closure& disabled_cb, | |
61 const PipelineStatusCB& error_cb) OVERRIDE; | |
57 virtual void Play(const base::Closure& callback) OVERRIDE; | 62 virtual void Play(const base::Closure& callback) OVERRIDE; |
58 virtual void Pause(const base::Closure& callback) OVERRIDE; | 63 virtual void Pause(const base::Closure& callback) OVERRIDE; |
59 virtual void Flush(const base::Closure& callback) OVERRIDE; | 64 virtual void Flush(const base::Closure& callback) OVERRIDE; |
60 virtual void Stop(const base::Closure& callback) OVERRIDE; | 65 virtual void Stop(const base::Closure& callback) OVERRIDE; |
61 virtual void SetPlaybackRate(float rate) OVERRIDE; | 66 virtual void SetPlaybackRate(float rate) OVERRIDE; |
62 virtual void Preroll(base::TimeDelta time, | 67 virtual void Preroll(base::TimeDelta time, |
63 const PipelineStatusCB& cb) OVERRIDE; | 68 const PipelineStatusCB& cb) OVERRIDE; |
64 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; | 69 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; |
65 virtual void SetVolume(float volume) OVERRIDE; | 70 virtual void SetVolume(float volume) OVERRIDE; |
66 | 71 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 bool IsBeforePrerollTime(const scoped_refptr<Buffer>& buffer); | 144 bool IsBeforePrerollTime(const scoped_refptr<Buffer>& buffer); |
140 | 145 |
141 // Pops the front of |decoders|, assigns it to |decoder_| and then | 146 // Pops the front of |decoders|, assigns it to |decoder_| and then |
142 // calls initialize on the new decoder. | 147 // calls initialize on the new decoder. |
143 void InitializeNextDecoder(const scoped_refptr<DemuxerStream>& demuxer_stream, | 148 void InitializeNextDecoder(const scoped_refptr<DemuxerStream>& demuxer_stream, |
144 scoped_ptr<AudioDecoderList> decoders); | 149 scoped_ptr<AudioDecoderList> decoders); |
145 | 150 |
146 // Called when |decoder_| initialization completes. | 151 // Called when |decoder_| initialization completes. |
147 // |demuxer_stream| & |decoders| are used if initialization failed and | 152 // |demuxer_stream| & |decoders| are used if initialization failed and |
148 // InitializeNextDecoder() needs to be called again. | 153 // InitializeNextDecoder() needs to be called again. |
149 void OnDecoderInitDone(const scoped_refptr<DemuxerStream>& demuxer_stream, | 154 void OnDecoderInitDone( |
150 scoped_ptr<AudioDecoderList> decoders, | 155 const scoped_refptr<AudioDecoder>& audio_decoder, |
151 PipelineStatus status); | 156 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream); |
152 | 157 |
153 // Audio decoder. | 158 scoped_ptr<AudioDecoderFactory> factory_; |
ddorwin
2012/12/11 05:13:34
decoder_factory_
xhwang
2012/12/11 19:43:04
Will do.
xhwang
2012/12/12 23:43:28
Done.
| |
154 scoped_refptr<AudioDecoder> decoder_; | 159 scoped_refptr<AudioDecoder> decoder_; |
160 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; | |
ddorwin
2012/12/11 05:13:34
Maybe explain when this is populated/valid.
xhwang
2012/12/11 19:43:04
Will add comment.
xhwang
2012/12/12 23:43:28
Done.
| |
155 | 161 |
156 scoped_ptr<AudioSplicer> splicer_; | 162 scoped_ptr<AudioSplicer> splicer_; |
157 | 163 |
158 // The sink (destination) for rendered audio. |sink_| must only be accessed | 164 // The sink (destination) for rendered audio. |sink_| must only be accessed |
159 // on the pipeline thread (verify with |pipeline_thread_checker_|). |sink_| | 165 // on the pipeline thread (verify with |pipeline_thread_checker_|). |sink_| |
160 // must never be called under |lock_| or the 3-way thread bridge between the | 166 // must never be called under |lock_| or the 3-way thread bridge between the |
161 // audio, pipeline, and decoder threads may deadlock. | 167 // audio, pipeline, and decoder threads may deadlock. |
162 scoped_refptr<media::AudioRendererSink> sink_; | 168 scoped_refptr<media::AudioRendererSink> sink_; |
163 | 169 |
164 // Ensures certain methods are always called on the pipeline thread. | 170 // Ensures certain methods are always called on the pipeline thread. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 // Variables used only on the audio thread. --------------------------------- | 248 // Variables used only on the audio thread. --------------------------------- |
243 int actual_frames_per_buffer_; | 249 int actual_frames_per_buffer_; |
244 scoped_array<uint8> audio_buffer_; | 250 scoped_array<uint8> audio_buffer_; |
245 | 251 |
246 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 252 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
247 }; | 253 }; |
248 | 254 |
249 } // namespace media | 255 } // namespace media |
250 | 256 |
251 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 257 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |