mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-16 08:11:35 +02:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user