mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-20 04:35:57 +00:00
The sound engine's audio thread takes every queued command list, so the game keeps its sound above 200 fps (#337)
The game thread hands its sound commands to the audio thread in lists: 16, of which 4 are always held, so at most 12 wait in the command ring. The game thread submits at most one per update (1.2.1 main+0x9bd144), the audio thread takes one per 5 ms audio frame (after a list, main+0x883780 goes on past the ring's check). Above about 200 updates a second the ring stays full. The game's guard (main+0x9bcdc4) counts the updates that find the ring of free lists empty and exactly 12 lists in the command ring (0x9bce1c cmp w9, #0xc); the count returns to 0 only when a free list is there. At every multiple of 300 (10 s at 30 fps, 1.25 s at 240) it clears the sound command switch (main+0x2268bfc) and stops every active voice (main+0x226f29c). Only the switch's constructor sets it to 1 (main+0xf31ce8, from the engine's init main+0xf31530), so the game is silent until it is restarted. Measured on 1.2.1 (Linux, RX 6750 XT), same save and scripted input, mix dumped without a device: with fps_limit 60, 144, 180, 200 and 201 the mix has sound; with 205, 210, 220, 230, 239 and 240 it goes silent after the boot logo and stays silent, also at the 130-148 fps of the scene that follows. The guard is read from the code; the switch going to 0 has not been observed in a run. The set audiodrain (TOTK_AUDIO_DRAIN_FIX, audio_drain_fix, on by default) sends the audio thread back to the ring's check after each list, so it takes every queued list in the pass: one site per version (1.2.1 main+0x883780, 1.4.3 main+0x149244), each going to a target the game's own code already branches to in the same way (1.2.1 main+0x883c18, 1.4.3 main+0x149700). The setting is in runtime/cfg.c, totk.ini.example and docs/settings.md. At fps_limit 240, 120 s runs of one build per game version with the set switched, seconds with sound in the mix: on 1.2.1 5 of 118 with the set off and 108 of 118 with it on; on 1.4.3 2 of 118 off and 110 of 119 on. Not run: Windows. Not covered: 1.1.0, whose main we do not have, so its table has no site and it keeps the game's code. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
a5c3e0f9f5
commit
037a39d303
5 files changed
+31
-3
No files matched your search
+3
-3
@@ -32,7 +32,7 @@ static int save_ok = 1; // the last cfg_save_to wrote (o
|
||||
// logged as unknown. A new variable goes here too, or its ini key logs a harmless "unknown key" line, and gets a
|
||||
// description in totk.ini.example or docs/settings.md (tests/settings_doc_check.py checks both).
|
||||
static const char *const known[] = {
|
||||
"AB", "ABILITY_GUARD", "ADDR_REPORT", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CHANNELS", "AUDIO_DEVICE", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"AB", "ABILITY_GUARD", "ADDR_REPORT", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CHANNELS", "AUDIO_DEVICE", "AUDIO_DRAIN_FIX", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"BACKGROUND_WINDOW", "BIND_A", "BIND_B", "BIND_DOWN", "BIND_L", "BIND_LCLICK", "BIND_LEFT", "BIND_LSTICK_DOWN", "BIND_LSTICK_LEFT",
|
||||
"BIND_LSTICK_RIGHT", "BIND_LSTICK_UP", "BIND_MINUS",
|
||||
"BIND_PLUS", "BIND_R", "BIND_RCLICK", "BIND_RIGHT", "BIND_RSTICK_DOWN", "BIND_RSTICK_LEFT", "BIND_RSTICK_RIGHT", "BIND_RSTICK_UP",
|
||||
@@ -75,7 +75,7 @@ static const char *const known[] = {
|
||||
static const struct { const char *key, *section; } sections[] = {
|
||||
{"FPS_LIMIT", "frame rate"}, {"FPS60", "frame rate"}, {"FRAME_QUEUE", "frame rate"},
|
||||
{"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"},
|
||||
{"CLIMB_FIX", "frame rate"},
|
||||
{"CLIMB_FIX", "frame rate"}, {"AUDIO_DRAIN_FIX", "frame rate"},
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
|
||||
@@ -161,7 +161,7 @@ static const CfgMeta metas[] = {
|
||||
{"REALTIME", "1", "0|1", RESTART}, {"CLOTH_REALTIME", "1", "0|1", RESTART},
|
||||
{"MODS_REBUILD", "auto", "auto|off", RESTART},
|
||||
{"MODS_WITHOUT_CODE", "0", "0|1", RESTART}, // 1: a mod is used without the code module it cannot run (mods.c)
|
||||
{"HIGHFPS_FIX", "1", "0|1", RESTART}, {"CLIMB_FIX", "1", "0|1", RESTART},
|
||||
{"HIGHFPS_FIX", "1", "0|1", RESTART}, {"CLIMB_FIX", "1", "0|1", RESTART}, {"AUDIO_DRAIN_FIX", "1", "0|1", RESTART},
|
||||
{"LANG", "", "ja|en-US|fr|de|it|es|zh-CN|ko|nl|pt|ru|zh-TW|en-GB|fr-CA|es-419|zh-Hans|zh-Hant|pt-BR", RESTART},
|
||||
{"OPERATION_MODE", "docked", "docked|handheld", RESTART},
|
||||
{"ASSUME_FOCUS", "1", "0|1", LIVE}, // read on every focus change (ov_system.c)
|
||||
|
||||
Reference in new issue
Block a user