Skip to content

Commit

Permalink
1. fix AUDIO_WORKLET + MODULARIZE #19796
Browse files Browse the repository at this point in the history
2. reformat
  • Loading branch information
Misko Lee committed Sep 22, 2023
1 parent c65a321 commit 85f0865
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 1 addition & 5 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3920,15 +3920,10 @@ def modularize():
return %(return_value)s
}
%(capture_module_function_for_audio_worklet)s
''' % {
'maybe_async': async_emit,
'src': src,
'return_value': return_value,
# Given the async nature of how the Module function and Module object come into existence in AudioWorkletGlobalScope,
# store the Module function under a different variable name so that AudioWorkletGlobalScope will be able to reference
# it without aliasing/conflicting with the Module variable name.
'capture_module_function_for_audio_worklet': 'globalThis.AudioWorkletModule = Module;' if settings.AUDIO_WORKLET and settings.MODULARIZE else ''
}

if settings.MINIMAL_RUNTIME and not settings.PTHREADS:
Expand All @@ -3953,6 +3948,7 @@ def modularize():
%(script_url_node)s
return (%(src)s);
})();
globalThis.AudioWorkletModule = %(EXPORT_NAME)s;
''' % {
'node_imports': node_es6_imports(),
'EXPORT_NAME': settings.EXPORT_NAME,
Expand Down
7 changes: 7 additions & 0 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5611,6 +5611,13 @@ def test_audio_worklet(self, args):
def test_audio_worklet_post_function(self, args):
self.btest('webaudio/audioworklet_post_function.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'] + args, expected='1')

@parameterized({
'': ([],),
'closure': (['--closure', '1', '-Oz'],),
})
def test_audio_worklet_modularize(self, args):
self.btest_exit('webaudio/audioworklet.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-sMODULARIZE=1', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')] + args)

def test_error_reporting(self):
# Test catching/reporting Error objects
create_file('post.js', 'throw new Error("oops");')
Expand Down

0 comments on commit 85f0865

Please sign in to comment.