Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ See docs/process.md for more on how version tagging works.
existence of `Buffer.from` which was added in v5.10.0. If it turns out
there is still a need to support these older node versions we can
add a polyfil under LEGACY_VM_SUPPORT (#14447).
- Added support for running Emscripten-compiled native code in AudioWorklets as
if they were regular pthreads. See `/tests/audioworklet/tone/` for a working
minimal example.

2.0.24 - 06/10/2021
-------------------
Expand Down Expand Up @@ -192,6 +195,9 @@ See docs/process.md for more on how version tagging works.
- You can now explicitly request that an environment variable remain unset by
setting its value in `ENV` to `undefined`. This is useful for variables, such
as `LANG`, for which Emscripten normally provides a default value.
- Added support for running Emscripten-compiled native code in AudioWorklets as
if they were regular pthreads. See `/tests/audioworklet/tone/` for a working
minimal example.

2.0.23 - 05/26/2021
-------------------
Expand Down
16 changes: 14 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
}


VALID_ENVIRONMENTS = ('web', 'webview', 'worker', 'node', 'shell')
VALID_ENVIRONMENTS = ('web', 'webview', 'worker', 'node', 'shell', 'audioworklet')
SIMD_INTEL_FEATURE_TOWER = ['-msse', '-msse2', '-msse3', '-mssse3', '-msse4.1', '-msse4.2', '-mavx']
SIMD_NEON_FLAGS = ['-mfpu=neon']
COMPILE_ONLY_FLAGS = set(['--default-obj-ext'])
Expand Down Expand Up @@ -297,6 +297,9 @@ def setup_environment_settings():
'worker' in environments or \
(settings.ENVIRONMENT_MAY_BE_NODE and settings.USE_PTHREADS)

# Worklet environment must be enabled explicitly for now
settings.ENVIRONMENT_MAY_BE_AUDIOWORKLET = 'audioworklet' in environments

if not settings.ENVIRONMENT_MAY_BE_WORKER and settings.PROXY_TO_WORKER:
exit_with_error('If you specify --proxy-to-worker and specify a "-s ENVIRONMENT=" directive, it must include "worker" as a target! (Try e.g. -s ENVIRONMENT=web,worker)')

Expand Down Expand Up @@ -1953,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',
]
Expand Down Expand Up @@ -3380,7 +3387,6 @@ def modularize():
f.write(src)

# Export using a UMD style export, or ES6 exports if selected

if settings.EXPORT_ES6:
f.write('export default %s;' % settings.EXPORT_NAME)
elif not settings.MINIMAL_RUNTIME:
Expand All @@ -3393,6 +3399,12 @@ def modularize():
exports["%(EXPORT_NAME)s"] = %(EXPORT_NAME)s;
''' % {'EXPORT_NAME': settings.EXPORT_NAME})

# Store the export on the global scope for audio worklets
if settings.ENVIRONMENT_MAY_BE_AUDIOWORKLET:
f.write(f'''if (typeof AudioWorkletGlobalScope === 'function')
globalThis["{settings.EXPORT_NAME}"] = {settings.EXPORT_NAME};
''')

shared.configuration.get_temp_files().note(final_js)
save_intermediate('modularized')

Expand Down
2 changes: 1 addition & 1 deletion src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -3434,7 +3434,7 @@ LibraryManager.library = {
$setWasmTableEntry__deps: ['$wasmTableMirror'],
$setWasmTableEntry: function(idx, func) {
wasmTable.set(idx, func);
wasmTableMirror[idx] = func;
wasmTableMirror[idx] = wasmTable.get(idx);
},

$getWasmTableEntry__internal: true,
Expand Down
Loading