mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:45:53 +01:00
[PR #2134] silent_audio: pace the 10 ms passes with a high-resolution timer (SILENT-AUDIO-PASS-CADENCE) #2140
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2140
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2134
Author: @syfyra
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/silent-audio-spatial-cadence📝 Commits (1)
2945effsilent_audio: pace the 10 ms passes with a high-resolution timer (SILENT-AUDIO-PASS-CADENCE)📊 Changes
2 files changed (+34 additions, -6 deletions)
View changed files
📝
runtime/shims/silent_audio.cpp(+18 -5)📝
runtime/test/silent_audio_test.cpp(+16 -1)📄 Description
Claimed in the coordination issue as: SILENT-AUDIO-PASS-CADENCE (claim comment to follow)
What and why
runtime/shims/silent_audio.cppPeriodicThread::rundrives both silent streams' 10 ms passes. It waited for each pass withWaitForSingleObject(stop_, wait)and a timeout in whole milliseconds. On Windows a wait timeout ends on the system timer's tick: 15.625 ms for a process that has not raised the timer resolution, and nothing inruntime/does (notimeBeginPeriod/NtSetTimerResolution). The 10 ms period therefore woke once per tick, and the fixed schedule re-anchored after each late wake: about 64 passes a second instead of 100.The title activates
ISpatialAudioClientfirst (docs/runtime_imports.md), and the spatial stream hands out 480 frames per pass and signals its event once per pass. A title paced by that event rendered about 30,700 frames a second against 48,000: its audio clock ran at 64% of real time. TheIAudioClientstream's event came at the same rate (its padding is measured with QPC, so only its cadence was off).The wait now uses a
CREATE_WAITABLE_TIMER_HIGH_RESOLUTIONtimer set to the next pass's due time, with the stop event beside it inWaitForMultipleObjects, as the gameinput and d3d12_xs shims already do. Where the timer cannot be created, the timeout wait remains. It also ends the short busy spin the old loop did when less than 1 ms was left (waittruncated to 0).Tested
Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:
silent_audio_testnow records when each spatial pass's event arrives and checks the median gap of the nine afterStart(8 to 12.5 ms), unless the whole run took over 300 ms: a host that starved the passes says nothing about the timer, so there the gaps are only printed.main: 10 passes in 143 to 159 ms, median gap 15.6 to 17.2 ms; the check fails in 3 of 3 runs.ctest -j 8(162 CPU tests) passes, apart fromxmem_test's system-wide commit check that #1316 addresses.scripts/check_no_game_data.pyon both files.Not tested under Wine; there the high-resolution timer may be unavailable and the old wait stays in use.
GPUs tested: n/a (CPU tests)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.