Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: +tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/renderers/audio_renderer_impl.cc
diff --git a/media/renderers/audio_renderer_impl.cc b/media/renderers/audio_renderer_impl.cc
index 7cb22ffb1695abb831acbfac99a6b19983c33dae..11f75fbef43fb9aa2ef713e11efcb4e5b02ba9ea 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),
@@ -361,6 +362,7 @@ 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
@@ -378,8 +380,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)
@@ -419,20 +420,25 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream,
// renderer. Browser-side will down-mix to the hardware config. If the
// hardware later changes to equal stream channels, browser-side will stop
// down-mixing and use the data from all stream channels.
+ bool use_hw_config = hw_channel_count > stream_channel_count;
ChannelLayout renderer_channel_layout =
- hw_channel_count > stream_channel_count
- ? hw_channel_layout
- : stream->audio_decoder_config().channel_layout();
+ use_hw_config ? hw_channel_layout
+ : stream->audio_decoder_config().channel_layout();
audio_parameters_.Reset(hw_params.format(), renderer_channel_layout,
sample_rate, hw_params.bits_per_sample(),
media::AudioLatency::GetHighLatencyBufferSize(
sample_rate, preferred_buffer_size));
+ if (!use_hw_config)
+ audio_parameters_.set_channels_for_discrete(stream_channel_count);
}
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()));
@@ -580,6 +586,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);
@@ -965,10 +972,11 @@ 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 =
DaleCurtis 2017/03/20 17:38:58 Just always use last_decoded_channels_ ?
flim-chromium 2017/03/22 06:20:51 Done.
- ChannelLayoutToChannelCount(last_decoded_channel_layout_);
+ last_decoded_channel_layout_ == CHANNEL_LAYOUT_DISCRETE
+ ? last_decoded_channels_
+ : 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.

Powered by Google App Engine
This is Rietveld 408576698