Repository navigation
Conversation
…ENT-AUDIO-PASS-CADENCE) PeriodicThread waited for each pass with WaitForSingleObject and a timeout in milliseconds. On Windows a timeout ends on the system timer's tick, 15.625 ms for a process that has not raised the timer resolution, and nothing in the runtime does. The 10 ms period therefore woke once per tick: about 64 passes a second instead of 100. A spatial stream hands out 480 frames each pass, so the title, which activates ISpatialAudioClient first (docs/runtime_imports.md) and is paced by its event, rendered about 30,700 frames a second against 48,000: its audio clock ran at 64% of real time. The IAudioClient stream's event came at the same rate. The wait now uses a CREATE_WAITABLE_TIMER_HIGH_RESOLUTION timer, as the gameinput and d3d12_xs shims do, set to the next pass's due time, with the stop event beside it. Where the timer cannot be created, the timeout wait remains. Tested (Windows 11, MSVC 14.44): silent_audio_test records when each spatial pass's event arrives and checks the median gap of the nine after Start, unless the whole run took over 300 ms (a starved host, where the spacing says nothing about the timer). On main: 10 passes in 143 to 159 ms, median gap 15.6 to 17.2 ms, the check fails in 3 of 3 runs. With the fix: 10 passes in 90 ms, median gap 10.0 ms, all 130 checks pass in 3 of 3 runs. ctest -j 8 (162 CPU tests) passes apart from the system-commit check of xmem_test that ProjectLeonida#1316 addresses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent verification on this machine (Windows 11, MSVC 19.44.35226), with a negative control that bites. 1. It applies. 2. With the branch its test passes: 3. The control - revert only the shim, keep the test: The assertion is the change: two consecutive passes must be 10 ms apart rather than one system timer tick - the branch makes the audio shim pace by millisecond sleep instead of by Heads-up for whoever merges the What I did not test: whether 10 ms is the right target on a loaded host or under Wine, and the rest of the audio shim. Why I am commenting: I verify open pull requests that replay onto current Written with an AI assistant. |
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 tests: xmem commit-on-touch checks read the test's own view, not system commit (TEST-XMEM-COMMIT-CHECK) #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