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/renderers/audio_renderer_impl.h" | 5 #include "media/renderers/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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); | 337 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); |
338 expecting_config_changes_ = stream->SupportsConfigChanges(); | 338 expecting_config_changes_ = stream->SupportsConfigChanges(); |
339 if (!expecting_config_changes_ || !hw_params.IsValid()) { | 339 if (!expecting_config_changes_ || !hw_params.IsValid()) { |
340 // The actual buffer size is controlled via the size of the AudioBus | 340 // The actual buffer size is controlled via the size of the AudioBus |
341 // provided to Render(), so just choose something reasonable here for looks. | 341 // provided to Render(), so just choose something reasonable here for looks. |
342 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; | 342 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; |
343 audio_parameters_.Reset( | 343 audio_parameters_.Reset( |
344 AudioParameters::AUDIO_PCM_LOW_LATENCY, | 344 AudioParameters::AUDIO_PCM_LOW_LATENCY, |
345 stream->audio_decoder_config().channel_layout(), | 345 stream->audio_decoder_config().channel_layout(), |
346 ChannelLayoutToChannelCount( | |
347 stream->audio_decoder_config().channel_layout()), | |
348 stream->audio_decoder_config().samples_per_second(), | 346 stream->audio_decoder_config().samples_per_second(), |
349 stream->audio_decoder_config().bits_per_channel(), | 347 stream->audio_decoder_config().bits_per_channel(), |
350 buffer_size); | 348 buffer_size); |
351 buffer_converter_.reset(); | 349 buffer_converter_.reset(); |
352 } else { | 350 } else { |
353 audio_parameters_.Reset( | 351 audio_parameters_.Reset( |
354 hw_params.format(), | 352 hw_params.format(), |
355 // Always use the source's channel layout and channel count to avoid | 353 // Always use the source's channel layout to avoid premature downmixing |
356 // premature downmixing (http://crbug.com/379288), platform specific | 354 // (http://crbug.com/379288), platform specific issues around channel |
357 // issues around channel layouts (http://crbug.com/266674), and | 355 // layouts (http://crbug.com/266674), and unnecessary upmixing overhead. |
358 // unnecessary upmixing overhead. | |
359 stream->audio_decoder_config().channel_layout(), | 356 stream->audio_decoder_config().channel_layout(), |
360 ChannelLayoutToChannelCount( | 357 hw_params.sample_rate(), hw_params.bits_per_sample(), |
361 stream->audio_decoder_config().channel_layout()), | |
362 hw_params.sample_rate(), | |
363 hw_params.bits_per_sample(), | |
364 hardware_config_.GetHighLatencyBufferSize()); | 358 hardware_config_.GetHighLatencyBufferSize()); |
365 } | 359 } |
366 | 360 |
367 audio_clock_.reset( | 361 audio_clock_.reset( |
368 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); | 362 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); |
369 | 363 |
370 audio_buffer_stream_->Initialize( | 364 audio_buffer_stream_->Initialize( |
371 stream, base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, | 365 stream, base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, |
372 weak_factory_.GetWeakPtr()), | 366 weak_factory_.GetWeakPtr()), |
373 set_decryptor_ready_cb, statistics_cb, waiting_for_decryption_key_cb); | 367 set_decryptor_ready_cb, statistics_cb, waiting_for_decryption_key_cb); |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 << buffering_state; | 797 << buffering_state; |
804 DCHECK_NE(buffering_state_, buffering_state); | 798 DCHECK_NE(buffering_state_, buffering_state); |
805 lock_.AssertAcquired(); | 799 lock_.AssertAcquired(); |
806 buffering_state_ = buffering_state; | 800 buffering_state_ = buffering_state; |
807 | 801 |
808 task_runner_->PostTask(FROM_HERE, | 802 task_runner_->PostTask(FROM_HERE, |
809 base::Bind(buffering_state_cb_, buffering_state_)); | 803 base::Bind(buffering_state_cb_, buffering_state_)); |
810 } | 804 } |
811 | 805 |
812 } // namespace media | 806 } // namespace media |
OLD | NEW |