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

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: another fix for unreliable ffmpeg channels vs layout Created 3 years, 7 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
« no previous file with comments | « media/renderers/audio_renderer_impl.h ('k') | media/renderers/audio_renderer_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/audio_renderer_impl.cc
diff --git a/media/renderers/audio_renderer_impl.cc b/media/renderers/audio_renderer_impl.cc
index a351b9a84ec0a7ae9207f94af19cc412237dc0ee..0d417c405a1fe42d806285600349a74505d2e021 100644
--- a/media/renderers/audio_renderer_impl.cc
+++ b/media/renderers/audio_renderer_impl.cc
@@ -48,6 +48,7 @@ AudioRendererImpl::AudioRendererImpl(
last_decoded_sample_rate_(0),
last_decoded_channel_layout_(CHANNEL_LAYOUT_NONE),
is_encrypted_(false),
+ last_decoded_channels_(0),
playback_rate_(0.0),
state_(kUninitialized),
create_audio_decoders_cb_(create_audio_decoders_cb),
@@ -369,9 +370,18 @@ 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 ||
- !sink_->IsOptimizedForHardwareParameters()) {
+
+ bool use_stream_params = !expecting_config_changes_ || !hw_params.IsValid() ||
+ hw_params.format() == AudioParameters::AUDIO_FAKE ||
+ !sink_->IsOptimizedForHardwareParameters();
+
+ if (stream->audio_decoder_config().channel_layout() ==
+ CHANNEL_LAYOUT_DISCRETE &&
+ sink_->IsOptimizedForHardwareParameters()) {
+ use_stream_params = false;
+ }
+
+ if (use_stream_params) {
// 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
@@ -384,6 +394,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
@@ -401,8 +413,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)
@@ -458,6 +469,8 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream,
is_encrypted_ = stream->audio_decoder_config().is_encrypted();
+ last_decoded_channels_ = stream->audio_decoder_config().channels();
+
audio_clock_.reset(
new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate()));
@@ -605,6 +618,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);
@@ -990,14 +1004,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;
@@ -1005,7 +1015,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);
« no previous file with comments | « media/renderers/audio_renderer_impl.h ('k') | media/renderers/audio_renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698