Skip to content

Commit 97840e6

Browse files
authored
Fix internal naming in libwebaudio.js. NFC (#25901)
Only classes and constructor functions should start with an uppercase letter in our JS style.
1 parent 05db1ba commit 97840e6

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/lib/libwebaudio.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
#endif
1010

1111
var LibraryWebAudio = {
12-
$EmAudio: {},
13-
$EmAudioCounter: 0,
12+
$emAudio: {},
13+
$emAudioCounter: 0,
1414

1515
// Call this function from JavaScript to register a Wasm-side handle to an AudioContext that
1616
// you have already created manually without calling emscripten_create_audio_context().
1717
// Note: To let that AudioContext be garbage collected later, call the function
1818
// emscriptenDestroyAudioContext() to unbind it from Wasm.
19-
$emscriptenRegisterAudioObject__deps: ['$EmAudio', '$EmAudioCounter'],
19+
$emscriptenRegisterAudioObject__deps: ['$emAudio', '$emAudioCounter'],
2020
$emscriptenRegisterAudioObject: (object) => {
2121
#if ASSERTIONS
2222
assert(object, 'Called emscriptenRegisterAudioObject() with a null object handle!');
2323
#endif
24-
EmAudio[++EmAudioCounter] = object;
24+
emAudio[++emAudioCounter] = object;
2525
#if WEBAUDIO_DEBUG
26-
dbg(`Registered new WebAudio object ${object} with ID ${EmAudioCounter}`);
26+
dbg(`Registered new WebAudio object ${object} with ID ${emAudioCounter}`);
2727
#endif
28-
return EmAudioCounter;
28+
return emAudioCounter;
2929
},
3030

3131
#if ASSERTIONS || WEBAUDIO_DEBUG
@@ -35,7 +35,7 @@ var LibraryWebAudio = {
3535
dbg(`called ${methodName}() with ID ${handle}`);
3636
#endif
3737
#if ASSERTIONS
38-
var obj = EmAudio[handle];
38+
var obj = emAudio[handle];
3939
assert(obj, `Called ${methodName}() on a nonexisting handle ${handle}`);
4040
return obj;
4141
#endif
@@ -73,11 +73,11 @@ var LibraryWebAudio = {
7373

7474
// Call this function from JavaScript to get the Web Audio object corresponding to the given
7575
// Wasm handle ID.
76-
$emscriptenGetAudioObject: (objectHandle) => EmAudio[objectHandle],
76+
$emscriptenGetAudioObject: (objectHandle) => emAudio[objectHandle],
7777

7878
// Performs the work of getting the AudioContext's render quantum size.
7979
$emscriptenGetContextQuantumSize: (contextHandle) => {
80-
return EmAudio[contextHandle]['renderQuantumSize'] || 128;
80+
return emAudio[contextHandle]['renderQuantumSize'] || 128;
8181
},
8282

8383
// emscripten_create_audio_context() does not itself use the
@@ -122,36 +122,36 @@ var LibraryWebAudio = {
122122
emscripten_resume_audio_context_async: (contextHandle, callback, userData) => {
123123
function cb(state) {
124124
#if WEBAUDIO_DEBUG
125-
console.log(`emscripten_resume_audio_context_async() callback: New audio state="${EmAudio[contextHandle].state}", ID=${state}`);
125+
console.log(`emscripten_resume_audio_context_async() callback: New audio state="${emAudio[contextHandle].state}", ID=${state}`);
126126
#endif
127127
{{{ makeDynCall('viip', 'callback') }}}(contextHandle, state, userData);
128128
}
129129
#if WEBAUDIO_DEBUG
130130
dbg('emscripten_resume_audio_context_async() resuming...');
131131
#endif
132-
EmAudio[contextHandle].resume().then(() => { cb(1/*running*/) }).catch(() => { cb(0/*suspended*/) });
132+
emAudio[contextHandle].resume().then(() => { cb(1/*running*/) }).catch(() => { cb(0/*suspended*/) });
133133
},
134134

135135
emscripten_resume_audio_context_sync: (contextHandle) => {
136136
#if ASSERTIONS || WEBAUDIO_DEBUG
137137
emAudioExpectContext(contextHandle, 'emscripten_resume_audio_context_sync');
138138
#endif
139-
EmAudio[contextHandle].resume();
139+
emAudio[contextHandle].resume();
140140
},
141141

142142
emscripten_audio_context_state: (contextHandle) => {
143143
#if ASSERTIONS || WEBAUDIO_DEBUG
144144
emAudioExpectContext(contextHandle, 'emscripten_audio_context_state');
145145
#endif
146-
return ['suspended', 'running', 'closed', 'interrupted'].indexOf(EmAudio[contextHandle].state);
146+
return ['suspended', 'running', 'closed', 'interrupted'].indexOf(emAudio[contextHandle].state);
147147
},
148148

149149
emscripten_destroy_audio_context: (contextHandle) => {
150150
#if ASSERTIONS || WEBAUDIO_DEBUG
151151
emAudioExpectContext(contextHandle, 'emscripten_destroy_audio_context');
152152
#endif
153-
EmAudio[contextHandle].suspend();
154-
delete EmAudio[contextHandle];
153+
emAudio[contextHandle].suspend();
154+
delete emAudio[contextHandle];
155155
},
156156

157157
emscripten_destroy_web_audio_node: (objectHandle) => {
@@ -160,24 +160,24 @@ var LibraryWebAudio = {
160160
#endif
161161
// Explicitly disconnect the node from Web Audio graph before letting it GC,
162162
// to work around browser bugs such as https://webkit.org/b/222098#c23
163-
EmAudio[objectHandle].disconnect();
164-
delete EmAudio[objectHandle];
163+
emAudio[objectHandle].disconnect();
164+
delete emAudio[objectHandle];
165165
},
166166

167167
#if AUDIO_WORKLET
168168
// emscripten_start_wasm_audio_worklet_thread_async() doesn't use stackAlloc,
169169
// etc., but the created worklet does.
170170
emscripten_start_wasm_audio_worklet_thread_async__deps: [
171171
'$_wasmWorkersID',
172-
'$_EmAudioDispatchProcessorCallback',
172+
'$_emAudioDispatchProcessorCallback',
173173
'$stackAlloc', '$stackRestore', '$stackSave'],
174174
emscripten_start_wasm_audio_worklet_thread_async: (contextHandle, stackLowestAddress, stackSize, callback, userData) => {
175175

176176
#if ASSERTIONS || WEBAUDIO_DEBUG
177177
emAudioExpectContext(contextHandle, 'emscripten_start_wasm_audio_worklet_thread_async');
178178
#endif
179179

180-
var audioContext = EmAudio[contextHandle];
180+
var audioContext = emAudio[contextHandle];
181181
var audioWorklet = audioContext.audioWorklet;
182182

183183
#if ASSERTIONS
@@ -258,13 +258,13 @@ var LibraryWebAudio = {
258258
stackLowestAddress, // sb = stack base
259259
stackSize, // sz = stack size
260260
});
261-
audioWorklet['port'].onmessage = _EmAudioDispatchProcessorCallback;
261+
audioWorklet['port'].onmessage = _emAudioDispatchProcessorCallback;
262262
{{{ makeDynCall('viip', 'callback') }}}(contextHandle, 1/*EM_TRUE*/, userData);
263263
}).catch(audioWorkletCreationFailed);
264264
},
265265

266-
$_EmAudioDispatchProcessorCallback__deps: ['$getWasmTableEntry'],
267-
$_EmAudioDispatchProcessorCallback: (e) => {
266+
$_emAudioDispatchProcessorCallback__deps: ['$getWasmTableEntry'],
267+
$_emAudioDispatchProcessorCallback: (e) => {
268268
var data = e.data;
269269
// '_wsc' is short for 'wasm call', trying to use an identifier name that
270270
// will never conflict with user code. This is used to call both the 3-param
@@ -304,7 +304,7 @@ var LibraryWebAudio = {
304304
console.log(`emscripten_create_wasm_audio_worklet_processor_async() creating a new AudioWorklet processor with name ${processorName}`);
305305
#endif
306306

307-
EmAudio[contextHandle].audioWorklet['port'].postMessage({
307+
emAudio[contextHandle].audioWorklet['port'].postMessage({
308308
// Deliberately mangled and short names used here ('_wpn', the 'Worklet
309309
// Processor Name' used as a 'key' to verify the message type so as to
310310
// not get accidentally mixed with user submitted messages, the remainder
@@ -352,7 +352,7 @@ var LibraryWebAudio = {
352352
dbg(`Creating AudioWorkletNode "${UTF8ToString(name)}" on context=${contextHandle} with options:`);
353353
console.dir(opts);
354354
#endif
355-
return emscriptenRegisterAudioObject(new AudioWorkletNode(EmAudio[contextHandle], UTF8ToString(name), opts));
355+
return emscriptenRegisterAudioObject(new AudioWorkletNode(emAudio[contextHandle], UTF8ToString(name), opts));
356356
},
357357
#endif // ~AUDIO_WORKLET
358358

@@ -368,16 +368,16 @@ var LibraryWebAudio = {
368368
#if ASSERTIONS || WEBAUDIO_DEBUG
369369
emAudioExpectContext(contextHandle, 'emscripten_audio_context_sample_rate');
370370
#endif
371-
return EmAudio[contextHandle]['sampleRate'];
371+
return emAudio[contextHandle]['sampleRate'];
372372
},
373373

374374
emscripten_audio_node_connect: (source, destination, outputIndex, inputIndex) => {
375375
#if ASSERTIONS || WEBAUDIO_DEBUG
376376
emAudioExpectNode(source, 'emscripten_audio_node_connect');
377377
emAudioExpectNodeOrContext(destination, 'emscripten_audio_node_connect');
378378
#endif
379-
var srcNode = EmAudio[source];
380-
var dstNode = EmAudio[destination];
379+
var srcNode = emAudio[source];
380+
var dstNode = emAudio[destination];
381381
#if WEBAUDIO_DEBUG
382382
dbg(`Connecting audio node ID ${source} to audio node ID ${destination} (${srcNode} to ${dstNode})`);
383383
#endif
@@ -393,7 +393,7 @@ var LibraryWebAudio = {
393393
if (audioContext) emAudioExpectContext(audioContext, 'emAudioWorkletPostFunction');
394394
#endif
395395
// _wsc = "WaSm Call"
396-
(audioContext ? EmAudio[audioContext].audioWorklet['port'] : port).postMessage({'_wsc': funcPtr, args});
396+
(audioContext ? emAudio[audioContext].audioWorklet['port'] : port).postMessage({'_wsc': funcPtr, args});
397397
},
398398

399399
emscripten_current_thread_is_audio_worklet: () => ENVIRONMENT_IS_AUDIO_WORKLET,

0 commit comments

Comments
 (0)