fix(switch): pass NX cache prefix to the chip-audio worker

Yellow music was still silent because the background worker thread loads
ChipSynth.lua in a fresh Lua state with no GameVersion/Platform context.
The main thread's prefix never reached it.

ChipAudio.slimAudio now resolves the versioned cache prefix on the main
thread and includes it in the audio payload as `programPrefix`.
ChipSynth.loadBanks prefers `audio.programPrefix` when present, falling
back to its own NX detection for the sync path. Blue and Yellow are
handled the same way.

Tests cover the worker prefix hand-off and Blue's programs.bin path.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Andrew Quenehen
2026-08-03 15:26:37 -03:00
parent e4ce1063a1
commit 16b6b98ede
3 changed files with 59 additions and 7 deletions
+13
View File
@@ -100,14 +100,27 @@ end
-- play so a hot-reloaded dataset (or a mod's audio) always reaches the worker
local function slimAudio(data)
local audio = data.audio or {}
-- NX-only: resolve the versioned cache prefix on the main thread and hand
-- it to the worker, which runs in a fresh Lua state without GameVersion.
local programPrefix
if require("src.core.Platform").isNX() then
local prefix = require("src.core.GameVersion").cachePrefix()
if prefix ~= "" then programPrefix = prefix end
end
return {
programFile = audio.programFile,
programPrefix = programPrefix,
bankOrder = audio.bankOrder,
waveBanks = audio.waveBanks,
noiseHeaders = audio.noiseHeaders,
}
end
-- test-only: expose slimAudio so the NX prefix hand-off is verifiable
function ChipAudio._slimAudioForTest(data)
return slimAudio(data)
end
-- If the worker died (a malformed def that errors mid-synth), fall back to the
-- synchronous path for the rest of the session instead of going silent.
local function workerAlive()