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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 // Called when the |decoder_|.Reset() has completed. | 190 // Called when the |decoder_|.Reset() has completed. |
191 void ResetDecoderDone(); | 191 void ResetDecoderDone(); |
192 | 192 |
193 // Called by the AudioBufferStream when a config change occurs. | 193 // Called by the AudioBufferStream when a config change occurs. |
194 void OnConfigChange(); | 194 void OnConfigChange(); |
195 | 195 |
196 // Updates |buffering_state_| and fires |buffering_state_cb_|. | 196 // Updates |buffering_state_| and fires |buffering_state_cb_|. |
197 void SetBufferingState_Locked(BufferingState buffering_state); | 197 void SetBufferingState_Locked(BufferingState buffering_state); |
198 | 198 |
| 199 // Configure's the channel mask for |algorithm_|. Must be called if the layout |
| 200 // changes. Expect the layout in |last_decoded_channel_layout_|. |
| 201 void ConfigureChannelMask(); |
| 202 |
199 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 203 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
200 | 204 |
201 std::unique_ptr<AudioBufferConverter> buffer_converter_; | 205 std::unique_ptr<AudioBufferConverter> buffer_converter_; |
202 | 206 |
203 // Whether or not we expect to handle config changes. | 207 // Whether or not we expect to handle config changes. |
204 bool expecting_config_changes_; | 208 bool expecting_config_changes_; |
205 | 209 |
206 // The sink (destination) for rendered audio. |sink_| must only be accessed | 210 // The sink (destination) for rendered audio. |sink_| must only be accessed |
207 // on |task_runner_|. |sink_| must never be called under |lock_| or else we | 211 // on |task_runner_|. |sink_| must never be called under |lock_| or else we |
208 // may deadlock between |task_runner_| and the audio callback thread. | 212 // may deadlock between |task_runner_| and the audio callback thread. |
(...skipping 18 matching lines...) Expand all Loading... |
227 std::unique_ptr<base::TickClock> tick_clock_; | 231 std::unique_ptr<base::TickClock> tick_clock_; |
228 | 232 |
229 // Memory usage of |algorithm_| recorded during the last | 233 // Memory usage of |algorithm_| recorded during the last |
230 // HandleDecodedBuffer_Locked() call. | 234 // HandleDecodedBuffer_Locked() call. |
231 int64_t last_audio_memory_usage_; | 235 int64_t last_audio_memory_usage_; |
232 | 236 |
233 // Sample rate of the last decoded audio buffer. Allows for detection of | 237 // Sample rate of the last decoded audio buffer. Allows for detection of |
234 // sample rate changes due to implicit AAC configuration change. | 238 // sample rate changes due to implicit AAC configuration change. |
235 int last_decoded_sample_rate_; | 239 int last_decoded_sample_rate_; |
236 | 240 |
237 // Indicates which channels are muted and can be ignored by the algorithm. | 241 // Similar to |last_decoded_sample_rate_|, used to configure the channel mask |
238 std::vector<bool> channel_mask_; | 242 // given to the |algorithm_| for efficient playback rate changes. |
| 243 ChannelLayout last_decoded_channel_layout_; |
239 | 244 |
240 // After Initialize() has completed, all variables below must be accessed | 245 // After Initialize() has completed, all variables below must be accessed |
241 // under |lock_|. ------------------------------------------------------------ | 246 // under |lock_|. ------------------------------------------------------------ |
242 base::Lock lock_; | 247 base::Lock lock_; |
243 | 248 |
244 // Algorithm for scaling audio. | 249 // Algorithm for scaling audio. |
245 double playback_rate_; | 250 double playback_rate_; |
246 std::unique_ptr<AudioRendererAlgorithm> algorithm_; | 251 std::unique_ptr<AudioRendererAlgorithm> algorithm_; |
247 | 252 |
248 // Simple state tracking variable. | 253 // Simple state tracking variable. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 298 |
294 // NOTE: Weak pointers must be invalidated before all other member variables. | 299 // NOTE: Weak pointers must be invalidated before all other member variables. |
295 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 300 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
296 | 301 |
297 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 302 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
298 }; | 303 }; |
299 | 304 |
300 } // namespace media | 305 } // namespace media |
301 | 306 |
302 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ | 307 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |