| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 AudioParameters::AUDIO_PCM_LOW_LATENCY, | 276 AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 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 stream->audio_decoder_config().samples_per_second(), | 280 stream->audio_decoder_config().samples_per_second(), |
| 281 stream->audio_decoder_config().bits_per_channel(), | 281 stream->audio_decoder_config().bits_per_channel(), |
| 282 buffer_size); | 282 buffer_size); |
| 283 buffer_converter_.reset(); | 283 buffer_converter_.reset(); |
| 284 } else { | 284 } else { |
| 285 // TODO(rileya): Support hardware config changes | 285 // TODO(rileya): Support hardware config changes |
| 286 const AudioParameters& hw_params = hardware_config_->GetOutputConfig(); | 286 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); |
| 287 audio_parameters_.Reset( | 287 audio_parameters_.Reset( |
| 288 hw_params.format(), | 288 hw_params.format(), |
| 289 // Always use the source's channel layout and channel count to avoid | 289 // Always use the source's channel layout and channel count to avoid |
| 290 // premature downmixing (http://crbug.com/379288), platform specific | 290 // premature downmixing (http://crbug.com/379288), platform specific |
| 291 // issues around channel layouts (http://crbug.com/266674), and | 291 // issues around channel layouts (http://crbug.com/266674), and |
| 292 // unnecessary upmixing overhead. | 292 // unnecessary upmixing overhead. |
| 293 stream->audio_decoder_config().channel_layout(), | 293 stream->audio_decoder_config().channel_layout(), |
| 294 ChannelLayoutToChannelCount( | 294 ChannelLayoutToChannelCount( |
| 295 stream->audio_decoder_config().channel_layout()), | 295 stream->audio_decoder_config().channel_layout()), |
| 296 hw_params.sample_rate(), | 296 hw_params.sample_rate(), |
| 297 hw_params.bits_per_sample(), | 297 hw_params.bits_per_sample(), |
| 298 hardware_config_->GetHighLatencyBufferSize()); | 298 hardware_config_.GetHighLatencyBufferSize()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 audio_clock_.reset( | 301 audio_clock_.reset( |
| 302 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); | 302 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); |
| 303 | 303 |
| 304 audio_buffer_stream_->Initialize( | 304 audio_buffer_stream_->Initialize( |
| 305 stream, | 305 stream, |
| 306 false, | 306 false, |
| 307 statistics_cb, | 307 statistics_cb, |
| 308 base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, | 308 base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 << buffering_state; | 699 << buffering_state; |
| 700 DCHECK_NE(buffering_state_, buffering_state); | 700 DCHECK_NE(buffering_state_, buffering_state); |
| 701 lock_.AssertAcquired(); | 701 lock_.AssertAcquired(); |
| 702 buffering_state_ = buffering_state; | 702 buffering_state_ = buffering_state; |
| 703 | 703 |
| 704 task_runner_->PostTask(FROM_HERE, | 704 task_runner_->PostTask(FROM_HERE, |
| 705 base::Bind(buffering_state_cb_, buffering_state_)); | 705 base::Bind(buffering_state_cb_, buffering_state_)); |
| 706 } | 706 } |
| 707 | 707 |
| 708 } // namespace media | 708 } // namespace media |
| OLD | NEW |