diff --git a/src/audio_worklet.js b/src/audio_worklet.js index e427e4ee3519a..4691475782083 100644 --- a/src/audio_worklet.js +++ b/src/audio_worklet.js @@ -25,7 +25,7 @@ function createWasmAudioWorkletProcessor(audioParams) { assert(opts.callback) assert(opts.samplesPerChannel) #endif - this.callback = getWasmTableEntry(opts.callback); + this.callback = {{{ makeDynCall('iipipipp', 'opts.callback') }}}; this.userData = opts.userData; // Then the samples per channel to process, fixed for the lifetime of the // context that created this processor. Note for when moving to Web Audio @@ -65,48 +65,48 @@ function createWasmAudioWorkletProcessor(audioParams) { inputsPtr = stackAlloc(stackMemoryNeeded); // Copy input audio descriptor structs and data to Wasm - k = inputsPtr >> 2; + k = inputsPtr; dataPtr = inputsPtr + numInputs * {{{ C_STRUCTS.AudioSampleFrame.__size__ }}}; for (i of inputList) { // Write the AudioSampleFrame struct instance - HEAPU32[k + {{{ C_STRUCTS.AudioSampleFrame.numberOfChannels / 4 }}}] = i.length; - HEAPU32[k + {{{ C_STRUCTS.AudioSampleFrame.samplesPerChannel / 4 }}}] = this.samplesPerChannel; - HEAPU32[k + {{{ C_STRUCTS.AudioSampleFrame.data / 4 }}}] = dataPtr; - k += {{{ C_STRUCTS.AudioSampleFrame.__size__ / 4 }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioSampleFrame.numberOfChannels, 'i.length', 'u32') }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioSampleFrame.samplesPerChannel, 'this.samplesPerChannel', 'u32') }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioSampleFrame.data, 'dataPtr', '*') }}}; + k += {{{ C_STRUCTS.AudioSampleFrame.__size__ }}}; // Marshal the input audio sample data for each audio channel of this input for (j of i) { - HEAPF32.set(j, dataPtr>>2); + HEAPF32.set(j, {{{ getHeapOffset('dataPtr', 'float') }}}); dataPtr += bytesPerChannel; } } // Copy output audio descriptor structs to Wasm outputsPtr = dataPtr; - k = outputsPtr >> 2; - outputDataPtr = (dataPtr += numOutputs * {{{ C_STRUCTS.AudioSampleFrame.__size__ }}}) >> 2; + k = outputsPtr; + outputDataPtr = (dataPtr += numOutputs * {{{ C_STRUCTS.AudioSampleFrame.__size__ }}}); for (i of outputList) { // Write the AudioSampleFrame struct instance - HEAPU32[k + {{{ C_STRUCTS.AudioSampleFrame.numberOfChannels / 4 }}}] = i.length; - HEAPU32[k + {{{ C_STRUCTS.AudioSampleFrame.samplesPerChannel / 4 }}}] = this.samplesPerChannel; - HEAPU32[k + {{{ C_STRUCTS.AudioSampleFrame.data / 4 }}}] = dataPtr; - k += {{{ C_STRUCTS.AudioSampleFrame.__size__ / 4 }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioSampleFrame.numberOfChannels, 'i.length', 'u32') }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioSampleFrame.samplesPerChannel, 'this.samplesPerChannel', 'u32') }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioSampleFrame.data, 'dataPtr', '*') }}}; + k += {{{ C_STRUCTS.AudioSampleFrame.__size__ }}}; // Reserve space for the output data dataPtr += bytesPerChannel * i.length; } // Copy parameters descriptor structs and data to Wasm paramsPtr = dataPtr; - k = paramsPtr >> 2; + k = paramsPtr; dataPtr += numParams * {{{ C_STRUCTS.AudioParamFrame.__size__ }}}; for (i = 0; paramArray = parameters[i++];) { // Write the AudioParamFrame struct instance - HEAPU32[k + {{{ C_STRUCTS.AudioParamFrame.length / 4 }}}] = paramArray.length; - HEAPU32[k + {{{ C_STRUCTS.AudioParamFrame.data / 4 }}}] = dataPtr; - k += {{{ C_STRUCTS.AudioParamFrame.__size__ / 4 }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioParamFrame.length, 'paramArray.length', 'u32') }}}; + {{{ makeSetValue('k', C_STRUCTS.AudioParamFrame.data, 'dataPtr', '*') }}}; + k += {{{ C_STRUCTS.AudioParamFrame.__size__ }}}; // Marshal the audio parameters array - HEAPF32.set(paramArray, dataPtr>>2); - dataPtr += paramArray.length*4; + HEAPF32.set(paramArray, {{{ getHeapOffset('dataPtr', 'float') }}}); + dataPtr += paramArray.length * {{{ getNativeTypeSize('float') }}}; } // Call out to Wasm callback to perform audio processing @@ -115,6 +115,7 @@ function createWasmAudioWorkletProcessor(audioParams) { // (A garbage-free function TypedArray.copy(dstTypedArray, dstOffset, // srcTypedArray, srcOffset, count) would sure be handy.. but web does // not have one, so manually copy all bytes in) + outputDataPtr = {{{ getHeapOffset('outputDataPtr', 'float') }}}; for (i of outputList) { for (j of i) { for (k = 0; k < this.samplesPerChannel; ++k) { @@ -167,8 +168,12 @@ class BootstrapMessages extends AudioWorkletProcessor { // of the emscripten_create_wasm_audio_worklet_processor_async() call. // // '_wsc' is short for 'wasm call', using an identifier that will never - // conflict with user messages - messagePort.postMessage({'_wsc': d.callback, args: [d.contextHandle, 1/*EM_TRUE*/, d.userData] }); + // conflict with user messages. + // + // Note: we convert the pointer arg manually here since the call site + // ($_EmAudioDispatchProcessorCallback) is used with various signatures + // and we do not know the types in advance. + messagePort.postMessage({'_wsc': d.callback, args: [d.contextHandle, 1/*EM_TRUE*/, {{{ to64('d.userData') }}}] }); } else if (d['_wsc']) { getWasmTableEntry(d['_wsc'])(...d.args); }; diff --git a/src/lib/libwebaudio.js b/src/lib/libwebaudio.js index 87eb86c07d56f..b6a357bc01f9b 100644 --- a/src/lib/libwebaudio.js +++ b/src/lib/libwebaudio.js @@ -78,7 +78,7 @@ var LibraryWebAudio = { #if WEBAUDIO_DEBUG console.log(`emscripten_resume_audio_context_async() callback: New audio state="${EmAudio[contextHandle].state}", ID=${state}`); #endif - {{{ makeDynCall('viii', 'callback') }}}(contextHandle, state, userData); + {{{ makeDynCall('viip', 'callback') }}}(contextHandle, state, userData); } #if WEBAUDIO_DEBUG console.log(`emscripten_resume_audio_context_async() resuming...`); @@ -202,7 +202,7 @@ var LibraryWebAudio = { } }); audioWorklet.bootstrapMessage.port.onmessage = _EmAudioDispatchProcessorCallback; - {{{ makeDynCall('viii', 'callback') }}}(contextHandle, 1/*EM_TRUE*/, userData); + {{{ makeDynCall('viip', 'callback') }}}(contextHandle, 1/*EM_TRUE*/, userData); }).catch(audioWorkletCreationFailed); }, @@ -210,7 +210,8 @@ var LibraryWebAudio = { $_EmAudioDispatchProcessorCallback: (e) => { var data = e.data; // '_wsc' is short for 'wasm call', trying to use an identifier name that - // will never conflict with user code + // will never conflict with user code. This is used to call both the 3-param + // call (handle, true, userData) and the variable argument post functions. var wasmCall = data['_wsc']; wasmCall && getWasmTableEntry(wasmCall)(...data.args); }, @@ -222,24 +223,25 @@ var LibraryWebAudio = { assert(EmAudio[contextHandle] instanceof (window.AudioContext || window.webkitAudioContext), `Called emscripten_create_wasm_audio_worklet_processor_async() on a context handle ${contextHandle} that is not an AudioContext, but of type ${typeof EmAudio[contextHandle]}`); #endif - options >>= 2; - var audioParams = [], - numAudioParams = HEAPU32[options+1], - audioParamDescriptors = HEAPU32[options+2] >> 2, - i = 0; + var audioParams = []; + var processorName = UTF8ToString({{{ makeGetValue('options', C_STRUCTS.WebAudioWorkletProcessorCreateOptions.name, '*') }}}); + var numAudioParams = {{{ makeGetValue('options', C_STRUCTS.WebAudioWorkletProcessorCreateOptions.numAudioParams, 'i32') }}}; + var audioParamDescriptors = {{{ makeGetValue('options', C_STRUCTS.WebAudioWorkletProcessorCreateOptions.audioParamDescriptors, '*') }}}; + var paramIndex = 0; while (numAudioParams--) { audioParams.push({ - name: i++, - defaultValue: HEAPF32[audioParamDescriptors++], - minValue: HEAPF32[audioParamDescriptors++], - maxValue: HEAPF32[audioParamDescriptors++], - automationRate: ['a','k'][HEAPU32[audioParamDescriptors++]] + '-rate', + name: paramIndex++, + defaultValue: {{{ makeGetValue('audioParamDescriptors', C_STRUCTS.WebAudioParamDescriptor.defaultValue, 'float') }}}, + minValue: {{{ makeGetValue('audioParamDescriptors', C_STRUCTS.WebAudioParamDescriptor.minValue, 'float') }}}, + maxValue: {{{ makeGetValue('audioParamDescriptors', C_STRUCTS.WebAudioParamDescriptor.maxValue, 'float') }}}, + automationRate: ({{{ makeGetValue('audioParamDescriptors', C_STRUCTS.WebAudioParamDescriptor.automationRate, 'i32') }}} ? 'k' : 'a') + '-rate', }); + audioParamDescriptors += {{{ C_STRUCTS.WebAudioParamDescriptor.__size__ }}}; } #if WEBAUDIO_DEBUG - console.log(`emscripten_create_wasm_audio_worklet_processor_async() creating a new AudioWorklet processor with name ${UTF8ToString(HEAPU32[options])}`); + console.log(`emscripten_create_wasm_audio_worklet_processor_async() creating a new AudioWorklet processor with name ${processorName}`); #endif EmAudio[contextHandle].audioWorklet.bootstrapMessage.port.postMessage({ @@ -247,7 +249,7 @@ var LibraryWebAudio = { // Processor Name' used as a 'key' to verify the message type so as to // not get accidentally mixed with user submitted messages, the remainder // for space saving reasons, abbreviated from their variable names). - '_wpn': UTF8ToString(HEAPU32[options]), + '_wpn': processorName, audioParams, contextHandle, callback, @@ -262,18 +264,20 @@ var LibraryWebAudio = { assert(EmAudio[contextHandle], `Called emscripten_create_wasm_audio_worklet_node() with a nonexisting/already freed Web Audio Context handle ${contextHandle}!`); assert(EmAudio[contextHandle] instanceof (window.AudioContext || window.webkitAudioContext), `Called emscripten_create_wasm_audio_worklet_node() on a context handle ${contextHandle} that is not an AudioContext, but of type ${typeof EmAudio[contextHandle]}`); #endif - options >>= 2; function readChannelCountArray(heapIndex, numOutputs) { + if (!heapIndex) return undefined; + heapIndex = {{{ getHeapOffset('heapIndex', 'i32') }}}; var channelCounts = []; while (numOutputs--) channelCounts.push(HEAPU32[heapIndex++]); return channelCounts; } + var optionsOutputs = options ? {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.numberOfOutputs, 'i32') }}} : 0; var opts = options ? { - numberOfInputs: HEAP32[options], - numberOfOutputs: HEAP32[options+1], - outputChannelCount: HEAPU32[options+2] ? readChannelCountArray(HEAPU32[options+2]>>2, HEAP32[options+1]) : undefined, + numberOfInputs: {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.numberOfInputs, 'i32') }}}, + numberOfOutputs: optionsOutputs, + outputChannelCount: readChannelCountArray({{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.outputChannelCounts, 'i32*') }}}, optionsOutputs), processorOptions: { callback, userData, diff --git a/src/struct_info.json b/src/struct_info.json index e94e38326b46e..13012a6aaf176 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1266,6 +1266,17 @@ { "file": "emscripten/webaudio.h", "structs": { + "WebAudioParamDescriptor": [ + "defaultValue", + "minValue", + "maxValue", + "automationRate" + ], + "WebAudioWorkletProcessorCreateOptions": [ + "name", + "numAudioParams", + "audioParamDescriptors" + ], "AudioSampleFrame": [ "numberOfChannels", "samplesPerChannel", @@ -1274,6 +1285,11 @@ "AudioParamFrame": [ "length", "data" + ], + "EmscriptenAudioWorkletNodeCreateOptions": [ + "numberOfInputs", + "numberOfOutputs", + "outputChannelCounts" ] } }, diff --git a/src/struct_info_generated.json b/src/struct_info_generated.json index f16041377e17d..72227e94a5170 100644 --- a/src/struct_info_generated.json +++ b/src/struct_info_generated.json @@ -534,6 +534,12 @@ "numberOfChannels": 0, "samplesPerChannel": 4 }, + "EmscriptenAudioWorkletNodeCreateOptions": { + "__size__": 12, + "numberOfInputs": 0, + "numberOfOutputs": 4, + "outputChannelCounts": 8 + }, "EmscriptenBatteryEvent": { "__size__": 32, "charging": 24, @@ -1479,6 +1485,19 @@ "module": 4, "nextInChain": 0 }, + "WebAudioParamDescriptor": { + "__size__": 16, + "automationRate": 12, + "defaultValue": 0, + "maxValue": 8, + "minValue": 4 + }, + "WebAudioWorkletProcessorCreateOptions": { + "__size__": 12, + "audioParamDescriptors": 8, + "name": 0, + "numAudioParams": 4 + }, "__cxa_exception": { "__size__": 24, "adjustedPtr": 16, diff --git a/src/struct_info_generated_wasm64.json b/src/struct_info_generated_wasm64.json index cf131c464ce4a..225ff0809f608 100644 --- a/src/struct_info_generated_wasm64.json +++ b/src/struct_info_generated_wasm64.json @@ -534,6 +534,12 @@ "numberOfChannels": 0, "samplesPerChannel": 4 }, + "EmscriptenAudioWorkletNodeCreateOptions": { + "__size__": 16, + "numberOfInputs": 0, + "numberOfOutputs": 4, + "outputChannelCounts": 8 + }, "EmscriptenBatteryEvent": { "__size__": 32, "charging": 24, @@ -1479,6 +1485,19 @@ "module": 8, "nextInChain": 0 }, + "WebAudioParamDescriptor": { + "__size__": 16, + "automationRate": 12, + "defaultValue": 0, + "maxValue": 8, + "minValue": 4 + }, + "WebAudioWorkletProcessorCreateOptions": { + "__size__": 24, + "audioParamDescriptors": 16, + "name": 0, + "numAudioParams": 8 + }, "__cxa_exception": { "__size__": 48, "adjustedPtr": 32, diff --git a/test/code_size/audio_worklet_wasm.js b/test/code_size/audio_worklet_wasm.js index 3ab8a368262e5..b3130bc397e79 100644 --- a/test/code_size/audio_worklet_wasm.js +++ b/test/code_size/audio_worklet_wasm.js @@ -1,78 +1,79 @@ -var k = globalThis.Module || "undefined" != typeof Module ? Module : {}, p = "em-ww" == globalThis.name, q = "undefined" !== typeof AudioWorkletGlobalScope, r, v, L, M, G, I, C, X, J, E, D, Y, Z; +var l = globalThis.Module || "undefined" != typeof Module ? Module : {}, n = "em-ww" == globalThis.name, q = "undefined" !== typeof AudioWorkletGlobalScope, r, u, K, L, F, H, B, X, I, D, C, Y, Z; -q && (p = !0); +q && (n = !0); -function u(a) { +function t(a) { r = a; - v = a.I; + u = a.I; x(); - k ||= {}; - k.wasm = a.C; + l ||= {}; + l.wasm = a.C; y(); a.C = a.J = 0; } -p && !q && (onmessage = a => { +n && !q && (onmessage = a => { onmessage = null; - u(a.data); + t(a.data); }); if (q) { function a(c) { - class d extends AudioWorkletProcessor { - constructor(e) { + class e extends AudioWorkletProcessor { + constructor(d) { super(); - e = e.processorOptions; - this.u = C.get(e.u); - this.v = e.v; - this.s = e.s; + d = d.processorOptions; + this.u = B.get(d.u); + this.v = d.v; + this.s = d.s; } static get parameterDescriptors() { return c; } - process(e, h, f) { - let m = e.length, w = h.length, F = 0, l, z, n, t = 4 * this.s, g = 12 * (m + w), W = D(), A, H, B; - for (l of e) g += l.length * t; - for (l of h) g += l.length * t; - for (l in f) g += f[l].byteLength + 8, ++F; - A = E(g); - g = A >> 2; - n = A + 12 * m; - for (l of e) { - G[g] = l.length; - G[g + 1] = this.s; - G[g + 2] = n; - g += 3; - for (z of l) I.set(z, n >> 2), n += t; + process(d, g, h) { + let p = d.length, v = g.length, E = 0, k, z, m, w = 4 * this.s, f = 12 * (p + v), W = C(), G, P, A; + for (k of d) f += k.length * w; + for (k of g) f += k.length * w; + for (k in h) f += h[k].byteLength + 8, ++E; + f = G = D(f); + m = G + 12 * p; + for (k of d) { + F[f >> 2] = k.length; + F[f + 4 >> 2] = this.s; + F[f + 8 >> 2] = m; + f += 12; + for (z of k) H.set(z, m >> 2), m += w; } - H = n; - g = H >> 2; - e = (n += 12 * w) >> 2; - for (l of h) G[g] = l.length, G[g + 1] = this.s, G[g + 2] = n, g += 3, n += t * l.length; - t = n; - g = t >> 2; - n += 8 * F; - for (l = 0; B = f[l++]; ) G[g] = B.length, G[g + 1] = n, g += 2, I.set(B, n >> 2), - n += 4 * B.length; - if (f = this.u(m, A, w, H, F, t, this.v)) for (l of h) for (z of l) for (g = 0; g < this.s; ++g) z[g] = I[e++]; - J(W); - return !!f; + f = P = m; + d = m += 12 * v; + for (k of g) F[f >> 2] = k.length, F[f + 4 >> 2] = this.s, F[f + 8 >> 2] = m, f += 12, + m += w * k.length; + f = w = m; + m += 8 * E; + for (k = 0; A = h[k++]; ) F[f >> 2] = A.length, F[f + 4 >> 2] = m, f += 8, H.set(A, m >> 2), + m += 4 * A.length; + if (h = this.u(p, G, v, P, E, w, this.v)) { + d >>= 2; + for (k of g) for (z of k) for (f = 0; f < this.s; ++f) z[f] = H[d++]; + } + I(W); + return !!h; } } - return d; + return e; } - var K; + var J; class b extends AudioWorkletProcessor { constructor(c) { super(); - u(c.processorOptions); - K = this.port; - K.onmessage = async d => { - d = d.data; - d._wpn ? (registerProcessor(d._wpn, a(d.D)), K.postMessage({ - _wsc: d.u, - A: [ d.F, 1, d.v ] - })) : d._wsc && C.get(d._wsc)(...d.A); + t(c.processorOptions); + J = this.port; + J.onmessage = async e => { + e = e.data; + e._wpn ? (registerProcessor(e._wpn, a(e.D)), J.postMessage({ + _wsc: e.u, + A: [ e.F, 1, e.v ] + })) : e._wsc && B.get(e._wsc)(...e.A); }; } process() {} @@ -81,118 +82,118 @@ if (q) { } function x() { - var a = v.buffer; - L = new Uint8Array(a); - M = new Int32Array(a); - G = new Uint32Array(a); - I = new Float32Array(a); + var a = u.buffer; + K = new Uint8Array(a); + L = new Int32Array(a); + F = new Uint32Array(a); + H = new Float32Array(a); } -p || (v = k.mem || new WebAssembly.Memory({ +n || (u = l.mem || new WebAssembly.Memory({ initial: 256, maximum: 256, shared: !0 }), x()); -var N = [], O = a => { +var M = [], N = a => { a = a.data; let b = a._wsc; - b && C.get(b)(...a.x); -}, P = a => { - N.push(a); -}, Q = a => J(a), R = () => D(), aa = (a, b, c, d) => { + b && B.get(b)(...a.x); +}, O = a => { + M.push(a); +}, Q = a => I(a), R = () => C(), aa = (a, b, c, e) => { b = S[b]; - S[a].connect(b.destination || b, c, d); + S[a].connect(b.destination || b, c, e); }, S = {}, T = 0, U = "undefined" != typeof TextDecoder ? new TextDecoder : void 0, V = (a = 0) => { - for (var b = L, c = a, d = c + void 0; b[c] && !(c >= d); ) ++c; + for (var b = K, c = a, e = c + void 0; b[c] && !(c >= e); ) ++c; if (16 < c - a && b.buffer && U) return U.decode(b.slice(a, c)); - for (d = ""; a < c; ) { - var e = b[a++]; - if (e & 128) { - var h = b[a++] & 63; - if (192 == (e & 224)) d += String.fromCharCode((e & 31) << 6 | h); else { - var f = b[a++] & 63; - e = 224 == (e & 240) ? (e & 15) << 12 | h << 6 | f : (e & 7) << 18 | h << 12 | f << 6 | b[a++] & 63; - 65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023)); + for (e = ""; a < c; ) { + var d = b[a++]; + if (d & 128) { + var g = b[a++] & 63; + if (192 == (d & 224)) e += String.fromCharCode((d & 31) << 6 | g); else { + var h = b[a++] & 63; + d = 224 == (d & 240) ? (d & 15) << 12 | g << 6 | h : (d & 7) << 18 | g << 12 | h << 6 | b[a++] & 63; + 65536 > d ? e += String.fromCharCode(d) : (d -= 65536, e += String.fromCharCode(55296 | d >> 10, 56320 | d & 1023)); } - } else d += String.fromCharCode(e); + } else e += String.fromCharCode(d); } - return d; + return e; }, ba = a => { var b = window.AudioContext || window.webkitAudioContext; if (a >>= 2) { - var c = G[a] ? (c = G[a]) ? V(c) : "" : void 0; + var c = F[a] ? (c = F[a]) ? V(c) : "" : void 0; a = { latencyHint: c, - sampleRate: M[a + 1] || void 0 + sampleRate: L[a + 1] || void 0 }; } else a = void 0; if (c = b) b = new b(a), S[++T] = b, c = T; return c; -}, ca = (a, b, c, d, e) => { - if (c >>= 2) { - var h = M[c], f = M[c + 1]; - if (G[c + 2]) { - var m = G[c + 2] >> 2; - c = M[c + 1]; - for (var w = []; c--; ) w.push(G[m++]); - m = w; - } else m = void 0; - d = { +}, ca = (a, b, c, e, d) => { + var g = c ? L[c + 4 >> 2] : 0; + if (c) { + var h = L[c >> 2]; + c = F[c + 8 >> 2]; + var p = g; + if (c) { + c >>= 2; + for (var v = []; p--; ) v.push(F[c++]); + c = v; + } else c = void 0; + e = { numberOfInputs: h, - numberOfOutputs: f, - outputChannelCount: m, + numberOfOutputs: g, + outputChannelCount: c, processorOptions: { - u: d, - v: e, + u: e, + v: d, s: 128 } }; - } else d = void 0; - a = new AudioWorkletNode(S[a], b ? V(b) : "", d); + } else e = void 0; + a = new AudioWorkletNode(S[a], b ? V(b) : "", e); S[++T] = a; return T; -}, da = (a, b, c, d) => { - b >>= 2; - for (var e = [], h = G[b + 1], f = G[b + 2] >> 2, m = 0; h--; ) e.push({ - name: m++, - defaultValue: I[f++], - minValue: I[f++], - maxValue: I[f++], - automationRate: [ "a", "k" ][G[f++]] + "-rate" - }); - h = S[a].audioWorklet.B.port; - f = h.postMessage; - b = (b = G[b]) ? V(b) : ""; - f.call(h, { - _wpn: b, - D: e, +}, da = (a, b, c, e) => { + var d = [], g = (g = F[b >> 2]) ? V(g) : "", h = L[b + 4 >> 2]; + b = F[b + 8 >> 2]; + for (var p = 0; h--; ) d.push({ + name: p++, + defaultValue: H[b >> 2], + minValue: H[b + 4 >> 2], + maxValue: H[b + 8 >> 2], + automationRate: (L[b + 12 >> 2] ? "k" : "a") + "-rate" + }), b += 16; + S[a].audioWorklet.B.port.postMessage({ + _wpn: g, + D: d, F: a, u: c, - v: d + v: e }); }, ea = () => !1, fa = 1, ha = a => { a = a.data; var b = a._wsc; - b && C.get(b)(...a.A); -}, ia = a => E(a), ja = (a, b, c, d, e) => { - var h = S[a], f = h.audioWorklet, m = () => { - C.get(d)(a, 0, e); + b && B.get(b)(...a.A); +}, ia = a => D(a), ja = (a, b, c, e, d) => { + var g = S[a], h = g.audioWorklet, p = () => { + B.get(e)(a, 0, d); }; - if (!f) return m(); - f.addModule(k.js).then((() => { - f.B = new AudioWorkletNode(h, "em-bootstrap", { + if (!h) return p(); + h.addModule(l.js).then((() => { + h.B = new AudioWorkletNode(g, "em-bootstrap", { processorOptions: { K: fa++, - C: k.wasm, - I: v, + C: l.wasm, + I: u, G: b, H: c } }); - f.B.port.onmessage = ha; - C.get(d)(a, 1, e); - })).catch(m); + h.B.port.onmessage = ha; + B.get(e)(a, 1, d); + })).catch(p); }; function ka(a) { @@ -214,26 +215,26 @@ function y() { e: da, b: ea, c: ja, - a: v + a: u }; - WebAssembly.instantiate(k.wasm, { + WebAssembly.instantiate(l.wasm, { a: Z }).then((a => { a = a.instance.exports; X = a.j; - J = a.l; - E = a.m; - D = a.n; + I = a.l; + D = a.m; + C = a.n; Y = a.o; - C = a.k; - k.stackSave = R; - k.stackAlloc = ia; - k.stackRestore = Q; - k.wasmTable = C; - p ? (Y(r.G, r.H), "undefined" === typeof AudioWorkletGlobalScope && (removeEventListener("message", P), - N = N.forEach(O), addEventListener("message", O))) : a.i(); - p || X(); + B = a.k; + l.stackSave = R; + l.stackAlloc = ia; + l.stackRestore = Q; + l.wasmTable = B; + n ? (Y(r.G, r.H), "undefined" === typeof AudioWorkletGlobalScope && (removeEventListener("message", O), + M = M.forEach(N), addEventListener("message", N))) : a.i(); + n || X(); })); } -p || y(); \ No newline at end of file +n || y(); \ No newline at end of file diff --git a/test/code_size/audio_worklet_wasm.json b/test/code_size/audio_worklet_wasm.json index 9648aff3d49a7..ac82d5d9d9179 100644 --- a/test/code_size/audio_worklet_wasm.json +++ b/test/code_size/audio_worklet_wasm.json @@ -1,10 +1,10 @@ { "a.html": 519, "a.html.gz": 357, - "a.js": 3853, - "a.js.gz": 2045, + "a.js": 3864, + "a.js.gz": 2041, "a.wasm": 1288, "a.wasm.gz": 860, - "total": 5660, - "total_gz": 3262 + "total": 5671, + "total_gz": 3258 } diff --git a/test/code_size/test_minimal_runtime_code_size_audio_worklet.json b/test/code_size/test_minimal_runtime_code_size_audio_worklet.json index 914c498e84979..fc236e257f576 100644 --- a/test/code_size/test_minimal_runtime_code_size_audio_worklet.json +++ b/test/code_size/test_minimal_runtime_code_size_audio_worklet.json @@ -1,10 +1,10 @@ { "a.html": 519, "a.html.gz": 357, - "a.js": 3851, - "a.js.gz": 2048, + "a.js": 3875, + "a.js.gz": 2040, "a.wasm": 1288, "a.wasm.gz": 860, - "total": 5658, - "total_gz": 3265 + "total": 5682, + "total_gz": 3257 } diff --git a/test/test_browser.py b/test/test_browser.py index ef1d7ad8d54bb..bebfcdfd0df6a 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -5487,8 +5487,6 @@ def test_full_js_library_strict(self): 'es6': (['-sEXPORT_ES6'],), 'strict': (['-sSTRICT'],), }) - @no_wasm64('https://github.com/emscripten-core/emscripten/pull/23508') - @no_2gb('https://github.com/emscripten-core/emscripten/pull/23508') @requires_sound_hardware def test_audio_worklet(self, args): self.btest_exit('webaudio/audioworklet.c', cflags=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-DTEST_AND_EXIT'] + args) @@ -5511,8 +5509,6 @@ def test_audio_worklet_post_function(self, args): '': ([],), 'closure': (['--closure', '1', '-Oz'],), }) - @no_wasm64('https://github.com/emscripten-core/emscripten/pull/23508') - @no_2gb('https://github.com/emscripten-core/emscripten/pull/23508') @requires_sound_hardware def test_audio_worklet_modularize(self, args): self.btest_exit('webaudio/audioworklet.c', cflags=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-sMODULARIZE=1', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html'), '-DTEST_AND_EXIT'] + args) @@ -5524,8 +5520,6 @@ def test_audio_worklet_modularize(self, args): '': ([],), 'minimal_with_closure': (['-sMINIMAL_RUNTIME', '--closure=1', '-Oz'],), }) - @no_wasm64('https://github.com/emscripten-core/emscripten/pull/23508') - @no_2gb('https://github.com/emscripten-core/emscripten/pull/23508') @requires_sound_hardware def test_audio_worklet_params_mixing(self, args): os.mkdir('audio_files') @@ -5534,8 +5528,6 @@ def test_audio_worklet_params_mixing(self, args): self.btest_exit('webaudio/audioworklet_params_mixing.c', cflags=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-DTEST_AND_EXIT'] + args) # Tests AudioWorklet with emscripten_lock_busyspin_wait_acquire() and friends - @no_wasm64('https://github.com/emscripten-core/emscripten/pull/23508') - @no_2gb('https://github.com/emscripten-core/emscripten/pull/23508') @requires_sound_hardware @also_with_minimal_runtime def test_audio_worklet_emscripten_locks(self):