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
9
// Count the audio callbacks and return after 375 frames (1 second with the
15
10
// default 128 size).
18
13
//
19
14
#ifdef TEST_AND_EXIT
20
15
volatile int audioProcessedCount = 0 ;
21
- bool playedAndMixed (double __unused time, void * __unused data) {
22
- #if TEST_AND_EXIT > 0
23
- // Special interactive case to play for 10 seconds
24
- if (audioProcessedCount >= 3750 ) {
25
- #else
16
+ bool playedAndMixed (double time, void * data) {
26
17
if (audioProcessedCount >= 375 ) {
27
- #endif
28
18
emscripten_force_exit (0 );
29
19
return false ;
30
20
}
@@ -42,12 +32,9 @@ EM_JS(EMSCRIPTEN_WEBAUDIO_T, createTrack, (EMSCRIPTEN_WEBAUDIO_T ctxID, const ch
42
32
var context = emscriptenGetAudioObject (ctxID);
43
33
if (context) {
44
34
var audio = document.createElement (' audio' );
45
- #if __wasm64__
46
35
// Number() wrapper is a workaround for UTF8ToString() needing a JS number
47
36
// and from64() not being available in EM_JS macros. Fix in UTF8ToString?
48
- url = Number (url);
49
- #endif
50
- audio.src = UTF8ToString (url);
37
+ audio.src = UTF8ToString (Number (url));
51
38
audio.loop = looping;
52
39
var track = context.createMediaElementSource (audio);
53
40
return emscriptenRegisterAudioObject (track);
@@ -72,7 +59,7 @@ EM_JS(void, toggleTrack, (EMSCRIPTEN_WEBAUDIO_T srcID), {
72
59
})
73
60
74
61
// Registered click event to (1) enable audio playback and (2) toggle playing the tracks
75
- bool onClick (int __unused type, const EmscriptenMouseEvent* __unused e, void * data) {
62
+ bool onClick (int type, const EmscriptenMouseEvent* e, void * data) {
76
63
EMSCRIPTEN_WEBAUDIO_T ctx = VOIDP_2_WA (data);
77
64
if (emscripten_audio_context_state (ctx) != AUDIO_CONTEXT_STATE_RUNNING) {
78
65
emscripten_out (" Resuming playback" );
@@ -88,7 +75,7 @@ bool onClick(int __unused type, const EmscriptenMouseEvent* __unused e, void* da
88
75
void processorCreated (EMSCRIPTEN_WEBAUDIO_T context, bool success, void * data);
89
76
90
77
// Worklet thread inited, now create the audio processor
91
- void initialised (EMSCRIPTEN_WEBAUDIO_T context, bool success, void * __unused data) {
78
+ void initialised (EMSCRIPTEN_WEBAUDIO_T context, bool success, void * data) {
92
79
assert (success && " Audio worklet failed in initialised()" );
93
80
emscripten_out (" Audio worklet initialised" );
94
81
@@ -112,13 +99,9 @@ int main(void) {
112
99
113
100
#ifdef TEST_AND_EXIT
114
101
// We're in the test harness and exiting is via playedAndMixed()
115
- #if TEST_AND_EXIT > 0
116
- emscripten_out (" In test mode, will exit after 10 seconds of playback" );
117
- #else
118
102
emscripten_out (" In test mode, will exit after 1 second of playback" );
119
103
#endif
120
104
emscripten_exit_with_live_runtime ();
121
- #endif
122
105
123
106
return EXIT_SUCCESS;
124
107
}
0 commit comments