diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-05-10 14:37:50 +0200 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-05-20 13:47:45 +0000 |
commit | aeef4240d598a6e0e8be35c854ad26ff6d77fa3f (patch) | |
tree | c75da0be0a9fd7aa982972f6041f4c141786e7cf | |
parent | 938e6204efb8f47f8426aeb114c41d333e696d1a (diff) | |
download | UXP-aeef4240d598a6e0e8be35c854ad26ff6d77fa3f.tar UXP-aeef4240d598a6e0e8be35c854ad26ff6d77fa3f.tar.gz UXP-aeef4240d598a6e0e8be35c854ad26ff6d77fa3f.tar.lz UXP-aeef4240d598a6e0e8be35c854ad26ff6d77fa3f.tar.xz UXP-aeef4240d598a6e0e8be35c854ad26ff6d77fa3f.zip |
Issue #1589 - Ensure computed length and data is always available
-rw-r--r-- | dom/media/webaudio/AudioBuffer.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/dom/media/webaudio/AudioBuffer.cpp b/dom/media/webaudio/AudioBuffer.cpp index e4252dfcf..39fe8c735 100644 --- a/dom/media/webaudio/AudioBuffer.cpp +++ b/dom/media/webaudio/AudioBuffer.cpp @@ -254,6 +254,9 @@ void AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannelNumber, uint32_t aStartInChannel, ErrorResult& aRv) { + JS::AutoCheckCannotGC nogc; + aDestination.ComputeLengthAndData(); + uint32_t length = aDestination.Length(); CheckedInt<uint32_t> end = aStartInChannel; end += length; @@ -263,8 +266,6 @@ AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannel return; } - JS::AutoCheckCannotGC nogc; - aDestination.ComputeLengthAndData(); JSObject* channelArray = mJSChannels[aChannelNumber]; const float* sourceData = nullptr; if (channelArray) { @@ -295,6 +296,9 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource, uint32_t aChannelNumber, uint32_t aStartInChannel, ErrorResult& aRv) { + JS::AutoCheckCannotGC nogc; + aSource.ComputeLengthAndData(); + uint32_t length = aSource.Length(); CheckedInt<uint32_t> end = aStartInChannel; end += length; @@ -309,7 +313,6 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource, return; } - JS::AutoCheckCannotGC nogc; JSObject* channelArray = mJSChannels[aChannelNumber]; if (JS_GetTypedArrayLength(channelArray) != mLength) { // The array's buffer was detached. @@ -317,7 +320,6 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource, return; } - aSource.ComputeLengthAndData(); bool isShared = false; float* channelData = JS_GetFloat32ArrayData(channelArray, &isShared, nogc); // The channelData arrays should all have originated in |