| Index: media/renderers/audio_renderer_impl.cc
|
| diff --git a/media/renderers/audio_renderer_impl.cc b/media/renderers/audio_renderer_impl.cc
|
| index 596603b96f99dbda5c65adf925e85025ee78dd79..93fae8374dbcd41412348c75b8b20c1ac1a40f54 100644
|
| --- a/media/renderers/audio_renderer_impl.cc
|
| +++ b/media/renderers/audio_renderer_impl.cc
|
| @@ -49,6 +49,7 @@ AudioRendererImpl::AudioRendererImpl(
|
| last_audio_memory_usage_(0),
|
| last_decoded_sample_rate_(0),
|
| last_decoded_channel_layout_(CHANNEL_LAYOUT_NONE),
|
| + last_decoded_channels_(0),
|
| playback_rate_(0.0),
|
| state_(kUninitialized),
|
| buffering_state_(BUFFERING_HAVE_NOTHING),
|
| @@ -358,8 +359,16 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream,
|
| auto output_device_info = sink_->GetOutputDeviceInfo();
|
| const AudioParameters& hw_params = output_device_info.output_params();
|
| expecting_config_changes_ = stream->SupportsConfigChanges();
|
| - if (!expecting_config_changes_ || !hw_params.IsValid() ||
|
| - hw_params.format() == AudioParameters::AUDIO_FAKE) {
|
| +
|
| + bool invalid_discrete_layout_sink =
|
| + stream->audio_decoder_config().channel_layout() ==
|
| + CHANNEL_LAYOUT_DISCRETE &&
|
| + !output_device_info.is_webaudio_source();
|
| + DCHECK(!invalid_discrete_layout_sink);
|
| +
|
| + if ((!expecting_config_changes_ || !hw_params.IsValid() ||
|
| + hw_params.format() == AudioParameters::AUDIO_FAKE) &&
|
| + !invalid_discrete_layout_sink) {
|
| // The actual buffer size is controlled via the size of the AudioBus
|
| // provided to Render(), but we should choose a value here based on hardware
|
| // parameters if possible since it affects the initial buffer size used by
|
| @@ -372,6 +381,8 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream,
|
| stream->audio_decoder_config().samples_per_second(),
|
| stream->audio_decoder_config().bits_per_channel(),
|
| buffer_size);
|
| + audio_parameters_.set_channels_for_discrete(
|
| + stream->audio_decoder_config().channels());
|
| buffer_converter_.reset();
|
| } else {
|
| // To allow for seamless sample rate adaptations (i.e. changes from say
|
| @@ -389,8 +400,7 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream,
|
| }
|
| #endif
|
|
|
| - int stream_channel_count = ChannelLayoutToChannelCount(
|
| - stream->audio_decoder_config().channel_layout());
|
| + int stream_channel_count = stream->audio_decoder_config().channels();
|
|
|
| bool try_supported_channel_layouts = false;
|
| #if defined(OS_WIN)
|
| @@ -444,6 +454,8 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream,
|
| last_decoded_channel_layout_ =
|
| stream->audio_decoder_config().channel_layout();
|
|
|
| + last_decoded_channels_ = stream->audio_decoder_config().channels();
|
| +
|
| audio_clock_.reset(
|
| new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate()));
|
|
|
| @@ -591,6 +603,7 @@ void AudioRendererImpl::DecodedAudioReady(
|
|
|
| if (last_decoded_channel_layout_ != buffer->channel_layout()) {
|
| last_decoded_channel_layout_ = buffer->channel_layout();
|
| + last_decoded_channels_ = buffer->channel_count();
|
|
|
| // Input layouts should never be discrete.
|
| DCHECK_NE(last_decoded_channel_layout_, CHANNEL_LAYOUT_DISCRETE);
|
| @@ -976,14 +989,10 @@ void AudioRendererImpl::ConfigureChannelMask() {
|
| DCHECK(audio_parameters_.IsValid());
|
| DCHECK_NE(last_decoded_channel_layout_, CHANNEL_LAYOUT_NONE);
|
| DCHECK_NE(last_decoded_channel_layout_, CHANNEL_LAYOUT_UNSUPPORTED);
|
| - DCHECK_NE(last_decoded_channel_layout_, CHANNEL_LAYOUT_DISCRETE);
|
| -
|
| - const int input_channel_count =
|
| - ChannelLayoutToChannelCount(last_decoded_channel_layout_);
|
|
|
| // If we're actually downmixing the signal, no mask is necessary, but ensure
|
| // we clear any existing mask if present.
|
| - if (input_channel_count >= audio_parameters_.channels()) {
|
| + if (last_decoded_channels_ >= audio_parameters_.channels()) {
|
| algorithm_->SetChannelMask(
|
| std::vector<bool>(audio_parameters_.channels(), true));
|
| return;
|
| @@ -991,7 +1000,7 @@ void AudioRendererImpl::ConfigureChannelMask() {
|
|
|
| // Determine the matrix used to upmix the channels.
|
| std::vector<std::vector<float>> matrix;
|
| - ChannelMixingMatrix(last_decoded_channel_layout_, input_channel_count,
|
| + ChannelMixingMatrix(last_decoded_channel_layout_, last_decoded_channels_,
|
| audio_parameters_.channel_layout(),
|
| audio_parameters_.channels())
|
| .CreateTransformationMatrix(&matrix);
|
|
|