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 #include "media/filters/audio_renderer_impl.h" | 5 #include "media/filters/audio_renderer_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 "Media.AudioRendererEvents", event, RENDER_EVENT_MAX + 1); | 38 "Media.AudioRendererEvents", event, RENDER_EVENT_MAX + 1); |
39 } | 39 } |
40 | 40 |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 AudioRendererImpl::AudioRendererImpl( | 43 AudioRendererImpl::AudioRendererImpl( |
44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
45 media::AudioRendererSink* sink, | 45 media::AudioRendererSink* sink, |
46 ScopedVector<AudioDecoder> decoders, | 46 ScopedVector<AudioDecoder> decoders, |
47 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 47 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
48 AudioHardwareConfig* hardware_config) | 48 const AudioHardwareConfig& hardware_config) |
49 : task_runner_(task_runner), | 49 : task_runner_(task_runner), |
50 expecting_config_changes_(false), | 50 expecting_config_changes_(false), |
51 sink_(sink), | 51 sink_(sink), |
52 audio_buffer_stream_(new AudioBufferStream(task_runner, | 52 audio_buffer_stream_(new AudioBufferStream(task_runner, |
53 decoders.Pass(), | 53 decoders.Pass(), |
54 set_decryptor_ready_cb)), | 54 set_decryptor_ready_cb)), |
55 hardware_config_(hardware_config), | 55 hardware_config_(hardware_config), |
56 playback_rate_(0), | 56 playback_rate_(0), |
57 state_(kUninitialized), | 57 state_(kUninitialized), |
58 buffering_state_(BUFFERING_HAVE_NOTHING), | 58 buffering_state_(BUFFERING_HAVE_NOTHING), |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 stream->audio_decoder_config().channel_layout(), | 277 stream->audio_decoder_config().channel_layout(), |
278 ChannelLayoutToChannelCount( | 278 ChannelLayoutToChannelCount( |
279 stream->audio_decoder_config().channel_layout()), | 279 stream->audio_decoder_config().channel_layout()), |
280 0, | 280 0, |
281 stream->audio_decoder_config().samples_per_second(), | 281 stream->audio_decoder_config().samples_per_second(), |
282 stream->audio_decoder_config().bits_per_channel(), | 282 stream->audio_decoder_config().bits_per_channel(), |
283 buffer_size); | 283 buffer_size); |
284 buffer_converter_.reset(); | 284 buffer_converter_.reset(); |
285 } else { | 285 } else { |
286 // TODO(rileya): Support hardware config changes | 286 // TODO(rileya): Support hardware config changes |
287 const AudioParameters& hw_params = hardware_config_->GetOutputConfig(); | 287 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); |
288 audio_parameters_.Reset( | 288 audio_parameters_.Reset( |
289 hw_params.format(), | 289 hw_params.format(), |
290 // Always use the source's channel layout and channel count to avoid | 290 // Always use the source's channel layout and channel count to avoid |
291 // premature downmixing (http://crbug.com/379288), platform specific | 291 // premature downmixing (http://crbug.com/379288), platform specific |
292 // issues around channel layouts (http://crbug.com/266674), and | 292 // issues around channel layouts (http://crbug.com/266674), and |
293 // unnecessary upmixing overhead. | 293 // unnecessary upmixing overhead. |
294 stream->audio_decoder_config().channel_layout(), | 294 stream->audio_decoder_config().channel_layout(), |
295 ChannelLayoutToChannelCount( | 295 ChannelLayoutToChannelCount( |
296 stream->audio_decoder_config().channel_layout()), | 296 stream->audio_decoder_config().channel_layout()), |
297 hw_params.input_channels(), | 297 hw_params.input_channels(), |
298 hw_params.sample_rate(), | 298 hw_params.sample_rate(), |
299 hw_params.bits_per_sample(), | 299 hw_params.bits_per_sample(), |
300 hardware_config_->GetHighLatencyBufferSize()); | 300 hardware_config_.GetHighLatencyBufferSize()); |
301 } | 301 } |
302 | 302 |
303 audio_clock_.reset( | 303 audio_clock_.reset( |
304 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); | 304 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); |
305 | 305 |
306 audio_buffer_stream_->Initialize( | 306 audio_buffer_stream_->Initialize( |
307 stream, | 307 stream, |
308 false, | 308 false, |
309 statistics_cb, | 309 statistics_cb, |
310 base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, | 310 base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 << buffering_state; | 701 << buffering_state; |
702 DCHECK_NE(buffering_state_, buffering_state); | 702 DCHECK_NE(buffering_state_, buffering_state); |
703 lock_.AssertAcquired(); | 703 lock_.AssertAcquired(); |
704 buffering_state_ = buffering_state; | 704 buffering_state_ = buffering_state; |
705 | 705 |
706 task_runner_->PostTask(FROM_HERE, | 706 task_runner_->PostTask(FROM_HERE, |
707 base::Bind(buffering_state_cb_, buffering_state_)); | 707 base::Bind(buffering_state_cb_, buffering_state_)); |
708 } | 708 } |
709 | 709 |
710 } // namespace media | 710 } // namespace media |
OLD | NEW |