Bug 1266047 - Fix crash in mozilla::AudioBufferAddWithScale_SSE r=padenot

This adds alignment checks to fallback to scalar operations if the
received buffers are not properly aligned. Bug 1266112 is the follow on
to either fix the alignment problem or add a vector path for the aligned
portion of the buffers.

MozReview-Commit-ID: 5HCXzipXlqD

--HG--
extra : rebase_source : 0dff8258c4cc0d468c18267680f053ff1a240ad5
This commit is contained in:
Dan Minor 2016-04-20 11:54:50 -04:00
parent 983f3c49d1
commit eb586d648d
2 changed files with 13 additions and 6 deletions

View File

@ -10,6 +10,7 @@
#include "AudioNodeEngineNEON.h"
#endif
#ifdef USE_SSE2
#include "AlignmentUtils.h"
#include "AudioNodeEngineSSE2.h"
#endif
@ -76,7 +77,10 @@ void AudioBufferAddWithScale(const float* aInput,
#endif
#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
// TODO: See Bug 1266112, we should either fix the source of the unaligned
// buffers or do as much as possible with vector instructions and
// fallback to scalar instructions where necessary.
if (mozilla::supports_sse2() && IS_ALIGNED16(aInput) && IS_ALIGNED16(aOutput)) {
AudioBufferAddWithScale_SSE(aInput, aScale, aOutput, aSize);
return;
}
@ -117,10 +121,13 @@ AudioBlockCopyChannelWithScale(const float* aInput,
#endif
#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
AudioBlockCopyChannelWithScale_SSE(aInput, aScale, aOutput);
return;
}
// TODO: See Bug 1266112, we should either fix the source of the unaligned
// buffers or do as much as possible with vector instructions and
// fallback to scalar instructions where necessary.
if (mozilla::supports_sse2() && IS_ALIGNED16(aInput) && IS_ALIGNED16(aOutput)) {
AudioBlockCopyChannelWithScale_SSE(aInput, aScale, aOutput);
return;
}
#endif
for (uint32_t i = 0; i < WEBAUDIO_BLOCK_SIZE; ++i) {

View File

@ -3,8 +3,8 @@
* license, v. 2.0. if a copy of the mpl was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AlignmentUtils.h"
#include "AudioNodeEngineSSE2.h"
#include "AlignmentUtils.h"
#include <emmintrin.h>