From fd21b1a62f0fb1a0efd503769b2e5f3a81747af0 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Fri, 4 Dec 2026 14:08:57 -0800 Subject: Start chapter 33 again from the green chapter 32 baseline Copy the completed chapter 32 snapshot into chapter33 and register the new Maven and IDE module. Update chapter paths and introductory documentation; retain the chapter 32 compiler behavior. Preserve the previous memory-management attempt on ch33_wip for selective follow-up changes. Validation: make -k -j8 tests passes with 819 JUnit test executions, including all four lattice shards and native/library integration. git diff --cached --check passes. --- chapter33/src/test/c/audio_test.c | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 chapter33/src/test/c/audio_test.c (limited to 'chapter33/src/test/c') diff --git a/chapter33/src/test/c/audio_test.c b/chapter33/src/test/c/audio_test.c new file mode 100644 index 00000000..f82504c3 --- /dev/null +++ b/chapter33/src/test/c/audio_test.c @@ -0,0 +1,48 @@ +// Explicit optional integration checks: real miniaudio thread, silent device. +#define SIMPLE_AUDIO_TEST_NULL +#include "../../main/c/simple_miniaudio.c" +#include + +int main(void) { + assert(api.play(1)==-1 && api.playing()==0); + assert(api.stop()==0); + api.close(); + for (int pass=0;pass<2;++pass) { + assert(api.open()==0 && api.open()==0); + assert(api.load(NULL,1)==-1); + int16_t pcm[RATE]={0}; + assert(api.load(pcm,0)==-1 && api.load(pcm,RATE*10+1)==-1); + int sound=api.load(pcm,RATE); + assert(sound==4); + pcm[0]=12345; + assert(sounds[sound].pcm[0]==0); + assert(api.play(-1)==-1 && api.play(0)==-1 && api.play(SLOTS)==-1); + assert(api.play(sound)==0 && api.playing()); + // A one-second sound returns while playback is still in progress. + assert(api.stop()==0 && !api.playing()); + for (int cue=1;cue<=3;++cue) { + assert(api.play(cue)==0); + int elapsed=0; + while (api.playing() && elapsed<2000) { ma_sleep(10); elapsed+=10; } + assert(!api.playing()); + } + for (int i=5;i