Merge pull request #43 from paulkaplan/fix-detached-buffer-error

Make a copy before using audio buffer
This commit is contained in:
Paul Kaplan 2017-06-14 12:31:36 -04:00 committed by GitHub
commit c85c757a72

View file

@ -232,12 +232,15 @@ class AudioEngine {
let loaderPromise = null;
// Make a copy of the buffer because decoding detaches the original buffer
var bufferCopy = sound.data.buffer.slice(0);
switch (sound.format) {
case '':
loaderPromise = Tone.context.decodeAudioData(sound.data.buffer);
loaderPromise = Tone.context.decodeAudioData(bufferCopy);
break;
case 'adpcm':
loaderPromise = (new ADPCMSoundDecoder()).decode(sound.data.buffer);
loaderPromise = (new ADPCMSoundDecoder()).decode(bufferCopy);
break;
default:
return log.warn('unknown sound format', sound.format);