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 // 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 11 matching lines...) Expand all Loading... |
22 #include <deque> | 22 #include <deque> |
23 | 23 |
24 #include "base/gtest_prod_util.h" | 24 #include "base/gtest_prod_util.h" |
25 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
26 #include "base/memory/weak_ptr.h" | 26 #include "base/memory/weak_ptr.h" |
27 #include "base/synchronization/lock.h" | 27 #include "base/synchronization/lock.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/decryptor.h" | 31 #include "media/base/decryptor.h" |
| 32 #include "media/base/time_source.h" |
32 #include "media/filters/audio_renderer_algorithm.h" | 33 #include "media/filters/audio_renderer_algorithm.h" |
33 #include "media/filters/decoder_stream.h" | 34 #include "media/filters/decoder_stream.h" |
34 | 35 |
35 namespace base { | 36 namespace base { |
36 class SingleThreadTaskRunner; | 37 class SingleThreadTaskRunner; |
37 } | 38 } |
38 | 39 |
39 namespace media { | 40 namespace media { |
40 | 41 |
41 class AudioBufferConverter; | 42 class AudioBufferConverter; |
42 class AudioBus; | 43 class AudioBus; |
43 class AudioClock; | 44 class AudioClock; |
44 class AudioHardwareConfig; | 45 class AudioHardwareConfig; |
45 class AudioSplicer; | 46 class AudioSplicer; |
46 class DecryptingDemuxerStream; | 47 class DecryptingDemuxerStream; |
47 | 48 |
48 class MEDIA_EXPORT AudioRendererImpl | 49 class MEDIA_EXPORT AudioRendererImpl |
49 : public AudioRenderer, | 50 : public AudioRenderer, |
| 51 public TimeSource, |
50 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { | 52 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { |
51 public: | 53 public: |
52 // |task_runner| is the thread on which AudioRendererImpl will execute. | 54 // |task_runner| is the thread on which AudioRendererImpl will execute. |
53 // | 55 // |
54 // |sink| is used as the destination for the rendered audio. | 56 // |sink| is used as the destination for the rendered audio. |
55 // | 57 // |
56 // |decoders| contains the AudioDecoders to use when initializing. | 58 // |decoders| contains the AudioDecoders to use when initializing. |
57 // | 59 // |
58 // |set_decryptor_ready_cb| is fired when the audio decryptor is available | 60 // |set_decryptor_ready_cb| is fired when the audio decryptor is available |
59 // (only applicable if the stream is encrypted and we have a decryptor). | 61 // (only applicable if the stream is encrypted and we have a decryptor). |
60 AudioRendererImpl( | 62 AudioRendererImpl( |
61 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 63 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
62 AudioRendererSink* sink, | 64 AudioRendererSink* sink, |
63 ScopedVector<AudioDecoder> decoders, | 65 ScopedVector<AudioDecoder> decoders, |
64 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 66 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
65 AudioHardwareConfig* hardware_params); | 67 AudioHardwareConfig* hardware_params); |
66 virtual ~AudioRendererImpl(); | 68 virtual ~AudioRendererImpl(); |
67 | 69 |
| 70 // TimeSource implementation. |
| 71 virtual void StartTicking() OVERRIDE; |
| 72 virtual void StopTicking() OVERRIDE; |
| 73 virtual void SetPlaybackRate(float rate) OVERRIDE; |
| 74 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; |
| 75 virtual base::TimeDelta CurrentMediaTime() OVERRIDE; |
| 76 |
68 // AudioRenderer implementation. | 77 // AudioRenderer implementation. |
69 virtual void Initialize(DemuxerStream* stream, | 78 virtual void Initialize(DemuxerStream* stream, |
70 const PipelineStatusCB& init_cb, | 79 const PipelineStatusCB& init_cb, |
71 const StatisticsCB& statistics_cb, | 80 const StatisticsCB& statistics_cb, |
72 const TimeCB& time_cb, | 81 const TimeCB& time_cb, |
73 const BufferingStateCB& buffering_state_cb, | 82 const BufferingStateCB& buffering_state_cb, |
74 const base::Closure& ended_cb, | 83 const base::Closure& ended_cb, |
75 const PipelineStatusCB& error_cb) OVERRIDE; | 84 const PipelineStatusCB& error_cb) OVERRIDE; |
76 virtual void StartRendering() OVERRIDE; | 85 virtual TimeSource* GetTimeSource() OVERRIDE; |
77 virtual void StopRendering() OVERRIDE; | |
78 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; | |
79 virtual void Flush(const base::Closure& callback) OVERRIDE; | 86 virtual void Flush(const base::Closure& callback) OVERRIDE; |
80 virtual void Stop(const base::Closure& callback) OVERRIDE; | 87 virtual void Stop(const base::Closure& callback) OVERRIDE; |
81 virtual void SetPlaybackRate(float rate) OVERRIDE; | |
82 virtual void StartPlaying() OVERRIDE; | 88 virtual void StartPlaying() OVERRIDE; |
83 virtual void SetVolume(float volume) OVERRIDE; | 89 virtual void SetVolume(float volume) OVERRIDE; |
84 | 90 |
85 private: | 91 private: |
86 friend class AudioRendererImplTest; | 92 friend class AudioRendererImplTest; |
87 | 93 |
88 // Important detail: being in kPlaying doesn't imply that audio is being | 94 // Important detail: being in kPlaying doesn't imply that audio is being |
89 // rendered. Rather, it means that the renderer is ready to go. The actual | 95 // rendered. Rather, it means that the renderer is ready to go. The actual |
90 // rendering of audio is controlled via Start/StopRendering(). | 96 // rendering of audio is controlled via Start/StopRendering(). |
91 // | 97 // |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 255 |
250 // NOTE: Weak pointers must be invalidated before all other member variables. | 256 // NOTE: Weak pointers must be invalidated before all other member variables. |
251 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 257 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
252 | 258 |
253 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 259 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
254 }; | 260 }; |
255 | 261 |
256 } // namespace media | 262 } // namespace media |
257 | 263 |
258 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 264 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |