diff --git a/emcc.py b/emcc.py index 31e711e22e419..25f44cd07ed3e 100755 --- a/emcc.py +++ b/emcc.py @@ -1956,6 +1956,10 @@ def default_setting(name, new_default): '_pthread_testcancel', '_exit', ] + if settings.ENVIRONMENT_MAY_BE_AUDIOWORKLET: + settings.EXPORTED_FUNCTIONS += [ + '_pthread_create', + ] settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += [ '$exitOnMainThread', ] diff --git a/src/library_pthread.js b/src/library_pthread.js index d9fd0fdebb16b..892fa5d8f5de8 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -431,7 +431,7 @@ var LibraryPThread = { PThread.unusedWorkers[0].postMessage(PThread.buildWorkerLoadMessage()); } return PThread.unusedWorkers.pop(); - } + }, busySpinWait: function(msecs) { var t = performance.now() + msecs; @@ -489,9 +489,7 @@ var LibraryPThread = { // This is sent from the worklet after the worker.js has processed the 'load' // commands and needs to load the main js (which it can't do directly in // AudioWorkletGlobalScope so we do it here from the main thread) - aw.addModule((Module['mainScriptUrlOrBlob'] || _scriptDir)).then(function() { - dummy.postMessage({'cmd': 'moduleloaded'}); - }); + aw.addModule((Module['mainScriptUrlOrBlob'] || _scriptDir)); } else if (cmd === 'running') { // This is notified to let us know the pthread environment is ready and we can go ahead // and create any pending AudioWorkletNodes