From 3752318631428262ff53485d8c0a8415616ec3d5 Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 6 Mar 2019 11:51:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=97=A0=E6=B3=95=E5=9C=A8iP?= =?UTF-8?q?hone=E4=B8=8A=E6=92=AD=E6=94=BE=E5=A3=B0=E9=9F=B3=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fc/js/nes-embed.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fc/js/nes-embed.js b/fc/js/nes-embed.js index 0925788..33b5d15 100644 --- a/fc/js/nes-embed.js +++ b/fc/js/nes-embed.js @@ -195,10 +195,14 @@ window.onload = function(){ } +var script_processor=null +var audio_ctx = null function initAudioEvent() { - var aaa = window.webkitAudioContext || window.AudioContext - var audio_ctx = new aaa(); - var script_processor = audio_ctx.createScriptProcessor(4096, 0, 2); + script_processor && (script_processor.disconnect(audio_ctx.destination), script_processor.onaudioprocess = null, script_processor = null) + audio_ctx && audio_ctx.close().catch(handleError) + window.AudioContext = window.webkitAudioContext || window.AudioContext + audio_ctx = new window.AudioContext (); + script_processor = audio_ctx.createScriptProcessor(4096, 0, 2); script_processor.onaudioprocess = audio_callback; script_processor.connect(audio_ctx.destination);