[dom] Reorder some calls to improve memory safety.
parent
48a4b4f8c2
commit
169b4a77e7
|
@ -254,8 +254,6 @@ 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)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -266,6 +264,7 @@ AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::AutoCheckCannotGC nogc;
|
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) {
|
||||||
|
@ -296,8 +295,6 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource,
|
||||||
uint32_t aChannelNumber, uint32_t aStartInChannel,
|
uint32_t aChannelNumber, uint32_t aStartInChannel,
|
||||||
ErrorResult& aRv)
|
ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -320,6 +317,7 @@ 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…
Reference in New Issue