Keep the desktop audio mixer refill timer responsive #1441

Merged
R0Y00 merged 1 commit from upstream-pr/1448 into main 2026-11-24 12:03:15 +00:00
R0Y00 commented 2026-11-24 11:45:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T11:45:09Z.


Hold a 1 ms Windows timer request while a permissive XApu connection is active. On this Windows machine a mix worker requesting a 2 ms sleep otherwise waited about 15 ms. Release the timer on the last disconnect.

Local Release build and verification:

  • cmake --build out/audio-release --target startup_stub_xapu
  • A local source-built client measured median Sleep(2) at 15.30 ms before connection, 2.32 ms with two connections, 2.52 ms after one disconnect, and 15.34 ms after the final disconnect. A null output connection failed as expected.
  • In the 15-second stereo playback comparison, the audio queue received 2,880,000 bytes at 48 kHz PCM16, up from 1,284,000. The final build had 7 near-silent 10 ms intervals among 1,228 intervals where the reference audio was clearly audible, down from 282.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6581015977 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1448). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T11:45:09Z. --- Hold a 1 ms Windows timer request while a permissive XApu connection is active. On this Windows machine a mix worker requesting a 2 ms sleep otherwise waited about 15 ms. Release the timer on the last disconnect. Local Release build and verification: - `cmake --build out/audio-release --target startup_stub_xapu` - A local source-built client measured median Sleep(2) at 15.30 ms before connection, 2.32 ms with two connections, 2.52 ms after one disconnect, and 15.34 ms after the final disconnect. A null output connection failed as expected. - In the 15-second stereo playback comparison, the audio queue received 2,880,000 bytes at 48 kHz PCM16, up from 1,284,000. The final build had 7 near-silent 10 ms intervals among 1,228 intervals where the reference audio was clearly audible, down from 282.
tedin7 commented 2026-11-24 11:54:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:54:08Z.

Review: COMMENTED


Reviewed commit e8003928576871c5fa7dd0de55a49296aa0c6e55 (git diff origin/main...HEAD).

Checks

  • Linux: python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, and git diff --check origin/main..HEAD passed. Title-neutrality clean.
  • Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): startup_stub_xapu, startup_stub_consumer built (24.08s); ctest -R '^startup_stubs$' 1/1 passed (0.49s).
    • Release /O2 (--preset release): built (36.46s); 1/1 passed (0.52s).

Findings

  • src/startup_stubs/xapu.cpp: SRWLOCK-guarded connection_count and timer_active cleanly balance timeBeginPeriod(1) / timeEndPeriod(1) across repeated/concurrent XApuConnect calls, timeBeginPeriod failure, and mismatched or extra XApuDisconnect calls (connection_count underflow is guarded).
  • CMakeLists.txt: startup_stub_xapu links winmm as required for timeapi.h.
  • Coverage note: startup_stubs verifies the DLL build and default trap behavior; the X2W_AUDIO_PERMISSIVE=1 timeBeginPeriod(1)/timeEndPeriod(1) path itself is not exercised by startup_stubs.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6038711814 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1448#pullrequestreview-6038711814). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T11:54:08Z. **Review:** COMMENTED --- Reviewed commit `e8003928576871c5fa7dd0de55a49296aa0c6e55` (`git diff origin/main...HEAD`). ### Checks - **Linux**: `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, and `git diff --check origin/main..HEAD` passed. Title-neutrality clean. - **Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - **Debug (`--preset dev`)**: `startup_stub_xapu`, `startup_stub_consumer` built (`24.08s`); `ctest -R '^startup_stubs$'` **1/1 passed** (`0.49s`). - **Release `/O2` (`--preset release`)**: built (`36.46s`); **1/1 passed** (`0.52s`). ### Findings - `src/startup_stubs/xapu.cpp`: `SRWLOCK`-guarded `connection_count` and `timer_active` cleanly balance `timeBeginPeriod(1)` / `timeEndPeriod(1)` across repeated/concurrent `XApuConnect` calls, `timeBeginPeriod` failure, and mismatched or extra `XApuDisconnect` calls (`connection_count` underflow is guarded). - `CMakeLists.txt`: `startup_stub_xapu` links `winmm` as required for `timeapi.h`. - **Coverage note**: `startup_stubs` verifies the DLL build and default trap behavior; the `X2W_AUDIO_PERMISSIVE=1` `timeBeginPeriod(1)`/`timeEndPeriod(1)` path itself is not exercised by `startup_stubs`.
upstream-sync closed this pull request 2026-11-24 13:00:29 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1441
No description provided.