mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-27 19:07:31 +09:00
Issue #1589 - Ensure computed length and data is always available
This commit is contained in:
parent
b490bda019
commit
84053aba97
1 changed files with 6 additions and 4 deletions
|
|
@ -254,6 +254,9 @@ void
|
||||||
AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannelNumber,
|
AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannelNumber,
|
||||||
uint32_t aStartInChannel, ErrorResult& aRv)
|
uint32_t aStartInChannel, ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
|
JS::AutoCheckCannotGC nogc;
|
||||||
|
aDestination.ComputeLengthAndData();
|
||||||
|
|
||||||
uint32_t length = aDestination.Length();
|
uint32_t length = aDestination.Length();
|
||||||
CheckedInt<uint32_t> end = aStartInChannel;
|
CheckedInt<uint32_t> end = aStartInChannel;
|
||||||
end += length;
|
end += length;
|
||||||
|
|
@ -263,8 +266,6 @@ AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannel
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::AutoCheckCannotGC nogc;
|
|
||||||
aDestination.ComputeLengthAndData();
|
|
||||||
JSObject* channelArray = mJSChannels[aChannelNumber];
|
JSObject* channelArray = mJSChannels[aChannelNumber];
|
||||||
const float* sourceData = nullptr;
|
const float* sourceData = nullptr;
|
||||||
if (channelArray) {
|
if (channelArray) {
|
||||||
|
|
@ -295,6 +296,9 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource,
|
||||||
uint32_t aChannelNumber, uint32_t aStartInChannel,
|
uint32_t aChannelNumber, uint32_t aStartInChannel,
|
||||||
ErrorResult& aRv)
|
ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
|
JS::AutoCheckCannotGC nogc;
|
||||||
|
aSource.ComputeLengthAndData();
|
||||||
|
|
||||||
uint32_t length = aSource.Length();
|
uint32_t length = aSource.Length();
|
||||||
CheckedInt<uint32_t> end = aStartInChannel;
|
CheckedInt<uint32_t> end = aStartInChannel;
|
||||||
end += length;
|
end += length;
|
||||||
|
|
@ -309,7 +313,6 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::AutoCheckCannotGC nogc;
|
|
||||||
JSObject* channelArray = mJSChannels[aChannelNumber];
|
JSObject* channelArray = mJSChannels[aChannelNumber];
|
||||||
if (JS_GetTypedArrayLength(channelArray) != mLength) {
|
if (JS_GetTypedArrayLength(channelArray) != mLength) {
|
||||||
// The array's buffer was detached.
|
// The array's buffer was detached.
|
||||||
|
|
@ -317,7 +320,6 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
aSource.ComputeLengthAndData();
|
|
||||||
bool isShared = false;
|
bool isShared = false;
|
||||||
float* channelData = JS_GetFloat32ArrayData(channelArray, &isShared, nogc);
|
float* channelData = JS_GetFloat32ArrayData(channelArray, &isShared, nogc);
|
||||||
// The channelData arrays should all have originated in
|
// The channelData arrays should all have originated in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue