| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 AudioRendererImpl( | 63 AudioRendererImpl( |
| 64 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 64 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 65 AudioRendererSink* sink, | 65 AudioRendererSink* sink, |
| 66 ScopedVector<AudioDecoder> decoders, | 66 ScopedVector<AudioDecoder> decoders, |
| 67 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 67 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 68 const AudioHardwareConfig& hardware_params, | 68 const AudioHardwareConfig& hardware_params, |
| 69 const scoped_refptr<MediaLog>& media_log); | 69 const scoped_refptr<MediaLog>& media_log); |
| 70 virtual ~AudioRendererImpl(); | 70 virtual ~AudioRendererImpl(); |
| 71 | 71 |
| 72 // TimeSource implementation. | 72 // TimeSource implementation. |
| 73 virtual void StartTicking() OVERRIDE; | 73 virtual void StartTicking() override; |
| 74 virtual void StopTicking() OVERRIDE; | 74 virtual void StopTicking() override; |
| 75 virtual void SetPlaybackRate(float rate) OVERRIDE; | 75 virtual void SetPlaybackRate(float rate) override; |
| 76 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; | 76 virtual void SetMediaTime(base::TimeDelta time) override; |
| 77 virtual base::TimeDelta CurrentMediaTime() OVERRIDE; | 77 virtual base::TimeDelta CurrentMediaTime() override; |
| 78 virtual base::TimeDelta CurrentMediaTimeForSyncingVideo() OVERRIDE; | 78 virtual base::TimeDelta CurrentMediaTimeForSyncingVideo() override; |
| 79 | 79 |
| 80 // AudioRenderer implementation. | 80 // AudioRenderer implementation. |
| 81 virtual void Initialize(DemuxerStream* stream, | 81 virtual void Initialize(DemuxerStream* stream, |
| 82 const PipelineStatusCB& init_cb, | 82 const PipelineStatusCB& init_cb, |
| 83 const StatisticsCB& statistics_cb, | 83 const StatisticsCB& statistics_cb, |
| 84 const BufferingStateCB& buffering_state_cb, | 84 const BufferingStateCB& buffering_state_cb, |
| 85 const base::Closure& ended_cb, | 85 const base::Closure& ended_cb, |
| 86 const PipelineStatusCB& error_cb) OVERRIDE; | 86 const PipelineStatusCB& error_cb) override; |
| 87 virtual TimeSource* GetTimeSource() OVERRIDE; | 87 virtual TimeSource* GetTimeSource() override; |
| 88 virtual void Flush(const base::Closure& callback) OVERRIDE; | 88 virtual void Flush(const base::Closure& callback) override; |
| 89 virtual void StartPlaying() OVERRIDE; | 89 virtual void StartPlaying() override; |
| 90 virtual void SetVolume(float volume) OVERRIDE; | 90 virtual void SetVolume(float volume) override; |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 friend class AudioRendererImplTest; | 93 friend class AudioRendererImplTest; |
| 94 | 94 |
| 95 // Important detail: being in kPlaying doesn't imply that audio is being | 95 // Important detail: being in kPlaying doesn't imply that audio is being |
| 96 // rendered. Rather, it means that the renderer is ready to go. The actual | 96 // rendered. Rather, it means that the renderer is ready to go. The actual |
| 97 // rendering of audio is controlled via Start/StopRendering(). | 97 // rendering of audio is controlled via Start/StopRendering(). |
| 98 // | 98 // |
| 99 // kUninitialized | 99 // kUninitialized |
| 100 // | Initialize() | 100 // | Initialize() |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // |audio_bus|, it could be a sign that the pipeline is stalled or unable to | 145 // |audio_bus|, it could be a sign that the pipeline is stalled or unable to |
| 146 // stream the data fast enough. In such scenarios, the callee should zero out | 146 // stream the data fast enough. In such scenarios, the callee should zero out |
| 147 // unused portions of their buffer to play back silence. | 147 // unused portions of their buffer to play back silence. |
| 148 // | 148 // |
| 149 // Render() updates the pipeline's playback timestamp. If Render() is | 149 // Render() updates the pipeline's playback timestamp. If Render() is |
| 150 // not called at the same rate as audio samples are played, then the reported | 150 // not called at the same rate as audio samples are played, then the reported |
| 151 // timestamp in the pipeline will be ahead of the actual audio playback. In | 151 // timestamp in the pipeline will be ahead of the actual audio playback. In |
| 152 // this case |audio_delay_milliseconds| should be used to indicate when in the | 152 // this case |audio_delay_milliseconds| should be used to indicate when in the |
| 153 // future should the filled buffer be played. | 153 // future should the filled buffer be played. |
| 154 virtual int Render(AudioBus* audio_bus, | 154 virtual int Render(AudioBus* audio_bus, |
| 155 int audio_delay_milliseconds) OVERRIDE; | 155 int audio_delay_milliseconds) override; |
| 156 virtual void OnRenderError() OVERRIDE; | 156 virtual void OnRenderError() override; |
| 157 | 157 |
| 158 // Helper methods that schedule an asynchronous read from the decoder as long | 158 // Helper methods that schedule an asynchronous read from the decoder as long |
| 159 // as there isn't a pending read. | 159 // as there isn't a pending read. |
| 160 // | 160 // |
| 161 // Must be called on |task_runner_|. | 161 // Must be called on |task_runner_|. |
| 162 void AttemptRead(); | 162 void AttemptRead(); |
| 163 void AttemptRead_Locked(); | 163 void AttemptRead_Locked(); |
| 164 bool CanRead_Locked(); | 164 bool CanRead_Locked(); |
| 165 void ChangeState_Locked(State new_state); | 165 void ChangeState_Locked(State new_state); |
| 166 | 166 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 // NOTE: Weak pointers must be invalidated before all other member variables. | 266 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 267 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 267 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
| 268 | 268 |
| 269 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 269 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
| 270 }; | 270 }; |
| 271 | 271 |
| 272 } // namespace media | 272 } // namespace media |
| 273 | 273 |
| 274 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 274 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
| OLD | NEW |