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

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 2522673003: Don't run WSOLA over always muted channels. (Closed)
Patch Set: Created 4 years, 1 month 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 e5891c894695fb6538446992a49b4e6ea6164df1..5f598e3e56c920a19ceca481d9f67942a2e7647c 100644
--- a/media/renderers/audio_renderer_impl.cc
+++ b/media/renderers/audio_renderer_impl.cc
@@ -22,6 +22,7 @@
#include "media/base/audio_buffer_converter.h"
#include "media/base/audio_latency.h"
#include "media/base/bind_to_current_loop.h"
+#include "media/base/channel_mixing_matrix.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
@@ -426,6 +427,24 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream,
sample_rate, hw_params.bits_per_sample(),
media::AudioLatency::GetHighLatencyBufferSize(
sample_rate, preferred_buffer_size));
+
+ // Figure out if there are muted channels that we should ignore when
+ // playback rate adapatation is requested (it's expensive).
+ if (stream_channel_count < audio_parameters_.channels()) {
+ std::vector<std::vector<float>> matrix;
+ ChannelMixingMatrix(
+ stream->audio_decoder_config().channel_layout(), stream_channel_count,
+ audio_parameters_.channel_layout(), audio_parameters_.channels())
+ .CreateTransformationMatrix(&matrix);
+
+ // All channels with a zero mix are muted and can be ignored.
+ channel_mask_ = std::vector<bool>(audio_parameters_.channels(), false);
+ for (size_t ch = 0; ch < matrix.size(); ++ch) {
+ channel_mask_[ch] =
+ std::find_if(matrix[ch].begin(), matrix[ch].end(),
+ [](float mix) { return !!mix; }) != matrix[ch].end();
sandersd (OOO until July 31) 2016/11/22 00:59:24 Nit: Would be more clear using std::any_of().
DaleCurtis 2016/11/22 01:07:49 Ah, didn't know about that one. Done.
+ }
+ }
}
audio_clock_.reset(
@@ -466,7 +485,7 @@ void AudioRendererImpl::OnAudioBufferStreamInitialized(bool success) {
// We're all good! Continue initializing the rest of the audio renderer
// based on the decoder format.
algorithm_.reset(new AudioRendererAlgorithm());
- algorithm_->Initialize(audio_parameters_);
+ algorithm_->Initialize(audio_parameters_, channel_mask_);
ChangeState_Locked(kFlushed);

Powered by Google App Engine
This is Rietveld 408576698