From 48b739028974f554767105e4ff62861de0c46cec Mon Sep 17 00:00:00 2001 From: Dan Minor Date: Thu, 21 Apr 2016 10:01:19 -0400 Subject: [PATCH] Bug 1266405 - AudioBufferSourceNode::CopyFromBuffer should not borrow unaligned buffers; r=padenot MozReview-Commit-ID: 82DZJ8BFWaq --HG-- extra : rebase_source : 20d5a43df87cf826971bef149a1f29ee75c1c0d2 --- dom/media/webaudio/AudioBufferSourceNode.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp index 677dea272b86..2e6586fd9a70 100644 --- a/dom/media/webaudio/AudioBufferSourceNode.cpp +++ b/dom/media/webaudio/AudioBufferSourceNode.cpp @@ -10,6 +10,7 @@ #include "mozilla/FloatingPoint.h" #include "nsContentUtils.h" #include "nsMathUtils.h" +#include "AlignmentUtils.h" #include "AudioNodeEngine.h" #include "AudioNodeStream.h" #include "AudioDestinationNode.h" @@ -410,7 +411,15 @@ public: uint32_t numFrames = std::min(aBufferMax - mBufferPosition, availableInOutput); - if (numFrames == WEBAUDIO_BLOCK_SIZE) { + + bool inputBufferAligned = true; + for (uint32_t i = 0; i < aChannels; ++i) { + if (!IS_ALIGNED16(mBuffer->GetData(i) + mBufferPosition)) { + inputBufferAligned = false; + } + } + + if (numFrames == WEBAUDIO_BLOCK_SIZE && inputBufferAligned) { MOZ_ASSERT(mBufferPosition < aBufferMax); BorrowFromInputBuffer(aOutput, aChannels); } else {