@@ -73,7 +73,7 @@ let LibraryWebAudio = {
7373 return ctx && emscriptenRegisterAudioObject ( new ctx ( opts ) ) ;
7474 } ,
7575
76- emscripten_resume_audio_context_async : ( contextHandle , callback , userData ) => {
76+ emscripten_resume_audio_context_async : async ( contextHandle , callback , userData ) => {
7777 function cb ( state ) {
7878#if WEBAUDIO_DEBUG
7979 console . log ( `emscripten_resume_audio_context_async() callback: New audio state="${ EmAudio [ contextHandle ] . state } ", ID=${ state } ` ) ;
@@ -83,7 +83,12 @@ let LibraryWebAudio = {
8383#if WEBAUDIO_DEBUG
8484 console . log ( `emscripten_resume_audio_context_async() resuming...` ) ;
8585#endif
86- EmAudio [ contextHandle ] . resume ( ) . then ( ( ) => { cb ( 1 /*running*/ ) } ) . catch ( ( ) => { cb ( 0 /*suspended*/ ) } ) ;
86+ try {
87+ await EmAudio [ contextHandle ] . resume ( ) ;
88+ cb ( 1 /*running*/ ) ;
89+ } catch {
90+ cb ( 0 /*suspended*/ ) ;
91+ }
8792 } ,
8893
8994 emscripten_resume_audio_context_sync : ( contextHandle ) => {
@@ -138,7 +143,7 @@ let LibraryWebAudio = {
138143 '$_wasmWorkersID' ,
139144 '$_EmAudioDispatchProcessorCallback' ,
140145 '$stackAlloc' , '$stackRestore' , '$stackSave' ] ,
141- emscripten_start_wasm_audio_worklet_thread_async : ( contextHandle , stackLowestAddress , stackSize , callback , userData ) => {
146+ emscripten_start_wasm_audio_worklet_thread_async : async ( contextHandle , stackLowestAddress , stackSize , callback , userData ) => {
142147
143148#if ASSERTIONS
144149 assert ( contextHandle , `Called emscripten_start_wasm_audio_worklet_thread_async() with a null Web Audio Context handle!` ) ;
@@ -183,7 +188,8 @@ let LibraryWebAudio = {
183188
184189 // TODO: In MINIMAL_RUNTIME builds, read this file off of a preloaded Blob,
185190 // and/or embed from a string like with WASM_WORKERS==2 mode.
186- audioWorklet . addModule ( '{{{ TARGET_BASENAME }}}.aw.js' ) . then ( ( ) => {
191+ try {
192+ await audioWorklet . addModule ( '{{{ TARGET_BASENAME }}}.aw.js' ) ;
187193#if WEBAUDIO_DEBUG
188194 console . log ( `emscripten_start_wasm_audio_worklet_thread_async() addModule('audioworklet.js') completed` ) ;
189195#endif
@@ -211,19 +217,20 @@ let LibraryWebAudio = {
211217 // either), but instead, the main thread must load all JS code into the
212218 // worklet scope. Send the application main JS script to the audio
213219 // worklet.
214- return audioWorklet . addModule (
220+ await audioWorklet . addModule (
215221#if MINIMAL_RUNTIME
216222 Module [ 'js' ]
217223#else
218224 Module [ 'mainScriptUrlOrBlob' ] || _scriptName
219225#endif
220226 ) ;
221- } ) . then ( ( ) => {
222227#if WEBAUDIO_DEBUG
223228 console . log ( `emscripten_start_wasm_audio_worklet_thread_async() addModule() of main application JS completed` ) ;
224229#endif
225230 { { { makeDynCall ( 'viii' , 'callback' ) } } } ( contextHandle , 1 /*EM_TRUE*/ , userData ) ;
226- } ) . catch ( audioWorkletCreationFailed ) ;
231+ } catch {
232+ audioWorkletCreationFailed ( ) ;
233+ }
227234 } ,
228235
229236 $_EmAudioDispatchProcessorCallback : ( e ) => {
0 commit comments