Skip to content

Commit 3aab394

Browse files
authored
Remove now unused Audio Worklet Module exports. (#25358)
Earlier refactor that avoided the separate .js file also made these redundant; `src/audio_worklet.js` no longer accesses anything via `Module`.
1 parent 9946451 commit 3aab394

File tree

3 files changed

+64
-86
lines changed

3 files changed

+64
-86
lines changed

src/postamble_minimal.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,6 @@ WebAssembly.instantiate(Module['wasm'], imports).then(/** @suppress {missingProp
241241
assignWasmExports(wasmExports);
242242
#endif
243243

244-
#if AUDIO_WORKLET
245-
// If we are in the audio worklet environment, we can only access the Module object
246-
// and not the global scope of the main JS script. Therefore we need to export
247-
// all symbols that the audio worklet scope needs onto the Module object.
248-
#if ASSERTIONS
249-
// In ASSERTIONS-enabled builds, the needed symbols have gotten read-only getters
250-
// saved to the Module. Remove the getters so we can manually export them here.
251-
delete Module['stackSave'];
252-
delete Module['stackAlloc'];
253-
delete Module['stackRestore'];
254-
delete Module['wasmTable'];
255-
#endif
256-
Module['stackSave'] = stackSave;
257-
Module['stackAlloc'] = stackAlloc;
258-
Module['stackRestore'] = stackRestore;
259-
Module['wasmTable'] = wasmTable;
260-
#endif
261-
262244
#if !IMPORTED_MEMORY
263245
updateMemoryViews();
264246
#endif
Lines changed: 60 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var m = globalThis.Module || "undefined" != typeof Module ? Module : {}, n = "em-ww" == globalThis.name, q = !!globalThis.AudioWorkletGlobalScope, t, z, J, K, H, D, v, X, F, C, B, Y, A, Z;
1+
var m = globalThis.Module || "undefined" != typeof Module ? Module : {}, q = "em-ww" == globalThis.name, r = !!globalThis.AudioWorkletGlobalScope, t, z, J, K, H, E, v, X, F, D, C, Y, A, Z;
22

3-
q && (n = !0);
3+
r && (q = !0);
44

55
function u(a) {
66
t = a;
@@ -12,12 +12,12 @@ function u(a) {
1212
a.G = a.M = 0;
1313
}
1414

15-
n && !q && (onmessage = a => {
15+
q && !r && (onmessage = a => {
1616
onmessage = null;
1717
u(a.data);
1818
});
1919

20-
if (q) {
20+
if (r) {
2121
function a(c) {
2222
class e extends AudioWorkletProcessor {
2323
constructor(d) {
@@ -31,41 +31,41 @@ if (q) {
3131
this.K();
3232
}
3333
K() {
34-
for (var d = B(), f = C(this.B.length * this.s) >> 2, g = this.B.length - 1; 0 <= g; g--) this.B[g] = D.subarray(f, f += this.u);
34+
for (var d = C(), f = D(this.B.length * this.s) >> 2, g = this.B.length - 1; 0 <= g; g--) this.B[g] = E.subarray(f, f += this.u);
3535
F(d);
3636
}
3737
static get parameterDescriptors() {
3838
return c;
3939
}
4040
process(d, f, g) {
41-
var p = d.length, x = f.length, k, r, h = 12 * (p + x), l = 0;
41+
var n = d.length, x = f.length, k, p, h = 12 * (n + x), l = 0;
4242
for (k of d) l += k.length;
4343
l *= this.s;
4444
var G = 0;
4545
for (k of f) G += k.length;
4646
l += G * this.s;
4747
var O = 0;
4848
for (k in g) ++O, h += 8, l += g[k].byteLength;
49-
var V = B(), E = h + l + 15 & -16;
50-
h = C(E);
51-
l = h + (E - l);
52-
E = h;
49+
var V = C(), B = h + l + 15 & -16;
50+
h = D(B);
51+
l = h + (B - l);
52+
B = h;
5353
for (k of d) {
5454
H[h >> 2] = k.length;
5555
H[h + 4 >> 2] = this.u;
5656
H[h + 8 >> 2] = l;
5757
h += 12;
58-
for (r of k) D.set(r, l >> 2), l += this.s;
58+
for (p of k) E.set(p, l >> 2), l += this.s;
5959
}
6060
d = h;
61-
for (k = 0; r = g[k++]; ) H[h >> 2] = r.length, H[h + 4 >> 2] = l, h += 8, D.set(r, l >> 2),
62-
l += 4 * r.length;
61+
for (k = 0; p = g[k++]; ) H[h >> 2] = p.length, H[h + 4 >> 2] = l, h += 8, E.set(p, l >> 2),
62+
l += 4 * p.length;
6363
g = h;
6464
for (k of f) H[h >> 2] = k.length, H[h + 4 >> 2] = this.u, H[h + 8 >> 2] = l, h += 12,
6565
l += this.s * k.length;
66-
if (p = this.v(p, E, x, g, O, d, this.A)) for (k of f) for (r of k) r.set(this.B[--G]);
66+
if (n = this.v(n, B, x, g, O, d, this.A)) for (k of f) for (p of k) p.set(this.B[--G]);
6767
F(V);
68-
return !!p;
68+
return !!n;
6969
}
7070
}
7171
return e;
@@ -95,10 +95,10 @@ function w() {
9595
J = new Uint8Array(a);
9696
K = new Int32Array(a);
9797
H = new Uint32Array(a);
98-
D = new Float32Array(a);
98+
E = new Float32Array(a);
9999
}
100100

101-
n || (v = m.mem || new WebAssembly.Memory({
101+
q || (v = m.mem || new WebAssembly.Memory({
102102
initial: 256,
103103
maximum: 256,
104104
shared: !0
@@ -110,12 +110,12 @@ var L = [], M = a => {
110110
b && A.get(b)(...a.x);
111111
}, N = a => {
112112
L.push(a);
113-
}, P = a => F(a), Q = () => B(), S = (a, b, c, e) => {
114-
b = R[b];
115-
R[a].connect(b.destination || b, c, e);
116-
}, R = {}, T = 0, U = "undefined" != typeof TextDecoder ? new TextDecoder : void 0, W = (a = 0) => {
113+
}, Q = (a, b, c, e) => {
114+
b = P[b];
115+
P[a].connect(b.destination || b, c, e);
116+
}, P = {}, R = 0, S = "undefined" != typeof TextDecoder ? new TextDecoder : void 0, T = (a = 0) => {
117117
for (var b = J, c = a, e = c + void 0; b[c] && !(c >= e); ) ++c;
118-
if (16 < c - a && b.buffer && U) return U.decode(b.slice(a, c));
118+
if (16 < c - a && b.buffer && S) return S.decode(b.slice(a, c));
119119
for (e = ""; a < c; ) {
120120
var d = b[a++];
121121
if (d & 128) {
@@ -128,26 +128,26 @@ var L = [], M = a => {
128128
} else e += String.fromCharCode(d);
129129
}
130130
return e;
131-
}, aa = a => {
131+
}, U = a => {
132132
var b = window.AudioContext || window.webkitAudioContext;
133133
if (a) {
134134
var c = H[a >> 2];
135135
a = {
136-
latencyHint: (c ? W(c) : "") || void 0,
136+
latencyHint: (c ? T(c) : "") || void 0,
137137
sampleRate: H[a + 4 >> 2] || void 0
138138
};
139139
} else a = void 0;
140-
if (c = b) b = new b(a), R[++T] = b, c = T;
140+
if (c = b) b = new b(a), P[++R] = b, c = R;
141141
return c;
142-
}, ba = (a, b, c, e, d) => {
142+
}, W = (a, b, c, e, d) => {
143143
var f = c ? K[c + 4 >> 2] : 0;
144144
if (c) {
145145
var g = K[c >> 2];
146146
c = H[c + 8 >> 2];
147-
var p = f;
147+
var n = f;
148148
if (c) {
149149
c >>= 2;
150-
for (var x = []; p--; ) x.push(H[c++]);
150+
for (var x = []; n--; ) x.push(H[c++]);
151151
c = x;
152152
} else c = void 0;
153153
e = {
@@ -161,69 +161,69 @@ var L = [], M = a => {
161161
}
162162
};
163163
} else e = void 0;
164-
a = new AudioWorkletNode(R[a], b ? W(b) : "", e);
165-
R[++T] = a;
166-
return T;
167-
}, ca = (a, b, c, e) => {
168-
var d = [], f = (f = H[b >> 2]) ? W(f) : "", g = K[b + 4 >> 2];
164+
a = new AudioWorkletNode(P[a], b ? T(b) : "", e);
165+
P[++R] = a;
166+
return R;
167+
}, aa = (a, b, c, e) => {
168+
var d = [], f = (f = H[b >> 2]) ? T(f) : "", g = K[b + 4 >> 2];
169169
b = H[b + 8 >> 2];
170-
for (var p = 0; g--; ) d.push({
171-
name: p++,
172-
defaultValue: D[b >> 2],
173-
minValue: D[b + 4 >> 2],
174-
maxValue: D[b + 8 >> 2],
170+
for (var n = 0; g--; ) d.push({
171+
name: n++,
172+
defaultValue: E[b >> 2],
173+
minValue: E[b + 4 >> 2],
174+
maxValue: E[b + 8 >> 2],
175175
automationRate: (K[b + 12 >> 2] ? "k" : "a") + "-rate"
176176
}), b += 16;
177-
R[a].audioWorklet.D.port.postMessage({
177+
P[a].audioWorklet.D.port.postMessage({
178178
_wpn: f,
179179
H: d,
180180
I: a,
181181
v: c,
182182
A: e
183183
});
184-
}, da = () => !1, ea = 1, fa = a => {
184+
}, ba = () => !1, ca = 1, da = a => {
185185
a = a.data;
186186
var b = a._wsc;
187187
b && A.get(b)(...a.C);
188-
}, ha = a => C(a), ia = (a, b, c, e, d) => {
189-
var f = R[a], g = f.audioWorklet, p = () => {
188+
}, ea = (a, b, c, e, d) => {
189+
var f = P[a], g = f.audioWorklet, n = () => {
190190
A.get(e)(a, 0, d);
191191
};
192-
if (!g) return p();
192+
if (!g) return n();
193193
g.addModule(m.js).then((() => {
194194
g.D = new AudioWorkletNode(f, "em-bootstrap", {
195195
processorOptions: {
196-
N: ea++,
196+
N: ca++,
197197
G: m.wasm,
198198
L: v,
199199
J: b,
200200
F: c
201201
}
202202
});
203-
g.D.port.onmessage = fa;
203+
g.D.port.onmessage = da;
204204
A.get(e)(a, 1, d);
205-
})).catch(p);
205+
})).catch(n);
206206
};
207207

208-
function ja(a) {
208+
function fa(a) {
209209
let b = document.createElement("button");
210210
b.innerHTML = "Toggle playback";
211211
document.body.appendChild(b);
212-
a = R[a];
212+
a = P[a];
213213
b.onclick = () => {
214214
"running" != a.state ? a.resume() : a.suspend();
215215
};
216216
}
217217

218218
function y() {
219219
Z = {
220-
f: ja,
221-
g: S,
222-
d: aa,
223-
h: ba,
224-
e: ca,
225-
b: da,
226-
c: ia,
220+
f: fa,
221+
g: Q,
222+
d: U,
223+
h: W,
224+
e: aa,
225+
b: ba,
226+
c: ea,
227227
a: v
228228
};
229229
z = WebAssembly.instantiate(m.wasm, {
@@ -232,17 +232,13 @@ function y() {
232232
a = (a.instance || a).exports;
233233
X = a.j;
234234
F = a.l;
235-
C = a.m;
236-
B = a.n;
235+
D = a.m;
236+
C = a.n;
237237
Y = a.o;
238238
A = a.k;
239-
m.stackSave = Q;
240-
m.stackAlloc = ha;
241-
m.stackRestore = P;
242-
m.wasmTable = A;
243-
n ? (Y(t.J, t.F), q || (removeEventListener("message", N), L = L.forEach(M), addEventListener("message", M))) : a.i();
244-
n || X();
239+
q ? (Y(t.J, t.F), r || (removeEventListener("message", N), L = L.forEach(M), addEventListener("message", M))) : a.i();
240+
q || X();
245241
}));
246242
}
247243

248-
n || y();
244+
q || y();
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 519,
33
"a.html.gz": 357,
4-
"a.js": 4024,
5-
"a.js.gz": 2127,
4+
"a.js": 3928,
5+
"a.js.gz": 2074,
66
"a.wasm": 1308,
77
"a.wasm.gz": 876,
8-
"total": 5851,
9-
"total_gz": 3360
8+
"total": 5755,
9+
"total_gz": 3307
1010
}

0 commit comments

Comments
 (0)