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

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: +pipeline integration tests, +test media, minor fixes 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..8fbb8416c6d9917f685001a48a09c56afc2af969 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,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
@@ -378,8 +381,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 +421,24 @@ 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,14 +972,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;
@@ -980,7 +983,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);

Powered by Google App Engine
This is Rietveld 408576698