acphal: audio frame deadlines are exact 1/375 s per frame index #468
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!468
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-468"
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?
@DavidM1911 on GitHub · 2026-11-24 00:43 UTC · original
DavidM1911:acphal-frame-clock→main· +41 −9 · 1 files · 1 commits · openPart of #329 (item 3).
FRAMEwas 2667 µs where one audio frame (128 samples at 48 kHz) is exactly 1/375 s = 2666.6 µs, and eachpopscheduled the next frame by adding it — so the cadence drifted +0.333 µs per frame (+125 ppm, ~0.45 s per hour of audio). Deadlines are now computed per 1-based frame index asepoch + k/375 sin integer nanoseconds (frame_deadline), so there is no accumulation. The "a frame more than 8 late is not made up for" rule is kept by fast-forwarding the index to the same floor (now - 8·FRAME).What is in it
crates/xcl/src/hle/acphal.rs:Channelstoresepoch+next_frameindex instead ofOption<Instant>;frame_due/pop/connectreworked;frame_deadlinehelper;FRAME_CATCHUPconstant; a test that walks 375 frames (exactly 1 s) checking each is due atepoch + k/375 sand not 1 ns earlier.Tested
x86_64-pc-windows-msvc:cargo test -p xcl --lib acphal: 8 passed, 0 failedcargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignoredscripts/smoke.ps1 -Seconds 60,cargo build --release -p xcl:main
a6f5f7a:this PR's head
0d407cf:Not tested
AI use
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@mastrr9 on GitHub · 2026-11-24 01:02 UTC · original
Code audit + NVIDIA RTX 5080 test run on
0d407cfcf81756012401c85f27462e41747b7165(part of #329):Review
Looks clean —
frame_deadline(epoch, k)computesepoch + floor(k * 10^9 / 375)inu128nanoseconds with zero cumulative drift, and the catch-up floor ceiling(wait_ns * 375 + 999_999_999) / 1_000_000_000preserves theFRAME_CATCHUP = 8cap cleanly. (Small note: this and #471 both touchChannel::connectone line apart, so whichever merges second will need a trivial rebase.)Tested
rustc 1.100.0(MSVC), debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored.hle::acphal::tests::frames_stay_on_the_48k_grid_without_drift: passed.SKIPPEDGPU tests (2, wave32-only adapter):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.Not tested
scripts/smoke.ps1run (test suite only).AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.
@alpz1000 on GitHub · 2026-11-24 01:38 UTC · original
Independent check of audio frame scheduling at
0d407cfcf81756012401c85f27462e41747b7165on Windows 11 Home 26200.9974, Intel Core i5-8400, Rust 1.100.0 x86_64-pc-windows-msvc, debug.Tested:
cargo test --locked -p xcl --lib acphalon the unmodified PR head: 8 passed, 0 failed. Then I temporarily extended only the loop bound inframes_stay_on_the_48k_grid_without_driftfrom 375 to 1,350,000 and reran that test. It passed across one simulated hour at 375 frames/s, checking at every frame that it was not due 1 ns before its deadline and was due at the deadline. The local edit was reverted.Not tested: audible drift, actual audio playback, retail titles, or the full workspace suite. This checks the scheduler against simulated timestamps.
AI use: OpenAI Codex (GPT-6) ran the tests and drafted this report.
@ryosen0 on GitHub · 2026-11-24 01:57 UTC · original
Data point from the same NVIDIA card the PR was tested on, different CPU/driver: RTX 3060 Ti 8 GB, Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11. Head
0d407cfmerged ontomain508a0c7(clean), together with #456 and #508 (adjacent paths).cargo test -p xcl --lib -- --test-threads=1 title_textures xaudio2 acphal: 27 passed, 0 failed, including the 375-frame deadline walk.epoch + k/375 sconstruction reads right: no accumulation, and the fast-forward floor keeps the >8-late rule without a second drift source.Not tested: audible retail audio on this stack (the run ended early on its own at t≈34 s, exit 0x0 - unrelated early-exit behaviour of the title); no long-run drift measurement.
AI use: GPT-6.2 Astra (API model selector) in DSH ran the tests and wrote this comment; the human contributor reviewed it.
@MesshM on GitHub · 2026-11-24 04:21 UTC · original
Test run of
0d407cfcf81756012401c85f27462e41747b7165on AMD RDNA4. I merged it onto currentmainf4ce27clocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 702 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 661 passed, 0 failed, 21 ignoredSKIPPED;frames_stay_on_the_48k_grid_without_driftpasses.Review: Deadlines are
epoch + k/375 sin integer nanoseconds per frame index, so there is no accumulated rounding, andFRAME_CATCHUPbounds how many frames a latepopreleases at once. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@Alpha325 on GitHub · 2026-11-25 02:45 UTC · original
I added a synthetic
Channel::poptest that leaves the channel unpolled for one hour, then drains the frames due at that instant. I ran it at the exact one-hour boundary and 1 ms after it.2997c9a0d407cfThe totals include the first frame emitted before the catch-up clamp. After draining, neither revision emitted a frame 1 ns before the next deadline on the original 375 Hz grid. At that exact deadline, 2,666,666 ns after the hour boundary, the PR emitted
MSG_AUDIO_FRAMEin both cases. The parent emitted nothing and failed the fixture as expected.On Windows 11 with Rust 1.100.0 MSVC,
cargo test --offline --locked -p xcl --lib acphal -- --test-threads=1 --nocapturereturned 9 passed, 0 failed on the PR. This checks scheduling with synthetic timestamps. It does not measure audible playback.AI use — OpenAI Codex (GPT-6) wrote and ran the fixture and drafted this report.
@DavidM1911 on GitHub · 2026-11-25 14:15 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.