5
5
// Helper for MEMORY64 to cast a void* to an audio context or type
6
6
#define VOIDP_2_WA (ptr ) ((EMSCRIPTEN_WEBAUDIO_T) (intptr_t ) ptr)
7
7
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
+
8
14
// Count the audio callbacks and return after 375 frames (1 second with the default 128 size)
9
15
//
10
16
// *** Remove this in your own code ***
11
17
//
12
18
volatile int audioProcessedCount = 0 ;
13
- bool playedAndMixed (double time, void * data) {
19
+ bool playedAndMixed (double __unused time, void * __unused data) {
14
20
if (audioProcessedCount >= 375 ) {
15
21
emscripten_force_exit (0 );
16
22
return false ;
@@ -57,7 +63,7 @@ EM_JS(void, toggleTrack, (EMSCRIPTEN_WEBAUDIO_T srcID), {
57
63
});
58
64
59
65
// Registered click even to (1) enable audio playback and (2) toggle playing the tracks
60
- bool onClick (int type, const EmscriptenMouseEvent* e, void * data) {
66
+ bool onClick (int __unused type, const EmscriptenMouseEvent* __unused e, void * data) {
61
67
EMSCRIPTEN_WEBAUDIO_T ctx = VOIDP_2_WA (data);
62
68
if (emscripten_audio_context_state (ctx) != AUDIO_CONTEXT_STATE_RUNNING) {
63
69
printf (" Resuming playback\n " );
@@ -73,7 +79,7 @@ bool onClick(int type, const EmscriptenMouseEvent* e, void* data) {
73
79
void processorCreated (EMSCRIPTEN_WEBAUDIO_T context, bool success, void * data);
74
80
75
81
// Worklet thread inited, now create the audio processor
76
- void initialised (EMSCRIPTEN_WEBAUDIO_T context, bool success, void * data) {
82
+ void initialised (EMSCRIPTEN_WEBAUDIO_T context, bool success, void * __unused data) {
77
83
if (!success) {
78
84
printf (" Audio worklet failed to initialise\n " );
79
85
return ;
@@ -86,40 +92,6 @@ void initialised(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
86
92
emscripten_create_wasm_audio_worklet_processor_async (context, &opts, &processorCreated, NULL );
87
93
}
88
94
89
- // Common entry point for the mixer tests
90
- // stackSize - audio worklet stack size in bytes
91
- // return true if the requested memory could be allocated
92
- bool _main_ (int stackSize) {
93
- // Optional empty space before the audio worklet's stack
94
- #if TEST_OFFSET_GB > 0
95
- char * const emptySpace = malloc (1073741824L * TEST_OFFSET_GB);
96
- if (emptySpace) {
97
- printf (" Empty space allocated (%dGB)\n " , TEST_OFFSET_GB);
98
- } else {
99
- printf (" Failed to allocate the required memory offset\n " );
100
- return false ;
101
- }
102
- #endif
103
-
104
- char * const workletStack = memalign (16 , stackSize);
105
- if (!workletStack) {
106
- printf (" Failed to allocate the required worklet stack\n " );
107
- return false ;
108
- }
109
-
110
- #if TEST_OFFSET_GB > 0
111
- free (emptySpace);
112
- #endif
113
-
114
- EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context (NULL );
115
- emscripten_start_wasm_audio_worklet_thread_async (context, workletStack, stackSize, &initialised, NULL );
116
- #ifndef BROWSER_TEST
117
- // Special case: browser tests need to exit instantly, interactive tests need to wait
118
- emscripten_runtime_keepalive_push ();
119
- #endif
120
- return true ;
121
- }
122
-
123
95
// Common entry point for the mixer tests
124
96
int main () {
125
97
char * const workletStack = memalign (16 , AUDIO_STACK_SIZE);
0 commit comments