Skip to content

Commit 20b222b

Browse files
committed
Fixes to build with MEMORY64
The tests pass the audio context in a void* for convenience, which needs shortening/widening for 64-bit pointers.
1 parent 2ff5c87 commit 20b222b

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

test/webaudio/audioworklet_2x_in_hard_pan.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
// This needs to be big enough for the stereo output, 2x mono inputs and the worker stack
1212
#define AUDIO_STACK_SIZE 3072
1313

14+
// Helper for MEMORY64 to cast an audio context or type to a void*
15+
#define WA_2_VOIDP(ctx) ((void*) (intptr_t) ctx)
16+
// Helper for MEMORY64 to cast a void* to an audio context or type
17+
#define VOIDP_2_WA(ptr) ((EMSCRIPTEN_WEBAUDIO_T) (intptr_t) ptr)
18+
1419
// REPORT_RESULT is defined when running in Emscripten test harness.
1520
#ifdef REPORT_RESULT
1621
// Count the mixed frames and return after 375 frames (1 second with the default 128 size)
@@ -79,7 +84,7 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
7984

8085
// Registered click even to (1) enable audio playback and (2) toggle playing the tracks
8186
bool onClick(int type, const EmscriptenMouseEvent* e, void* data) {
82-
EMSCRIPTEN_WEBAUDIO_T ctx = (EMSCRIPTEN_WEBAUDIO_T) (data);
87+
EMSCRIPTEN_WEBAUDIO_T ctx = VOIDP_2_WA(data);
8388
if (emscripten_audio_context_state(ctx) != AUDIO_CONTEXT_STATE_RUNNING) {
8489
printf("Resuming playback\n");
8590
emscripten_resume_audio_context_sync(ctx);
@@ -117,7 +122,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
117122
emscripten_audio_node_connect(bassID, worklet, 0, 1);
118123
}
119124

120-
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, (void*) (context), false, &onClick);
125+
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, WA_2_VOIDP(context), false, &onClick);
121126

122127
#ifdef REPORT_RESULT
123128
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);

test/webaudio/audioworklet_2x_in_out_stereo.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
// This needs to be big enough for the 2x stereo outputs, 2x inputs and the worker stack
1111
#define AUDIO_STACK_SIZE 6144
1212

13+
// Helper for MEMORY64 to cast an audio context or type to a void*
14+
#define WA_2_VOIDP(ctx) ((void*) (intptr_t) ctx)
15+
// Helper for MEMORY64 to cast a void* to an audio context or type
16+
#define VOIDP_2_WA(ptr) ((EMSCRIPTEN_WEBAUDIO_T) (intptr_t) ptr)
17+
1318
// REPORT_RESULT is defined when running in Emscripten test harness.
1419
#ifdef REPORT_RESULT
1520
// Count the mixed frames and return after 375 frames (1 second with the default 128 size)
@@ -79,7 +84,7 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
7984

8085
// Registered click even to (1) enable audio playback and (2) toggle playing the tracks
8186
bool onClick(int type, const EmscriptenMouseEvent* e, void* data) {
82-
EMSCRIPTEN_WEBAUDIO_T ctx = (EMSCRIPTEN_WEBAUDIO_T) (data);
87+
EMSCRIPTEN_WEBAUDIO_T ctx = VOIDP_2_WA(data);
8388
if (emscripten_audio_context_state(ctx) != AUDIO_CONTEXT_STATE_RUNNING) {
8489
printf("Resuming playback\n");
8590
emscripten_resume_audio_context_sync(ctx);
@@ -119,7 +124,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
119124
emscripten_audio_node_connect(bassID, worklet, 0, 1);
120125
}
121126

122-
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, (void*) (context), false, &onClick);
127+
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, WA_2_VOIDP(context), false, &onClick);
123128

124129
#ifdef REPORT_RESULT
125130
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);

test/webaudio/audioworklet_in_out_mono.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
// This needs to be big enough for the mono output, 2x inputs and the worker stack
1212
#define AUDIO_STACK_SIZE 2048
1313

14+
// Helper for MEMORY64 to cast an audio context or type to a void*
15+
#define WA_2_VOIDP(ctx) ((void*) (intptr_t) ctx)
16+
// Helper for MEMORY64 to cast a void* to an audio context or type
17+
#define VOIDP_2_WA(ptr) ((EMSCRIPTEN_WEBAUDIO_T) (intptr_t) ptr)
18+
1419
// REPORT_RESULT is defined when running in Emscripten test harness.
1520
#ifdef REPORT_RESULT
1621
// Count the mixed frames and return after 375 frames (1 second with the default 128 size)
@@ -91,7 +96,7 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
9196

9297
// Registered click even to (1) enable audio playback and (2) toggle playing the tracks
9398
bool onClick(int type, const EmscriptenMouseEvent* e, void* data) {
94-
EMSCRIPTEN_WEBAUDIO_T ctx = (EMSCRIPTEN_WEBAUDIO_T) (data);
99+
EMSCRIPTEN_WEBAUDIO_T ctx = VOIDP_2_WA(data);
95100
if (emscripten_audio_context_state(ctx) != AUDIO_CONTEXT_STATE_RUNNING) {
96101
printf("Resuming playback\n");
97102
emscripten_resume_audio_context_sync(ctx);
@@ -129,7 +134,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
129134
emscripten_audio_node_connect(bassID, worklet, 0, 1);
130135
}
131136

132-
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, (void*) (context), false, &onClick);
137+
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, WA_2_VOIDP(context), false, &onClick);
133138

134139
#ifdef REPORT_RESULT
135140
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);

test/webaudio/audioworklet_in_out_stereo.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
// This needs to be big enough for the stereo output, 2x inputs and the worker stack
1212
#define AUDIO_STACK_SIZE 4096
1313

14+
// Helper for MEMORY64 to cast an audio context or type to a void*
15+
#define WA_2_VOIDP(ctx) ((void*) (intptr_t) ctx)
16+
// Helper for MEMORY64 to cast a void* to an audio context or type
17+
#define VOIDP_2_WA(ptr) ((EMSCRIPTEN_WEBAUDIO_T) (intptr_t) ptr)
18+
1419
// REPORT_RESULT is defined when running in Emscripten test harness.
1520
#ifdef REPORT_RESULT
1621
// Count the mixed frames and return after 375 frames (1 second with the default 128 size)
@@ -91,7 +96,7 @@ bool process(int numInputs, const AudioSampleFrame* inputs, int numOutputs, Audi
9196

9297
// Registered click even to (1) enable audio playback and (2) toggle playing the tracks
9398
bool onClick(int type, const EmscriptenMouseEvent* e, void* data) {
94-
EMSCRIPTEN_WEBAUDIO_T ctx = (EMSCRIPTEN_WEBAUDIO_T) (data);
99+
EMSCRIPTEN_WEBAUDIO_T ctx = VOIDP_2_WA(data);
95100
if (emscripten_audio_context_state(ctx) != AUDIO_CONTEXT_STATE_RUNNING) {
96101
printf("Resuming playback\n");
97102
emscripten_resume_audio_context_sync(ctx);
@@ -129,7 +134,7 @@ void processorCreated(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
129134
emscripten_audio_node_connect(bassID, worklet, 0, 1);
130135
}
131136

132-
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, (void*) (context), false, &onClick);
137+
emscripten_set_click_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, WA_2_VOIDP(context), false, &onClick);
133138

134139
#ifdef REPORT_RESULT
135140
emscripten_set_timeout_loop(&playedAndMixed, 16, NULL);

0 commit comments

Comments
 (0)