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

Unified Diff: media/base/audio_buffer_converter.cc

Issue 217923002: Make sure AudioBufferConverter uses aligned AudioBus channels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « no previous file | media/base/audio_buffer_converter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_buffer_converter.cc
diff --git a/media/base/audio_buffer_converter.cc b/media/base/audio_buffer_converter.cc
index fd4ef43ce97ab3069eee92e8159e26d7d6e1192b..6f09015ce52f0cf8016aa9b0fed4bdcbe9dce986 100644
--- a/media/base/audio_buffer_converter.cc
+++ b/media/base/audio_buffer_converter.cc
@@ -198,10 +198,13 @@ void AudioBufferConverter::ConvertIfPossible() {
// The AudioConverter wants requests of a fixed size, so we'll slide an
// AudioBus of that size across the |output_buffer|.
while (frames_remaining != 0) {
- int frames_this_iteration =
- std::min(output_params_.frames_per_buffer(), frames_remaining);
-
- int offset_into_buffer = output_buffer->frame_count() - frames_remaining;
+ // It's important that this is a multiple of AudioBus::kChannelAlignment in
+ // all requests except for the last, otherwise downstream SIMD optimizations
+ // will crash on unaligned data.
+ const int frames_this_iteration = std::min(
+ static_cast<int>(SincResampler::kDefaultRequestSize), frames_remaining);
+ const int offset_into_buffer =
+ output_buffer->frame_count() - frames_remaining;
// Wrap the portion of the AudioBuffer in an AudioBus so the AudioConverter
// can fill it.
« no previous file with comments | « no previous file | media/base/audio_buffer_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698