| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "base/macros.h" | 27 #include "base/macros.h" |
| 28 #include "base/memory/weak_ptr.h" | 28 #include "base/memory/weak_ptr.h" |
| 29 #include "base/power_monitor/power_observer.h" | 29 #include "base/power_monitor/power_observer.h" |
| 30 #include "base/synchronization/lock.h" | 30 #include "base/synchronization/lock.h" |
| 31 #include "media/base/audio_decoder.h" | 31 #include "media/base/audio_decoder.h" |
| 32 #include "media/base/audio_renderer.h" | 32 #include "media/base/audio_renderer.h" |
| 33 #include "media/base/audio_renderer_sink.h" | 33 #include "media/base/audio_renderer_sink.h" |
| 34 #include "media/base/decryptor.h" | 34 #include "media/base/decryptor.h" |
| 35 #include "media/base/media_log.h" | 35 #include "media/base/media_log.h" |
| 36 #include "media/base/stream_position.h" |
| 36 #include "media/base/time_source.h" | 37 #include "media/base/time_source.h" |
| 37 #include "media/filters/audio_renderer_algorithm.h" | 38 #include "media/filters/audio_renderer_algorithm.h" |
| 38 #include "media/filters/decoder_stream.h" | 39 #include "media/filters/decoder_stream.h" |
| 39 | 40 |
| 40 namespace base { | 41 namespace base { |
| 41 class SingleThreadTaskRunner; | 42 class SingleThreadTaskRunner; |
| 42 class TickClock; | 43 class TickClock; |
| 43 } | 44 } |
| 44 | 45 |
| 45 namespace media { | 46 namespace media { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 AudioRendererSink* sink, | 67 AudioRendererSink* sink, |
| 67 ScopedVector<AudioDecoder> decoders, | 68 ScopedVector<AudioDecoder> decoders, |
| 68 const scoped_refptr<MediaLog>& media_log); | 69 const scoped_refptr<MediaLog>& media_log); |
| 69 ~AudioRendererImpl() override; | 70 ~AudioRendererImpl() override; |
| 70 | 71 |
| 71 // TimeSource implementation. | 72 // TimeSource implementation. |
| 72 void StartTicking() override; | 73 void StartTicking() override; |
| 73 void StopTicking() override; | 74 void StopTicking() override; |
| 74 void SetPlaybackRate(double rate) override; | 75 void SetPlaybackRate(double rate) override; |
| 75 void SetMediaTime(base::TimeDelta time) override; | 76 void SetMediaTime(base::TimeDelta time) override; |
| 77 void SetMediaTime_Locked(base::TimeDelta time); |
| 76 base::TimeDelta CurrentMediaTime() override; | 78 base::TimeDelta CurrentMediaTime() override; |
| 77 bool GetWallClockTimes( | 79 bool GetWallClockTimes( |
| 78 const std::vector<base::TimeDelta>& media_timestamps, | 80 const std::vector<base::TimeDelta>& media_timestamps, |
| 79 std::vector<base::TimeTicks>* wall_clock_times) override; | 81 std::vector<base::TimeTicks>* wall_clock_times) override; |
| 80 | 82 |
| 81 // AudioRenderer implementation. | 83 // AudioRenderer implementation. |
| 82 void Initialize(DemuxerStream* stream, | 84 void Initialize(DemuxerStream* stream, |
| 83 CdmContext* cdm_context, | 85 CdmContext* cdm_context, |
| 84 RendererClient* client, | 86 RendererClient* client, |
| 85 const PipelineStatusCB& init_cb) override; | 87 const PipelineStatusCB& init_cb) override; |
| 86 TimeSource* GetTimeSource() override; | 88 TimeSource* GetTimeSource() override; |
| 87 void Flush(const base::Closure& callback) override; | 89 void Flush(const base::Closure& callback) override; |
| 88 void StartPlaying() override; | 90 void StartPlayingFrom(StreamPosition position) override; |
| 89 void SetVolume(float volume) override; | 91 void SetVolume(float volume) override; |
| 90 | 92 |
| 91 // base::PowerObserver implementation. | 93 // base::PowerObserver implementation. |
| 92 void OnSuspend() override; | 94 void OnSuspend() override; |
| 93 void OnResume() override; | 95 void OnResume() override; |
| 94 | 96 |
| 95 private: | 97 private: |
| 96 friend class AudioRendererImplTest; | 98 friend class AudioRendererImplTest; |
| 97 | 99 |
| 98 // Important detail: being in kPlaying doesn't imply that audio is being | 100 // Important detail: being in kPlaying doesn't imply that audio is being |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 base::TimeTicks stop_rendering_time_; | 285 base::TimeTicks stop_rendering_time_; |
| 284 | 286 |
| 285 // Set upon receipt of the first decoded buffer after a StartPlayingFrom(). | 287 // Set upon receipt of the first decoded buffer after a StartPlayingFrom(). |
| 286 // Used to determine how long to delay playback. | 288 // Used to determine how long to delay playback. |
| 287 base::TimeDelta first_packet_timestamp_; | 289 base::TimeDelta first_packet_timestamp_; |
| 288 | 290 |
| 289 // Set by OnSuspend() and OnResume() to indicate when the system is about to | 291 // Set by OnSuspend() and OnResume() to indicate when the system is about to |
| 290 // suspend/is suspended and when it resumes. | 292 // suspend/is suspended and when it resumes. |
| 291 bool is_suspending_; | 293 bool is_suspending_; |
| 292 | 294 |
| 295 bool start_rendering_from_first_frame_ = false; |
| 296 |
| 293 // End variables which must be accessed under |lock_|. ---------------------- | 297 // End variables which must be accessed under |lock_|. ---------------------- |
| 294 | 298 |
| 295 // NOTE: Weak pointers must be invalidated before all other member variables. | 299 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 296 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 300 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
| 297 | 301 |
| 298 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 302 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
| 299 }; | 303 }; |
| 300 | 304 |
| 301 } // namespace media | 305 } // namespace media |
| 302 | 306 |
| 303 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ | 307 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ |
| OLD | NEW |