Split audio update into early/late phases, add asset<->stream type map, switch volume/pan to float, add stream loop limit

- audioUpdate()/audioMixerUpdate() split into Early (before rendering, per-stream buffering) and Late (end of frame, starts newly-queued mixer sounds) phases, wired into engineUpdate() around displayUpdate(); mixer is now actually initialized/disposed/updated from audio.c.
- New src/dusk/audio/stream/audiostreamtype.{h,c}: asset-loader-type <-> audio-stream-type map (with file extension), plus audioStreamAssetTypeForPath()/audioStreamTypeForAssetType()/audioStreamAssetTypeForStreamType() lookups.
- audiostream_t/audiomixerchanneldata_t volume and directionality/pan switched from integer (0-0xFF / -128..127) to float (0.0-1.0 / -1.0..1.0), removing the manual scaling each platform backend had to do.
- audiostream_t gains loopLimit/loopRestartCount so a stream can be told to stop (fire onEnd) after a fixed number of loop restarts instead of looping forever; wired into the shared restart path (Linux/Dolphin) and PSP's own read-ahead loop decision.

Built and verified on Linux, PSP (Docker) and GameCube (Docker).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
2026-09-02 14:39:27 -05:00
co-authored by Claude Sonnet 5
parent b564d0b1c1
commit 619ce932f9
13 changed files with 268 additions and 63 deletions
+2 -2
View File
@@ -191,7 +191,7 @@ errorret_t audioStreamLinuxFeed(audiostream_t *stream) {
const size_t bytesRead = framesRead * frameSize;
int queued;
if(stream->volume == 0xFF) {
if(stream->volume >= 1.0f) {
// Nothing to mix at full volume - queue the window directly instead of
// allocating/zeroing a same-size scratch buffer just to copy it in.
queued = SDL_QueueAudio(stream->platform.device, chunk, (Uint32) bytesRead);
@@ -200,7 +200,7 @@ errorret_t audioStreamLinuxFeed(audiostream_t *stream) {
memoryZero(mixed, bytesRead);
SDL_MixAudioFormat(
mixed, (uint8_t *) chunk, AUDIO_S16SYS, (Uint32) bytesRead,
(stream->volume * SDL_MIX_MAXVOLUME) / 0xFF
(int) (stream->volume * SDL_MIX_MAXVOLUME)
);
queued = SDL_QueueAudio(stream->platform.device, mixed, (Uint32) bytesRead);
memoryFree(mixed);