acphal: audio frame deadlines are exact 1/375 s per frame index #463
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T00:43:36Z.
Part 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
Imported from ivall/xcl. Originally posted by ethandepstein-del on 2026-11-24T01:02:13Z.
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.
Imported from ivall/xcl. Originally posted by alpz1000 on 2026-11-24T01:38:36Z.
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.
Imported from ivall/xcl. Originally posted by ryosen0 on 2026-11-24T01:57:23Z.
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.
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T04:21:29Z.
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.
Imported from ivall/xcl. Originally posted by Alpha325 on 2026-11-25T02:45:56Z.
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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:15:44Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:57Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:10:46Z.
Triage (#1607) – head
0d407cf#463 fixes a different bug from the same issue #329 (PopMessage BOOL width); #471 (merged) fixed the stale-message item. Main's
Channelstill advancesnext_framebyFRAME(2667 us), so the drift is not fixed there.frame_deadlinecomputes frame k at k/375 s in integer nanoseconds, and the catch-up floor matches the old 8-frame behaviour. No problems found in the diff. The PR conflicts with main (main'sChannel::connectchanged in #471).Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.