mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 880129 - Correctly handle AnalyserNodes with a buffer size smaller than 128; r=roc
This commit is contained in:
parent
970bda8200
commit
1391c0772c
9
content/media/test/crashtests/880129.html
Normal file
9
content/media/test/crashtests/880129.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script>
|
||||||
|
try { o1 = new window.AudioContext(3, 2, 44100); } catch(e) { }
|
||||||
|
try { o6 = o1.createBufferSource(); } catch(e) { }
|
||||||
|
try { o15 = o1.createAnalyser(); } catch(e) { }
|
||||||
|
try { o15.fftSize = 32; } catch(e) { }
|
||||||
|
try { o6.connect(o15,0,0) } catch(e) { }
|
||||||
|
try { o27 = o1.createPanner(); } catch(e) { }
|
||||||
|
try { o6.buffer = function(){var buffer = o1.createBuffer(2, 1148, o1.sampleRate);for(var c=0; c<2; c++) {for(var i=0; i<1148; i++) {buffer.getChannelData(c)[i] = 0;}}return buffer;}() } catch(e) { }
|
||||||
|
</script>
|
@ -38,4 +38,5 @@ load 878328.html
|
|||||||
load 878407.html
|
load 878407.html
|
||||||
load 878478.html
|
load 878478.html
|
||||||
load 877527.html
|
load 877527.html
|
||||||
|
load 880129.html
|
||||||
skip-if(B2G) load 880202.html # load failed, bug 833371 for B2G
|
skip-if(B2G) load 880202.html # load failed, bug 833371 for B2G
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "AudioNodeEngine.h"
|
#include "AudioNodeEngine.h"
|
||||||
#include "AudioNodeStream.h"
|
#include "AudioNodeStream.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
|
#include "mozilla/PodOperations.h"
|
||||||
#include "kiss_fft/kiss_fftr.h"
|
#include "kiss_fft/kiss_fftr.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
@ -275,12 +276,17 @@ AnalyserNode::AppendChunk(const AudioChunk& aChunk)
|
|||||||
{
|
{
|
||||||
const uint32_t bufferSize = mBuffer.Length();
|
const uint32_t bufferSize = mBuffer.Length();
|
||||||
const uint32_t channelCount = aChunk.mChannelData.Length();
|
const uint32_t channelCount = aChunk.mChannelData.Length();
|
||||||
const uint32_t chunkCount = aChunk.mDuration;
|
uint32_t chunkDuration = aChunk.mDuration;
|
||||||
MOZ_ASSERT((bufferSize & (bufferSize - 1)) == 0); // Must be a power of two!
|
MOZ_ASSERT((bufferSize & (bufferSize - 1)) == 0); // Must be a power of two!
|
||||||
MOZ_ASSERT(channelCount > 0);
|
MOZ_ASSERT(channelCount > 0);
|
||||||
MOZ_ASSERT(chunkCount == WEBAUDIO_BLOCK_SIZE);
|
MOZ_ASSERT(chunkDuration == WEBAUDIO_BLOCK_SIZE);
|
||||||
|
|
||||||
memcpy(mBuffer.Elements() + mWriteIndex, aChunk.mChannelData[0], sizeof(float) * chunkCount);
|
if (chunkDuration > bufferSize) {
|
||||||
|
// Copy a maximum bufferSize samples.
|
||||||
|
chunkDuration = bufferSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
PodCopy(mBuffer.Elements() + mWriteIndex, static_cast<const float*>(aChunk.mChannelData[0]), chunkDuration);
|
||||||
for (uint32_t i = 1; i < channelCount; ++i) {
|
for (uint32_t i = 1; i < channelCount; ++i) {
|
||||||
AudioBlockAddChannelWithScale(static_cast<const float*>(aChunk.mChannelData[i]), 1.0f,
|
AudioBlockAddChannelWithScale(static_cast<const float*>(aChunk.mChannelData[i]), 1.0f,
|
||||||
mBuffer.Elements() + mWriteIndex);
|
mBuffer.Elements() + mWriteIndex);
|
||||||
@ -289,7 +295,7 @@ AnalyserNode::AppendChunk(const AudioChunk& aChunk)
|
|||||||
AudioBlockInPlaceScale(mBuffer.Elements() + mWriteIndex, 1,
|
AudioBlockInPlaceScale(mBuffer.Elements() + mWriteIndex, 1,
|
||||||
1.0f / aChunk.mChannelData.Length());
|
1.0f / aChunk.mChannelData.Length());
|
||||||
}
|
}
|
||||||
mWriteIndex += chunkCount;
|
mWriteIndex += chunkDuration;
|
||||||
MOZ_ASSERT(mWriteIndex <= bufferSize);
|
MOZ_ASSERT(mWriteIndex <= bufferSize);
|
||||||
if (mWriteIndex >= bufferSize) {
|
if (mWriteIndex >= bufferSize) {
|
||||||
mWriteIndex = 0;
|
mWriteIndex = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user