Skip to content

Commit 4a91be3

Browse files
authored
Remove use of the nascent EMSCRIPTEN_AUDIO_WORKLET_NODE_T everywhere (#26867)
Remove use of the nascent EMSCRIPTEN_AUDIO_WORKLET_NODE_T everywhere, and replace its uses with the EMSCRIPTEN_WEBAUDIO_T handle type instead. No need to have separate typedefs for Web Audio handles, that would be overkill at this point. Addresses #23153.
1 parent bfe3a91 commit 4a91be3

11 files changed

Lines changed: 22 additions & 15 deletions

site/source/docs/api_reference/wasm_audio_worklets.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ which resumes the audio context when the user clicks on the DOM Canvas element t
133133
};
134134
135135
// Create node
136-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T wasmAudioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext,
137-
"noise-generator", &options, &GenerateNoise, 0);
136+
EMSCRIPTEN_WEBAUDIO_T wasmAudioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext,
137+
"noise-generator", &options, &GenerateNoise, 0);
138138
139139
// Connect it to audio context destination
140140
emscripten_audio_node_connect(wasmAudioWorklet, audioContext, 0, 0);

system/include/emscripten/webaudio.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@
1717
extern "C" {
1818
#endif
1919

20+
// A handle type that represents a JavaScript side object related to WebAudio.
21+
// Used to denote the AudioContext and Audio Nodes, especially the Audio Worklet
22+
// Node.
2023
typedef int EMSCRIPTEN_WEBAUDIO_T;
2124

25+
// An outdated node type that represented an AudioWorklet node.
26+
// If you are using this type in your application, replace it with
27+
// EMSCRIPTEN_WEBAUDIO_T handle type instead.
28+
typedef int EMSCRIPTEN_AUDIO_WORKLET_NODE_T __attribute__((deprecated("use EMSCRIPTEN_WEBAUDIO_T instead")));
29+
2230
// Default render size of 128 frames
2331
#define AUDIO_CONTEXT_RENDER_SIZE_DEFAULT 0
2432
// Let the hardware determine the best render size
@@ -108,8 +116,6 @@ int emscripten_audio_context_quantum_size(EMSCRIPTEN_WEBAUDIO_T audioContext);
108116
// Returns the sampling rate of the given Audio Context, e.g. 48000 or 44100 or similar.
109117
int emscripten_audio_context_sample_rate(EMSCRIPTEN_WEBAUDIO_T audioContext);
110118

111-
typedef int EMSCRIPTEN_AUDIO_WORKLET_NODE_T;
112-
113119
typedef struct AudioSampleFrame
114120
{
115121
// Number of audio channels to process (multiplied by samplesPerChannel gives the elements in data)
@@ -162,7 +168,8 @@ typedef struct EmscriptenAudioWorkletNodeCreateOptions
162168

163169
// Instantiates the given AudioWorkletProcessor as an AudioWorkletNode, which continuously calls the specified processCallback() function on the browser's audio thread to perform audio processing.
164170
// userData4: A custom userdata pointer to pass to the callback function. This value will be passed on to the call to the given EmscriptenWorkletNodeProcessCallback callback function.
165-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T emscripten_create_wasm_audio_worklet_node(EMSCRIPTEN_WEBAUDIO_T audioContext, const char *name, const EmscriptenAudioWorkletNodeCreateOptions *options, EmscriptenWorkletNodeProcessCallback processCallback, void *userData4);
171+
// Returns a handle to the created audio worklet node object.
172+
EMSCRIPTEN_WEBAUDIO_T emscripten_create_wasm_audio_worklet_node(EMSCRIPTEN_WEBAUDIO_T audioContext, const char *name, const EmscriptenAudioWorkletNodeCreateOptions *options, EmscriptenWorkletNodeProcessCallback processCallback, void *userData4);
166173

167174
// Connects a node's output to a target, e.g., connect the worklet node to the context.
168175
// For outputIndex and inputIndex, see the AudioNode.connect() documentation (setting 0 as the default values)

test/webaudio/audio_worklet_tone_generator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool succe
8282
};
8383

8484
// Instantiate the noise-generator Audio Worklet Processor.
85-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T wasmAudioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext, "tone-generator", &options, &ProcessAudio, 0);
85+
EMSCRIPTEN_WEBAUDIO_T wasmAudioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext, "tone-generator", &options, &ProcessAudio, 0);
8686

8787
// Connect the audio worklet node to the graph.
8888
emscripten_audio_node_connect(wasmAudioWorklet, audioContext, 0, 0);

test/webaudio/audioworklet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool succe
116116
};
117117

118118
// Instantiate the noise-generator Audio Worklet Processor.
119-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T wasmAudioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext, "noise-generator", &options, &ProcessAudio, 0);
119+
EMSCRIPTEN_WEBAUDIO_T wasmAudioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext, "noise-generator", &options, &ProcessAudio, 0);
120120
// Connect the audio worklet node to the graph.
121121
emscripten_audio_node_connect(wasmAudioWorklet, audioContext, 0, 0);
122122

test/webaudio/audioworklet_2x_in_hard_pan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
5858
.numberOfOutputs = 1,
5959
.outputChannelCounts = outputChannelCounts
6060
};
61-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
61+
EMSCRIPTEN_WEBAUDIO_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
6262
emscripten_audio_node_connect(worklet, context, 0, 0);
6363

6464
// Create the two mono source nodes and connect them to the two inputs

test/webaudio/audioworklet_2x_in_out_stereo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
5757
.numberOfOutputs = 2,
5858
.outputChannelCounts = outputChannelCounts
5959
};
60-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
60+
EMSCRIPTEN_WEBAUDIO_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
6161
// Both outputs connected to the context
6262
emscripten_audio_node_connect(worklet, context, 0, 0);
6363
emscripten_audio_node_connect(worklet, context, 1, 0);

test/webaudio/audioworklet_emscripten_locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T ctx, bool success, void* data) {
190190
.numberOfOutputs = 1,
191191
.outputChannelCounts = outputChannelCounts
192192
};
193-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T worklet = emscripten_create_wasm_audio_worklet_node(ctx, "locks-test", &opts, &process, data);
193+
EMSCRIPTEN_WEBAUDIO_T worklet = emscripten_create_wasm_audio_worklet_node(ctx, "locks-test", &opts, &process, data);
194194
emscripten_audio_node_connect(worklet, ctx, 0, 0);
195195
}
196196

test/webaudio/audioworklet_in_out_mono.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
6565
.numberOfOutputs = 1,
6666
.outputChannelCounts = outputChannelCounts
6767
};
68-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
68+
EMSCRIPTEN_WEBAUDIO_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
6969
emscripten_audio_node_connect(worklet, context, 0, 0);
7070

7171
// Create the two mono source nodes and connect them to the two inputs

test/webaudio/audioworklet_in_out_stereo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
6565
.numberOfOutputs = 1,
6666
.outputChannelCounts = outputChannelCounts
6767
};
68-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
68+
EMSCRIPTEN_WEBAUDIO_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
6969
emscripten_audio_node_connect(worklet, context, 0, 0);
7070

7171
// Create the two stereo source nodes and connect them to the two inputs

test/webaudio/audioworklet_memory_growth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
9595
.numberOfOutputs = 1,
9696
.outputChannelCounts = outputChannelCounts
9797
};
98-
EMSCRIPTEN_AUDIO_WORKLET_NODE_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
98+
EMSCRIPTEN_WEBAUDIO_T worklet = emscripten_create_wasm_audio_worklet_node(context, "mixer", &opts, &process, NULL);
9999
emscripten_audio_node_connect(worklet, context, 0, 0);
100100

101101
// Create the two stereo source nodes and connect them to the two inputs

0 commit comments

Comments
 (0)