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