| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 ChannelLayoutToChannelCount( | 276 ChannelLayoutToChannelCount( |
| 277 stream->audio_decoder_config().channel_layout()), | 277 stream->audio_decoder_config().channel_layout()), |
| 278 0, | 278 0, |
| 279 stream->audio_decoder_config().samples_per_second(), | 279 stream->audio_decoder_config().samples_per_second(), |
| 280 stream->audio_decoder_config().bits_per_channel(), | 280 stream->audio_decoder_config().bits_per_channel(), |
| 281 buffer_size); | 281 buffer_size); |
| 282 buffer_converter_.reset(); | 282 buffer_converter_.reset(); |
| 283 } else { | 283 } else { |
| 284 // TODO(rileya): Support hardware config changes | 284 // TODO(rileya): Support hardware config changes |
| 285 const AudioParameters& hw_params = hardware_config_->GetOutputConfig(); | 285 const AudioParameters& hw_params = hardware_config_->GetOutputConfig(); |
| 286 audio_parameters_.Reset(hw_params.format(), | 286 audio_parameters_.Reset( |
| 287 hw_params.channel_layout(), | 287 hw_params.format(), |
| 288 hw_params.channels(), | 288 // Always use the source's channel layout and channel count to avoid |
| 289 hw_params.input_channels(), | 289 // premature downmixing (http://crbug.com/379288), platform specific |
| 290 hw_params.sample_rate(), | 290 // issues around channel layouts (http://crbug.com/266674), and |
| 291 hw_params.bits_per_sample(), | 291 // unnecessary upmixing overhead. |
| 292 hardware_config_->GetHighLatencyBufferSize()); | 292 stream->audio_decoder_config().channel_layout(), |
| 293 ChannelLayoutToChannelCount( |
| 294 stream->audio_decoder_config().channel_layout()), |
| 295 hw_params.input_channels(), |
| 296 hw_params.sample_rate(), |
| 297 hw_params.bits_per_sample(), |
| 298 hardware_config_->GetHighLatencyBufferSize()); |
| 293 } | 299 } |
| 294 | 300 |
| 295 audio_clock_.reset(new AudioClock(audio_parameters_.sample_rate())); | 301 audio_clock_.reset(new AudioClock(audio_parameters_.sample_rate())); |
| 296 | 302 |
| 297 audio_buffer_stream_.Initialize( | 303 audio_buffer_stream_.Initialize( |
| 298 stream, | 304 stream, |
| 299 false, | 305 false, |
| 300 statistics_cb, | 306 statistics_cb, |
| 301 base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, | 307 base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, |
| 302 weak_factory_.GetWeakPtr())); | 308 weak_factory_.GetWeakPtr())); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 DCHECK(expecting_config_changes_); | 762 DCHECK(expecting_config_changes_); |
| 757 buffer_converter_->ResetTimestampState(); | 763 buffer_converter_->ResetTimestampState(); |
| 758 // Drain flushed buffers from the converter so the AudioSplicer receives all | 764 // Drain flushed buffers from the converter so the AudioSplicer receives all |
| 759 // data ahead of any OnNewSpliceBuffer() calls. Since discontinuities should | 765 // data ahead of any OnNewSpliceBuffer() calls. Since discontinuities should |
| 760 // only appear after config changes, AddInput() should never fail here. | 766 // only appear after config changes, AddInput() should never fail here. |
| 761 while (buffer_converter_->HasNextBuffer()) | 767 while (buffer_converter_->HasNextBuffer()) |
| 762 CHECK(splicer_->AddInput(buffer_converter_->GetNextBuffer())); | 768 CHECK(splicer_->AddInput(buffer_converter_->GetNextBuffer())); |
| 763 } | 769 } |
| 764 | 770 |
| 765 } // namespace media | 771 } // namespace media |
| OLD | NEW |