Skip to content

Commit b2c8826

Browse files
committed
Tests all moved to #23659, undoing all the changes here
1 parent 178b9c5 commit b2c8826

6 files changed

+38
-137
lines changed

test/test_interactive.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -334,32 +334,10 @@ def test_audio_worklet_2x_hard_pan_io(self):
334334
shutil.copy(test_file('webaudio/audio_files/emscripten-bass-mono.mp3'), 'audio_files/')
335335
self.btest_exit('webaudio/audioworklet_2x_in_hard_pan.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'])
336336

337-
# Tests an AudioWorklet with multiple stereo inputs mixing in the processor via a parameter to a single stereo output (6kB stack)
338-
def test_audio_worklet_params_mixing(self):
339-
os.mkdir('audio_files')
340-
shutil.copy(test_file('webaudio/audio_files/emscripten-beat.mp3'), 'audio_files/')
341-
shutil.copy(test_file('webaudio/audio_files/emscripten-bass.mp3'), 'audio_files/')
342-
self.btest_exit('webaudio/audioworklet_params_mixing.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'])
343-
344337

345338
class interactive64(interactive):
346339
def setUp(self):
347340
super().setUp()
348341
self.set_setting('MEMORY64')
342+
self.emcc_args.append('-Wno-experimental')
349343
self.require_wasm64()
350-
351-
352-
class interactive64_4gb(interactive):
353-
def setUp(self):
354-
super().setUp()
355-
self.set_setting('MEMORY64')
356-
self.set_setting('INITIAL_MEMORY', '4200mb')
357-
self.set_setting('GLOBAL_BASE', '4gb')
358-
self.require_wasm64()
359-
360-
361-
class interactive_2gb(interactive):
362-
def setUp(self):
363-
super().setUp()
364-
self.set_setting('INITIAL_MEMORY', '2200mb')
365-
self.set_setting('GLOBAL_BASE', '2gb')

test/webaudio/audioworklet_2x_in_hard_pan.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,25 @@
1515
#include "audioworklet_test_shared.inc"
1616

1717
// Callback to process and copy the audio tracks
18-
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int __unused numParams, const AudioParamFrame* __unused params, void* __unused data) {
18+
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int numParams, const AudioParamFrame* params, void* data) {
1919
audioProcessedCount++;
2020

21-
// Twin mono in (or disabled), single stereo out
21+
// Twin mono in, single stereo out
2222
assert(numInputs == 2 && numOutputs == 1);
23-
assert(inputs[0].numberOfChannels == 0 || inputs[0].numberOfChannels == 1);
24-
assert(inputs[1].numberOfChannels == 0 || inputs[1].numberOfChannels == 1);
23+
assert(inputs[0].numberOfChannels == 1 && inputs[1].numberOfChannels == 1);
2524
assert(outputs[0].numberOfChannels == 2);
2625
// All with the same number of samples
2726
assert(inputs[0].samplesPerChannel == inputs[1].samplesPerChannel);
2827
assert(inputs[0].samplesPerChannel == outputs[0].samplesPerChannel);
29-
// Now with all known quantities we can memcpy the L&R data (or zero it if the
30-
// channels are disabled)
31-
int bytesPerChannel = outputs[0].samplesPerChannel * sizeof(float);
32-
float* outputData = outputs[0].data;
33-
if (inputs[0].numberOfChannels > 0) {
34-
memcpy(outputData, inputs[0].data, bytesPerChannel);
35-
} else {
36-
memset(outputData, 0, bytesPerChannel);
37-
}
38-
outputData += outputs[0].samplesPerChannel;
39-
if (inputs[1].numberOfChannels > 0) {
40-
memcpy(outputData, inputs[1].data, bytesPerChannel);
41-
} else {
42-
memset(outputData, 0, bytesPerChannel);
43-
}
28+
// Now with all known quantities we can memcpy the data
29+
int samplesPerChannel = inputs[0].samplesPerChannel;
30+
memcpy(outputs[0].data, inputs[0].data, samplesPerChannel * sizeof(float));
31+
memcpy(outputs[0].data + samplesPerChannel, inputs[1].data, samplesPerChannel * sizeof(float));
4432
return true;
4533
}
4634

4735
// Audio processor created, now register the audio callback
48-
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unused data) {
36+
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
4937
if (!success) {
5038
printf("Audio worklet node creation failed\n");
5139
return;
@@ -80,8 +68,3 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unuse
8068
// Register the counter that exits the test after one second of mixing
8169
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);
8270
}
83-
84-
// This implementation has no custom start-up requirements
85-
EmscriptenStartWebAudioWorkletCallback getStartCallback(void) {
86-
return &initialised;
87-
}

test/webaudio/audioworklet_2x_in_out_stereo.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,26 @@
1414
#include "audioworklet_test_shared.inc"
1515

1616
// Callback to process and copy the audio tracks
17-
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int __unused numParams, const AudioParamFrame* __unused params, void* __unused data) {
17+
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int numParams, const AudioParamFrame* params, void* data) {
1818
audioProcessedCount++;
1919

2020
// Twin stereo in and out
2121
assert(numInputs == 2 && numOutputs == 2);
22-
assert(inputs[0].numberOfChannels == 0 || inputs[0].numberOfChannels == 2);
23-
assert(inputs[1].numberOfChannels == 0 || inputs[1].numberOfChannels == 2);
24-
assert(outputs[0].numberOfChannels == 2);
25-
assert(outputs[1].numberOfChannels == 2);
22+
assert(inputs[0].numberOfChannels == 2 && inputs[1].numberOfChannels == 2);
23+
assert(outputs[0].numberOfChannels == 2 && outputs[1].numberOfChannels == 2);
2624
// All with the same number of samples
2725
assert(inputs[0].samplesPerChannel == inputs[1].samplesPerChannel);
2826
assert(inputs[0].samplesPerChannel == outputs[0].samplesPerChannel);
2927
assert(outputs[0].samplesPerChannel == outputs[1].samplesPerChannel);
30-
// Now with all known quantities we can memcpy all the data (or zero it if the
31-
// channels are disabled)
32-
int totalBytes = outputs[0].samplesPerChannel * outputs[0].numberOfChannels * sizeof(float);
33-
if (inputs[0].numberOfChannels > 0) {
34-
memcpy(outputs[0].data, inputs[0].data, totalBytes);
35-
} else {
36-
memset(outputs[0].data, 0, totalBytes);
37-
}
38-
if (inputs[1].numberOfChannels > 0) {
39-
memcpy(outputs[1].data, inputs[1].data, totalBytes);
40-
} else {
41-
memset(outputs[1].data, 0, totalBytes);
42-
}
28+
// Now with all known quantities we can memcpy the data
29+
int totalSamples = outputs[0].samplesPerChannel * outputs[0].numberOfChannels;
30+
memcpy(outputs[0].data, inputs[0].data, totalSamples * sizeof(float));
31+
memcpy(outputs[1].data, inputs[1].data, totalSamples * sizeof(float));
4332
return true;
4433
}
4534

4635
// Audio processor created, now register the audio callback
47-
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unused data) {
36+
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
4837
if (!success) {
4938
printf("Audio worklet node creation failed\n");
5039
return;
@@ -81,8 +70,3 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unuse
8170
// Register the counter that exits the test after one second of mixing
8271
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);
8372
}
84-
85-
// This implementation has no custom start-up requirements
86-
EmscriptenStartWebAudioWorkletCallback getStartCallback(void) {
87-
return &initialised;
88-
}

test/webaudio/audioworklet_in_out_mono.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "audioworklet_test_shared.inc"
1616

1717
// Callback to process and mix the audio tracks
18-
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int __unused numParams, const AudioParamFrame* __unused params, void* __unused data) {
18+
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int numParams, const AudioParamFrame* params, void* data) {
1919
audioProcessedCount++;
2020

2121
// Single mono output
@@ -29,18 +29,11 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
2929
// We can now do a quick mix since we know the layouts
3030
if (numInputs > 0) {
3131
int totalSamples = outputs[0].samplesPerChannel * outputs[0].numberOfChannels;
32-
// Simple copy of the first input's audio data, checking that we have
33-
// channels (since a muted input has zero channels).
3432
float* outputData = outputs[0].data;
35-
if (inputs[0].numberOfChannels > 0) {
36-
memcpy(outputData, inputs[0].data, totalSamples * sizeof(float));
37-
} else {
38-
// And for muted we need to fill the buffer with zeroes otherwise it repeats the last frame
39-
memset(outputData, 0, totalSamples * sizeof(float));
40-
}
41-
// Now add another inputs
33+
memcpy(outputData, inputs[0].data, totalSamples * sizeof(float));
4234
for (int n = 1; n < numInputs; n++) {
43-
if (inputs[n].numberOfChannels > 0) {
35+
// It's possible to have an input with no channels
36+
if (inputs[n].numberOfChannels == 1) {
4437
float* inputData = inputs[n].data;
4538
for (int i = totalSamples - 1; i >= 0; i--) {
4639
outputData[i] += inputData[i];
@@ -52,7 +45,7 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
5245
}
5346

5447
// Audio processor created, now register the audio callback
55-
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unused data) {
48+
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
5649
if (!success) {
5750
printf("Audio worklet node creation failed\n");
5851
return;
@@ -87,9 +80,3 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unuse
8780
// Register the counter that exits the test after one second of mixing
8881
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);
8982
}
90-
91-
// This implementation has no custom start-up requirements
92-
EmscriptenStartWebAudioWorkletCallback getStartCallback(void) {
93-
return &initialised;
94-
}
95-

test/webaudio/audioworklet_in_out_stereo.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "audioworklet_test_shared.inc"
1616

1717
// Callback to process and mix the audio tracks
18-
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int __unused numParams, const AudioParamFrame* __unused params, void* __unused data) {
18+
bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, AudioSampleFrame* outputs, int numParams, const AudioParamFrame* params, void* data) {
1919
audioProcessedCount++;
2020

2121
// Single stereo output
@@ -29,18 +29,11 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
2929
// We can now do a quick mix since we know the layouts
3030
if (numInputs > 0) {
3131
int totalSamples = outputs[0].samplesPerChannel * outputs[0].numberOfChannels;
32-
// Simple copy of the first input's audio data, checking that we have
33-
// channels (since a muted input has zero channels).
3432
float* outputData = outputs[0].data;
35-
if (inputs[0].numberOfChannels > 0) {
36-
memcpy(outputData, inputs[0].data, totalSamples * sizeof(float));
37-
} else {
38-
// And for muted we need to fill the buffer with zeroes otherwise it repeats the last frame
39-
memset(outputData, 0, totalSamples * sizeof(float));
40-
}
41-
// Now add another inputs
33+
memcpy(outputData, inputs[0].data, totalSamples * sizeof(float));
4234
for (int n = 1; n < numInputs; n++) {
43-
if (inputs[n].numberOfChannels > 0) {
35+
// It's possible to have an input with no channels
36+
if (inputs[n].numberOfChannels == 2) {
4437
float* inputData = inputs[n].data;
4538
for (int i = totalSamples - 1; i >= 0; i--) {
4639
outputData[i] += inputData[i];
@@ -52,7 +45,7 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
5245
}
5346

5447
// Audio processor created, now register the audio callback
55-
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unused data) {
48+
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
5649
if (!success) {
5750
printf("Audio worklet node creation failed\n");
5851
return;
@@ -87,8 +80,3 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unuse
8780
// Register the counter that exits the test after one second of mixing
8881
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);
8982
}
90-
91-
// This implementation has no custom start-up requirements
92-
EmscriptenStartWebAudioWorkletCallback getStartCallback(void) {
93-
return &initialised;
94-
}

test/webaudio/audioworklet_test_shared.inc

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@
55
// Helper for MEMORY64 to cast a void* to an audio context or type
66
#define VOIDP_2_WA(ptr) ((EMSCRIPTEN_WEBAUDIO_T) (intptr_t) ptr)
77

8-
// Attribute that marks a function, parameter, variable, etc., as unused
9-
// (silencing any -Wunused warnings).
10-
#ifndef __unused
11-
#define __unused __attribute__((unused))
12-
#endif
13-
148
// Count the audio callbacks and return after 375 frames (1 second with the default 128 size)
159
//
1610
// *** Remove this in your own code ***
1711
//
1812
volatile int audioProcessedCount = 0;
19-
bool playedAndMixed(double __unused time, void* __unused data) {
13+
bool playedAndMixed(double time, void* data) {
2014
if (audioProcessedCount >= 375) {
2115
emscripten_force_exit(0);
2216
return false;
@@ -34,18 +28,13 @@ EM_JS(EMSCRIPTEN_WEBAUDIO_T, createTrack, (EMSCRIPTEN_WEBAUDIO_T ctxID, const ch
3428
var context = emscriptenGetAudioObject(ctxID);
3529
if (context) {
3630
var audio = document.createElement('audio');
37-
#if __wasm64__
38-
// Number() wrapper is a workaround for UTF8ToString() needing a JS number
39-
// and from64() not being available in EM_JS macros. Fix in UTF8ToString?
40-
url = Number(url);
41-
#endif
4231
audio.src = UTF8ToString(url);
4332
audio.loop = looping;
4433
var track = context.createMediaElementSource(audio);
4534
return emscriptenRegisterAudioObject(track);
4635
}
4736
return 0;
48-
})
37+
});
4938

5039
// Toggles the play/pause of a MediaElementAudioSourceNode given its ID
5140
EM_JS(void, toggleTrack, (EMSCRIPTEN_WEBAUDIO_T srcID), {
@@ -61,10 +50,10 @@ EM_JS(void, toggleTrack, (EMSCRIPTEN_WEBAUDIO_T srcID), {
6150
}
6251
}
6352
}
64-
})
53+
});
6554

66-
// Registered click event to (1) enable audio playback and (2) toggle playing the tracks
67-
bool onClick(int __unused type, const EmscriptenMouseEvent* __unused e, void* data) {
55+
// Registered click even to (1) enable audio playback and (2) toggle playing the tracks
56+
bool onClick(int type, const EmscriptenMouseEvent* e, void* data) {
6857
EMSCRIPTEN_WEBAUDIO_T ctx = VOIDP_2_WA(data);
6958
if (emscripten_audio_context_state(ctx) != AUDIO_CONTEXT_STATE_RUNNING) {
7059
printf("Resuming playback\n");
@@ -80,35 +69,27 @@ bool onClick(int __unused type, const EmscriptenMouseEvent* __unused e, void* da
8069
void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data);
8170

8271
// Worklet thread inited, now create the audio processor
83-
void initialised(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* __unused data) {
72+
void initialised(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
8473
if (!success) {
8574
printf("Audio worklet failed to initialise\n");
8675
return;
8776
}
8877
printf("Audio worklet initialised\n");
8978

9079
WebAudioWorkletProcessorCreateOptions opts = {
91-
.name = "mixer"
80+
.name = "mixer",
9281
};
9382
emscripten_create_wasm_audio_worklet_processor_async(context, &opts, &processorCreated, NULL);
9483
}
9584

96-
// To be implemented by the test code, allowing initialised() to be changed.
97-
EmscriptenStartWebAudioWorkletCallback getStartCallback(void);
98-
9985
// Common entry point for the mixer tests
100-
int main(void) {
101-
char* const workletStack = memalign(16, AUDIO_STACK_SIZE);
102-
printf("Audio worklet stack at 0x%p\n", workletStack);
103-
assert(workletStack);
104-
86+
int main() {
87+
static char workletStack[AUDIO_STACK_SIZE];
10588
EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(NULL);
106-
emscripten_start_wasm_audio_worklet_thread_async(context, workletStack, AUDIO_STACK_SIZE, getStartCallback(), NULL);
107-
89+
emscripten_start_wasm_audio_worklet_thread_async(context, workletStack, sizeof workletStack, &initialised, NULL);
10890
#ifndef BROWSER_TEST
10991
// Special case: browser tests need to exit instantly, interactive tests need to wait
11092
emscripten_runtime_keepalive_push();
11193
#endif
112-
113-
return EXIT_SUCCESS;
94+
return 0;
11495
}

0 commit comments

Comments
 (0)