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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 expecting_config_changes_ = stream->SupportsConfigChanges(); | 267 expecting_config_changes_ = stream->SupportsConfigChanges(); |
268 if (!expecting_config_changes_) { | 268 if (!expecting_config_changes_) { |
269 // The actual buffer size is controlled via the size of the AudioBus | 269 // The actual buffer size is controlled via the size of the AudioBus |
270 // provided to Render(), so just choose something reasonable here for looks. | 270 // provided to Render(), so just choose something reasonable here for looks. |
271 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; | 271 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; |
272 audio_parameters_.Reset( | 272 audio_parameters_.Reset( |
273 AudioParameters::AUDIO_PCM_LOW_LATENCY, | 273 AudioParameters::AUDIO_PCM_LOW_LATENCY, |
274 stream->audio_decoder_config().channel_layout(), | 274 stream->audio_decoder_config().channel_layout(), |
275 ChannelLayoutToChannelCount( | 275 ChannelLayoutToChannelCount( |
276 stream->audio_decoder_config().channel_layout()), | 276 stream->audio_decoder_config().channel_layout()), |
277 0, | |
278 stream->audio_decoder_config().samples_per_second(), | 277 stream->audio_decoder_config().samples_per_second(), |
279 stream->audio_decoder_config().bits_per_channel(), | 278 stream->audio_decoder_config().bits_per_channel(), |
280 buffer_size); | 279 buffer_size); |
281 buffer_converter_.reset(); | 280 buffer_converter_.reset(); |
282 } else { | 281 } else { |
283 // TODO(rileya): Support hardware config changes | 282 // TODO(rileya): Support hardware config changes |
284 const AudioParameters& hw_params = hardware_config_->GetOutputConfig(); | 283 const AudioParameters& hw_params = hardware_config_->GetOutputConfig(); |
285 audio_parameters_.Reset( | 284 audio_parameters_.Reset( |
286 hw_params.format(), | 285 hw_params.format(), |
287 // Always use the source's channel layout and channel count to avoid | 286 // Always use the source's channel layout and channel count to avoid |
288 // premature downmixing (http://crbug.com/379288), platform specific | 287 // premature downmixing (http://crbug.com/379288), platform specific |
289 // issues around channel layouts (http://crbug.com/266674), and | 288 // issues around channel layouts (http://crbug.com/266674), and |
290 // unnecessary upmixing overhead. | 289 // unnecessary upmixing overhead. |
291 stream->audio_decoder_config().channel_layout(), | 290 stream->audio_decoder_config().channel_layout(), |
292 ChannelLayoutToChannelCount( | 291 ChannelLayoutToChannelCount( |
293 stream->audio_decoder_config().channel_layout()), | 292 stream->audio_decoder_config().channel_layout()), |
294 hw_params.input_channels(), | |
295 hw_params.sample_rate(), | 293 hw_params.sample_rate(), |
296 hw_params.bits_per_sample(), | 294 hw_params.bits_per_sample(), |
297 hardware_config_->GetHighLatencyBufferSize()); | 295 hardware_config_->GetHighLatencyBufferSize()); |
298 } | 296 } |
299 | 297 |
300 audio_clock_.reset( | 298 audio_clock_.reset( |
301 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); | 299 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); |
302 | 300 |
303 audio_buffer_stream_->Initialize( | 301 audio_buffer_stream_->Initialize( |
304 stream, | 302 stream, |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 << buffering_state; | 697 << buffering_state; |
700 DCHECK_NE(buffering_state_, buffering_state); | 698 DCHECK_NE(buffering_state_, buffering_state); |
701 lock_.AssertAcquired(); | 699 lock_.AssertAcquired(); |
702 buffering_state_ = buffering_state; | 700 buffering_state_ = buffering_state; |
703 | 701 |
704 task_runner_->PostTask(FROM_HERE, | 702 task_runner_->PostTask(FROM_HERE, |
705 base::Bind(buffering_state_cb_, buffering_state_)); | 703 base::Bind(buffering_state_cb_, buffering_state_)); |
706 } | 704 } |
707 | 705 |
708 } // namespace media | 706 } // namespace media |
OLD | NEW |