mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 00:34:03 +02:00
Merge pull request #219 from HiberWorld/bugfix/intermediary-buffer-ref
Fix intermediaryBufferView losing reference to wasm memory after heap resize
This commit is contained in:
+10
@@ -31283,6 +31283,11 @@ static ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma
|
|||||||
return; /* This means the device has been uninitialized. */
|
return; /* This means the device has been uninitialized. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(device.intermediaryBufferView.length == 0) {
|
||||||
|
/* Recreate intermediaryBufferView when losing reference to the underlying buffer, probably due to emscripten resizing heap. */
|
||||||
|
device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure silence it output to the AudioContext destination. Not doing this will cause sound to come out of the speakers! */
|
/* Make sure silence it output to the AudioContext destination. Not doing this will cause sound to come out of the speakers! */
|
||||||
for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
|
for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
|
||||||
e.outputBuffer.getChannelData(iChannel).fill(0.0);
|
e.outputBuffer.getChannelData(iChannel).fill(0.0);
|
||||||
@@ -31343,6 +31348,11 @@ static ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma
|
|||||||
return; /* This means the device has been uninitialized. */
|
return; /* This means the device has been uninitialized. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(device.intermediaryBufferView.length == 0) {
|
||||||
|
/* Recreate intermediaryBufferView when losing reference to the underlying buffer, probably due to emscripten resizing heap. */
|
||||||
|
device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
|
||||||
|
}
|
||||||
|
|
||||||
var outputSilence = false;
|
var outputSilence = false;
|
||||||
|
|
||||||
/* Sanity check. This will never happen, right? */
|
/* Sanity check. This will never happen, right? */
|
||||||
|
|||||||
Reference in New Issue
Block a user