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

Unified Diff: media/filters/audio_renderer_algorithm.cc

Issue 2536013002: Fix implicit channel layout configurations at non-1.0 playback rates. (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
« no previous file with comments | « media/filters/audio_renderer_algorithm.h ('k') | media/filters/audio_renderer_algorithm_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_renderer_algorithm.cc
diff --git a/media/filters/audio_renderer_algorithm.cc b/media/filters/audio_renderer_algorithm.cc
index 1ce8bf6a12c641f897115a9bb46f5d2cfdcacc3f..efa45d35ef484a40cf509ac4f434c62095e2355d 100644
--- a/media/filters/audio_renderer_algorithm.cc
+++ b/media/filters/audio_renderer_algorithm.cc
@@ -82,11 +82,9 @@ AudioRendererAlgorithm::AudioRendererAlgorithm()
AudioRendererAlgorithm::~AudioRendererAlgorithm() {}
-void AudioRendererAlgorithm::Initialize(const AudioParameters& params,
- std::vector<bool> channel_mask) {
+void AudioRendererAlgorithm::Initialize(const AudioParameters& params) {
CHECK(params.IsValid());
- channel_mask_ = std::move(channel_mask);
channels_ = params.channels();
samples_per_second_ = params.sample_rate();
initial_capacity_ = capacity_ =
@@ -126,8 +124,14 @@ void AudioRendererAlgorithm::Initialize(const AudioParameters& params,
// If no mask is provided, assume all channels are valid.
if (channel_mask_.empty())
- channel_mask_ = std::vector<bool>(channels_, true);
- DCHECK_EQ(channel_mask_.size(), static_cast<size_t>(channels_));
+ SetChannelMask(std::vector<bool>(channels_, true));
+}
+
+void AudioRendererAlgorithm::SetChannelMask(std::vector<bool> channel_mask) {
+ DCHECK_EQ(channel_mask.size(), static_cast<size_t>(channels_));
+ channel_mask_ = std::move(channel_mask);
+ if (ola_window_)
+ CreateSearchWrappers();
}
int AudioRendererAlgorithm::FillBuffer(AudioBus* dest,
@@ -203,21 +207,8 @@ int AudioRendererAlgorithm::FillBuffer(AudioBus* dest,
channels_, num_candidate_blocks_ + (ola_window_size_ - 1));
target_block_ = AudioBus::Create(channels_, ola_window_size_);
- // WSOLA is quite expensive to run, so if a channel mask exists, use it to
- // reduce the size of our search space.
- std::vector<float*> active_target_channels;
- std::vector<float*> active_search_channels;
- for (int ch = 0; ch < channels_; ++ch) {
- if (channel_mask_[ch]) {
- active_target_channels.push_back(target_block_->channel(ch));
- active_search_channels.push_back(search_block_->channel(ch));
- }
- }
-
- target_block_wrapper_ =
- AudioBus::WrapVector(target_block_->frames(), active_target_channels);
- search_block_wrapper_ =
- AudioBus::WrapVector(search_block_->frames(), active_search_channels);
+ // Create potentially smaller wrappers for playback rate adaptation.
+ CreateSearchWrappers();
}
int rendered_frames = 0;
@@ -432,4 +423,22 @@ void AudioRendererAlgorithm::PeekAudioWithZeroPrepend(
write_offset, dest);
}
+void AudioRendererAlgorithm::CreateSearchWrappers() {
+ // WSOLA is quite expensive to run, so if a channel mask exists, use it to
+ // reduce the size of our search space.
+ std::vector<float*> active_target_channels;
+ std::vector<float*> active_search_channels;
+ for (int ch = 0; ch < channels_; ++ch) {
+ if (channel_mask_[ch]) {
+ active_target_channels.push_back(target_block_->channel(ch));
+ active_search_channels.push_back(search_block_->channel(ch));
+ }
+ }
+
+ target_block_wrapper_ =
+ AudioBus::WrapVector(target_block_->frames(), active_target_channels);
+ search_block_wrapper_ =
+ AudioBus::WrapVector(search_block_->frames(), active_search_channels);
+}
+
} // namespace media
« no previous file with comments | « media/filters/audio_renderer_algorithm.h ('k') | media/filters/audio_renderer_algorithm_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698