| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 const PipelineStatusCB& init_cb, | 70 const PipelineStatusCB& init_cb, |
| 71 const StatisticsCB& statistics_cb, | 71 const StatisticsCB& statistics_cb, |
| 72 const TimeCB& time_cb, | 72 const TimeCB& time_cb, |
| 73 const BufferingStateCB& buffering_state_cb, | 73 const BufferingStateCB& buffering_state_cb, |
| 74 const base::Closure& ended_cb, | 74 const base::Closure& ended_cb, |
| 75 const PipelineStatusCB& error_cb) OVERRIDE; | 75 const PipelineStatusCB& error_cb) OVERRIDE; |
| 76 virtual void StartRendering() OVERRIDE; | 76 virtual void StartRendering() OVERRIDE; |
| 77 virtual void StopRendering() OVERRIDE; | 77 virtual void StopRendering() OVERRIDE; |
| 78 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; | 78 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; |
| 79 virtual void Flush(const base::Closure& callback) OVERRIDE; | 79 virtual void Flush(const base::Closure& callback) OVERRIDE; |
| 80 virtual void Stop(const base::Closure& callback) OVERRIDE; | |
| 81 virtual void SetPlaybackRate(float rate) OVERRIDE; | 80 virtual void SetPlaybackRate(float rate) OVERRIDE; |
| 82 virtual void StartPlaying() OVERRIDE; | 81 virtual void StartPlaying() OVERRIDE; |
| 83 virtual void SetVolume(float volume) OVERRIDE; | 82 virtual void SetVolume(float volume) OVERRIDE; |
| 84 | 83 |
| 85 private: | 84 private: |
| 86 friend class AudioRendererImplTest; | 85 friend class AudioRendererImplTest; |
| 87 | 86 |
| 88 // Important detail: being in kPlaying doesn't imply that audio is being | 87 // 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 | 88 // rendered. Rather, it means that the renderer is ready to go. The actual |
| 90 // rendering of audio is controlled via Start/StopRendering(). | 89 // rendering of audio is controlled via Start/StopRendering(). |
| 91 // | 90 // |
| 92 // kUninitialized | 91 // kUninitialized |
| 93 // | Initialize() | 92 // | Initialize() |
| 94 // | | 93 // | |
| 95 // V | 94 // V |
| 96 // kInitializing | 95 // kInitializing |
| 97 // | Decoders initialized | 96 // | Decoders initialized |
| 98 // | | 97 // | |
| 99 // V Decoders reset | 98 // V Decoders reset |
| 100 // kFlushed <------------------ kFlushing | 99 // kFlushed <------------------ kFlushing |
| 101 // | StartPlaying() ^ | 100 // | StartPlaying() ^ |
| 102 // | | | 101 // | | |
| 103 // | | Flush() | 102 // | | Flush() |
| 104 // `---------> kPlaying --------' | 103 // `---------> kPlaying --------' |
| 105 enum State { | 104 enum State { |
| 106 kUninitialized, | 105 kUninitialized, |
| 107 kInitializing, | 106 kInitializing, |
| 108 kFlushing, | 107 kFlushing, |
| 109 kFlushed, | 108 kFlushed, |
| 110 kPlaying, | 109 kPlaying |
| 111 kStopped, | |
| 112 }; | 110 }; |
| 113 | 111 |
| 114 // Callback from the audio decoder delivering decoded audio samples. | 112 // Callback from the audio decoder delivering decoded audio samples. |
| 115 void DecodedAudioReady(AudioBufferStream::Status status, | 113 void DecodedAudioReady(AudioBufferStream::Status status, |
| 116 const scoped_refptr<AudioBuffer>& buffer); | 114 const scoped_refptr<AudioBuffer>& buffer); |
| 117 | 115 |
| 118 // Handles buffers that come out of |splicer_|. | 116 // Handles buffers that come out of |splicer_|. |
| 119 // Returns true if more buffers are needed. | 117 // Returns true if more buffers are needed. |
| 120 bool HandleSplicerBuffer_Locked(const scoped_refptr<AudioBuffer>& buffer); | 118 bool HandleSplicerBuffer_Locked(const scoped_refptr<AudioBuffer>& buffer); |
| 121 | 119 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 247 |
| 250 // NOTE: Weak pointers must be invalidated before all other member variables. | 248 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 251 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 249 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
| 252 | 250 |
| 253 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 251 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
| 254 }; | 252 }; |
| 255 | 253 |
| 256 } // namespace media | 254 } // namespace media |
| 257 | 255 |
| 258 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 256 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
| OLD | NEW |