You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib/libwebaudio.js
+72-53Lines changed: 72 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -23,11 +23,49 @@ var LibraryWebAudio = {
23
23
#endif
24
24
EmAudio[++EmAudioCounter]=object;
25
25
#if WEBAUDIO_DEBUG
26
-
console.log(`Registered new WebAudio object ${object} with ID ${EmAudioCounter}`);
26
+
dbg(`Registered new WebAudio object ${object} with ID ${EmAudioCounter}`);
27
27
#endif
28
28
returnEmAudioCounter;
29
29
},
30
30
31
+
#if ASSERTIONS||WEBAUDIO_DEBUG
32
+
$_emAudioCheckHandle__internal: true,
33
+
$_emAudioCheckHandle: (handle,methodName)=>{
34
+
#if WEBAUDIO_DEBUG
35
+
dbg(`called ${methodName}() with ID ${handle}`);
36
+
#endif
37
+
#if ASSERTIONS
38
+
varobj=EmAudio[handle];
39
+
assert(obj,`Called ${methodName}() on a nonexisting handle ${handle}`);
40
+
returnobj;
41
+
#endif
42
+
},
43
+
44
+
$emAudioCheckContext__internal: true,
45
+
$emAudioCheckContext: (handle,methodName)=>{
46
+
varobj=_emAudioCheckHandle(handle,methodName);
47
+
#if ASSERTIONS
48
+
assert(objinstanceof(window.AudioContext||window.webkitAudioContext),`${methodName}() called with ${handle} that is not an AudioContext, but of type ${typeofobj}`);
49
+
#endif
50
+
},
51
+
52
+
$emAudioCheckNode__internal: true,
53
+
$emAudioCheckNode: (handle,methodName)=>{
54
+
varobj=_emAudioCheckHandle(handle,methodName);
55
+
#if ASSERTIONS
56
+
assert(objinstanceofwindow.AudioNode,`${methodName}() called with a handle ${handle} that is not an AudioNode, but of type ${typeofobj}`);
assert(objinstanceofwindow.AudioNode||objinstanceof(window.AudioContext||window.webkitAudioContext),`${methodName}() called with a handle ${handle} that is not an AudioContext or AudioNode, but of type ${typeofobj}`);
65
+
#endif
66
+
},
67
+
#endif
68
+
31
69
// Call this function from JavaScript to destroy a Wasm-side handle to an AudioContext.
32
70
// After calling this function, it is no longer possible to reference this AudioContext
33
71
// from Wasm code - and the GC can reclaim it after all references to it are cleared.
@@ -68,7 +106,7 @@ var LibraryWebAudio = {
68
106
} : undefined;
69
107
70
108
#if WEBAUDIO_DEBUG
71
-
console.log(`Creating new WebAudio context with parameters:`);
109
+
dbg(`Creating new WebAudio context with parameters:`);
assert(EmAudio[contextHandle],`Called emscripten_resume_audio_context_sync() on a nonexisting context handle ${contextHandle}`);
99
-
assert(EmAudio[contextHandle]instanceof(window.AudioContext||window.webkitAudioContext),`Called emscripten_resume_audio_context_sync() on a context handle ${contextHandle} that is not an AudioContext, but of type ${typeofEmAudio[contextHandle]}`);
100
-
#endif
101
-
#if WEBAUDIO_DEBUG
102
-
console.log(`AudioContext.resume() on WebAudio context with ID ${contextHandle}`);
assert(EmAudio[contextHandle],`Called emscripten_audio_context_state() on a nonexisting context handle ${contextHandle}`);
110
-
assert(EmAudio[contextHandle]instanceof(window.AudioContext||window.webkitAudioContext),`Called emscripten_audio_context_state() on a context handle ${contextHandle} that is not an AudioContext, but of type ${typeofEmAudio[contextHandle]}`);
assert(EmAudio[contextHandle],`Called emscripten_destroy_audio_context() on an already freed context handle ${contextHandle}`);
118
-
assert(EmAudio[contextHandle]instanceof(window.AudioContext||window.webkitAudioContext),`Called emscripten_destroy_audio_context() on a context handle ${contextHandle} that is not an AudioContext, but of type ${typeofEmAudio[contextHandle]}`);
119
-
#endif
120
-
#if WEBAUDIO_DEBUG
121
-
console.log(`Destroyed WebAudio context with ID ${contextHandle}`);
assert(EmAudio[objectHandle],`Called emscripten_destroy_web_audio_node() on a nonexisting/already freed object handle ${objectHandle}`);
130
-
assert(EmAudio[objectHandle].disconnect,`Called emscripten_destroy_web_audio_node() on a handle ${objectHandle} that is not an Web Audio Node, but of type ${typeofEmAudio[objectHandle]}`);
131
-
#endif
132
-
#if WEBAUDIO_DEBUG
133
-
console.log(`Destroyed Web Audio Node with ID ${objectHandle}`);
assert(contextHandle,`Called emscripten_start_wasm_audio_worklet_thread_async() with a null Web Audio Context handle!`);
152
-
assert(EmAudio[contextHandle],`Called emscripten_start_wasm_audio_worklet_thread_async() with a nonexisting/already freed Web Audio Context handle ${contextHandle}!`);
153
-
assert(EmAudio[contextHandle]instanceof(window.AudioContext||window.webkitAudioContext),`Called emscripten_start_wasm_audio_worklet_thread_async() on a context handle ${contextHandle} that is not an AudioContext, but of type ${typeofEmAudio[contextHandle]}`);
assert(contextHandle,`Called emscripten_create_wasm_audio_worklet_processor_async() with a null Web Audio Context handle!`);
255
-
assert(EmAudio[contextHandle],`Called emscripten_create_wasm_audio_worklet_processor_async() with a nonexisting/already freed Web Audio Context handle ${contextHandle}!`);
256
-
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 ${typeofEmAudio[contextHandle]}`);
assert(contextHandle,`Called emscripten_create_wasm_audio_worklet_node() with a null Web Audio Context handle!`);
304
-
assert(EmAudio[contextHandle],`Called emscripten_create_wasm_audio_worklet_node() with a nonexisting/already freed Web Audio Context handle ${contextHandle}!`);
305
-
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 ${typeofEmAudio[contextHandle]}`);
assert(EmAudio[contextHandle],`Called emscripten_audio_context_quantum_size() with an invalid Web Audio Context handle ${contextHandle}`);
343
-
assert(EmAudio[contextHandle]instanceof(window.AudioContext||window.webkitAudioContext),`Called emscripten_audio_context_quantum_size() on handle ${contextHandle} that is not an AudioContext, but of type ${EmAudio[contextHandle]}`);
assert(EmAudio[contextHandle],`Called emscripten_audio_context_sample_rate() with an invalid Web Audio Context handle ${contextHandle}`);
351
-
assert(EmAudio[contextHandle]instanceof(window.AudioContext||window.webkitAudioContext),`Called emscripten_audio_context_sample_rate() on handle ${contextHandle} that is not an AudioContext, but of type ${EmAudio[contextHandle]}`);
assert(srcNode,`Called emscripten_audio_node_connect() with an invalid AudioNode handle ${source}`);
361
-
assert(srcNodeinstanceofwindow.AudioNode,`Called emscripten_audio_node_connect() on handle ${source} that is not an AudiotNode, but of type ${srcNode}`);
362
-
assert(dstNode,`Called emscripten_audio_node_connect() with an invalid AudioNode handle ${destination}!`);
363
-
assert(dstNodeinstanceof(window.AudioContext||window.webkitAudioContext)||dstNodeinstanceofwindow.AudioNode,`Called emscripten_audio_node_connect() on handle ${destination} that is not an AudioContext or AudioNode, but of type ${dstNode}`);
364
-
#endif
365
380
#if WEBAUDIO_DEBUG
366
-
console.log(`Connecting audio node ID ${source} to audio node ID ${destination} (${srcNode} to ${dstNode})`);
381
+
dbg(`Connecting audio node ID ${source} to audio node ID ${destination} (${srcNode} to ${dstNode})`);
0 commit comments