startup: add a WASAPI render sink and the startup_audio_output fixture #1250
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1250
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1250/head"
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?
@tedin7 on GitHub · 2026-11-24 05:28 UTC · original
tedin7:x2w-c3-audio-output→main· +564 −1 · 8 files · 2 commits · merged 2026-11-24 05:58 UTCWhat
src/startup_stubs/audio_sink.{h,cpp}: desktop WASAPI shared-mode render sink. Default endpoint viaIMMDeviceEnumerator, mix format fromGetMixFormat(32-bit float or 16-bit PCM only, anything else is a skip),IAudioRenderClientto write,GetCurrentPaddingandIAudioClock::GetPositionto observe consumption. One call,submit(format, frames, bytes), converts the block to the mix format. It records the first accepted block, submitted format, per-block frame counts and peaks, consumed frames, drained interval, recovery, and a glitch count kept separate (the render API exposes no discontinuity flag, so it reports "not available").tests/startup_audio_output.cpp(CTeststartup_audio_output, exit 77 = capability skip): (a) no submission, (b) eight generated 40 ms tone blocks with distinct amplitudes including one all-zero block that must be accepted and counted, (c) producer starvation: drain to padding 0, hold 300 ms, resume, consumption recovers. All waits are bounded; CTest TIMEOUT 60.docs/startup-runtime.md: short "Audio output" section.Why
First slice of #1145: a real desktop buffer submission and consumption record that separates absent output, valid silent samples and producer starvation. Fixtures are generated tones only.
Tested
Commands on Windows:
Run here (Linux host): the pure helpers (conversion, silence detection, drained/recovery arithmetic) built with
g++ -std=c++17and-std=c++20and ran clean;python3 -B tests/docs_links_check.pyandtests/bidi_controls_check.pypassed.NOT run: nothing that touches Windows.
audio_sink.cpp,tests/startup_audio_output.cppand the CMake registration were never compiled with MSVC and the fixture was never run against an endpoint. Please treat the Windows results (endpoint, format, build, per-case counters) as still to be reported.Not included: no capture-path verification of the generated tone, and no decoding of the console audio command queue (
xapu.cppis unchanged; its payload layout is still unknown).Refs #1145
@tedin7 on GitHub · 2026-11-24 05:30 UTC · original
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207, AMD Ryzen 5 PRO 5650U) at HEAD
89d860cfeb8097a285d01107e4367b5476e96438:--preset dev):cmake --build --preset dev --target startup_audio_output -- -j 6: built cleanly ([3/3] Linking CXX executable startup_audio_output.exe).ctest --preset dev --no-tests=error -R "^startup_audio_output$" -V:pure checks: conversion, silence detection and drained/recovery arithmetic okSKIP (capability): no default render endpoint, hr=-2147023728(0x80070490, headless VM has no audio render endpoint)windows: 10.0 build 261001/1 Test #53: startup_audio_output .............***Skipped 0.05 sec(exit code 0, clean capability skip 77).--preset release):cmake --build --preset release --target startup_audio_output -- -j 6: built cleanly ([3/3] Linking CXX executable startup_audio_output.exe).ctest --preset release --no-tests=error -R "^startup_audio_output$" -V:pure checks: conversion, silence detection and drained/recovery arithmetic okSKIP (capability): no default render endpoint, hr=-2147023728windows: 10.0 build 261001/1 Test #53: startup_audio_output .............***Skipped 0.02 sec(exit code 0, clean capability skip 77).@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 05:32 UTC · original · edited 2026-11-24 05:38 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
89d860cℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@ -166,0 +179,4 @@```powershellcmake --build --preset release --target startup_audio_outputctest --preset release --no-tests=error -R '^startup_audio_output$' -V@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 05:38 UTC · original
This introduces a public render capability and reproduction commands, but the commit updates neither the README experiment table nor
docs/experiments.md.AGENTS.mdrequires updating those entry points when public capabilities or reproduction commands change, andCONTRIBUTING.mdspecifically requires the README entry and experiment reproduction details. Add the fixture, capability-skip behavior, and limitations there so contributors following the prescribed experiment index can discover and reproduce it.AGENTS.md reference: AGENTS.md:L176-L177
Useful? React with 👍 / 👎.
@ -0,0 +102,4 @@++r_.padding_errors;return padding_failed;}return pad;@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 05:38 UTC · original
If the Windows endpoint is invalidated while audio remains queued,
GetCurrentPaddingcan fail withAUDCLNT_E_DEVICE_INVALIDATED, but its HRESULT is discarded andpadcan remain zero.observe()then counts every submitted frame as consumed and can mark recovery complete; an invalidation immediately after case (c)'s resume submission can therefore satisfy its assertions without consuming that block. Propagate the query failure and make the fixture reject the observation instead of advancing consumption and starvation measurements.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 05:38 UTC · original
On the successful Windows path,
a,b, andcare still alive when this call uninitializes COM. They are destroyed only asmainreturns, andAudioSink::~AudioSink()still callsIAudioClient::Stop()before itsComPtrmembers release the interfaces. Those operations therefore occur after COM teardown and can fail or crash during shutdown despite the fixture having printed PASS. Put the sinks in an inner scope, or use a COM lifetime guard declared before them, so all interfaces are stopped and released beforeCoUninitialize().Useful? React with 👍 / 👎.
@ -166,0 +179,4 @@```powershellcmake --build --preset release --target startup_audio_outputctest --preset release --no-tests=error -R '^startup_audio_output$' -V@tedin7 on GitHub · 2026-11-24 05:39 UTC · original
Fixed in
16a5a077: README experiment table row added, and a "Desktop audio render sink" section in docs/experiments.md (fixture, command, capability-skip meaning, what is not covered; no endpoint run is recorded there yet).@ -0,0 +102,4 @@++r_.padding_errors;return padding_failed;}return pad;@tedin7 on GitHub · 2026-11-24 05:39 UTC · original
Fixed in
16a5a077:padding()now returnspadding_failedand countspadding_errorswhenGetCurrentPaddingfails.observe()makes no observation in that case (consumption and the queue timers do not move),submit()refuses the block, and the fixture fails the run if any case haspadding_errors. Not compiled or run on Windows by me.@tedin7 on GitHub · 2026-11-24 05:40 UTC · original
Fixed in
16a5a077: the three sinks now live inrun(), andmain()callsCoUninitialize()only afterrun()has returned, so they stop and release their interfaces first. Not compiled or run on Windows by me.@tedin7 on GitHub · 2026-11-24 05:43 UTC · original
Verified on Windows Server 2025 (build 26100, MSVC 14.44,
sccache) at commit16a5a077872411f3ccd7418456b9ed72960de78e.Commands:
cmake --preset dev+cmake --build --preset dev --target startup_audio_output(4.3s build, 5.97s dev total)ctest --preset dev -R "^startup_audio_output$" -Vcmake --preset release+cmake --build --preset release --target startup_audio_output(1.88s build, 3.44s release total)ctest --preset release -R "^startup_audio_output$" -VResult (
devandrelease):pure checks: conversion, silence detection and drained/recovery arithmetic okSKIP (capability): no default render endpoint, hr=-2147023728100% tests passed out of 1, 1 skipped due to no default render endpoint on this headless Server 2025 VM).@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 05:38 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
89d860cfebℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".