runtime: count decoded Opus completions and desktop audio submissions #3180

Manually merged
github merged 4 commits from github-bot/gh-3178 into gh-pr/3178/base 2026-11-27 23:40:21 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-11-27 20:30 UTC · original
lambirou:codex/opus-completion-count → main · +736 −24 · 9 files · 4 commits · merged 2026-11-27 23:36 UTC

Changes

Adds bounded, saturating telemetry to the optional Opus decode path:

  • xapu.dll counts readable type 3 commands, successful libopus decodes, dequeued type 3 completions, and each refusal reason (invalid_argument, opus_error, capacity, queue_full, short_command, unknown_handle, out_of_memory, header).
  • One stable x2w-audio XApu opus summary: line is written at the last disconnect, or from atexit when the run never disconnects, only when the counters moved.
  • The desktop audio sink reports accepted and not_open submissions, so an endpoint that never opened is distinguishable from one that accepted decoded blocks.
  • The counters start on the first readable type 3 command; typed completions off reads and writes nothing.

Validation

Built with libopus 1.5.2 (static MSVC runtime) on Windows 11 build 26300:

cmake --preset dev -DX2W_WITH_OPUS=ON -DOpus_DIR=<install>/lib/cmake/Opus
cmake --build --preset dev --target startup_stub_xapu startup_xapu_opus_count_check startup_xapu_queue_check startup_xapu_opus_check startup_audio_output
ctest --preset dev --no-tests=error -R '^(startup_xapu_opus_count|startup_xapu_(queue|opus)|startup_audio_output)$' -V
  • startup_xapu_opus_count: passed (2 decodes/dequeues, 7 refusals by reason, one summary, saturation, typed-completions-off control).
  • startup_xapu_opus, startup_xapu_queue, startup_audio_output: 3/3 passed.
  • The default build without libopus is unchanged.

Limits

The counters prove that the optional decode path ran and that the caller consumed the results. They do not prove that the output was audible, that the desktop sink accepted the same block, or that XMA/AcpHal works. The title run behind the 27/11 audio observation was not available locally, so this PR adds the measurement, not the run receipt.

Refs #1145 #870.

Merge update (2026-11-27, b1dd0bd7)

Merged origin/main (e582a9a4) into the branch. The only conflict was src/startup_stubs/xapu.cpp: main's typed Opus stream path (48 kHz stream channels, skipped frames, planar stereo, sequence/options/context result words) and this PR's counters/refusal classification now share one QueueEntry and one decode_packet. The stream path computes entry.frames/value and the planar buffer; the counters observe the successful decode and refusal reason.

Debug startup_xapu_opus_count, startup_xapu_queue, startup_xapu_opus and startup_audio_output pass 4/4 with libopus 1.5.2 static. A separate Release libopus 1.5.2 static build now links and passes the same four tests.

Review update (2026-11-27, fd2f693e)

R0Y00's invalid-slot finding is fixed. Both return sites now set DecodeRefusal::invalid_argument: the typed stream check in XApuEnqueueCommand and the legacy slot >= max_slots check in decode_packet. The channel-count invalid-argument branches in the stream path set it too.

startup_xapu_opus_count_check now sends a valid packet and output window with slot = UINT32_MAX through both the legacy connection and a process-1 typed stream connection. Both return E_INVALIDARG, queue nothing and leave the output untouched. The summary is now type3=10 packets=2 completions=2 refusals=9 invalid_argument=3 ..., matching the expected counts.

Debug and Release with libopus 1.5.2 static: startup_xapu_opus_count, startup_xapu_queue, startup_xapu_opus and startup_audio_output pass 4/4. CI is running on fd2f693e.

**@⁠lambirou** on GitHub · 2026-11-27 20:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178) `lambirou:codex/opus-completion-count` → `main` · +736 −24 · 9 files · 4 commits · merged 2026-11-27 23:36 UTC ## Changes Adds bounded, saturating telemetry to the optional Opus decode path: - `xapu.dll` counts readable type 3 commands, successful libopus decodes, dequeued type 3 completions, and each refusal reason (`invalid_argument`, `opus_error`, `capacity`, `queue_full`, `short_command`, `unknown_handle`, `out_of_memory`, `header`). - One stable `x2w-audio XApu opus summary:` line is written at the last disconnect, or from `atexit` when the run never disconnects, only when the counters moved. - The desktop audio sink reports `accepted` and `not_open` submissions, so an endpoint that never opened is distinguishable from one that accepted decoded blocks. - The counters start on the first readable type 3 command; typed completions off reads and writes nothing. ## Validation Built with libopus 1.5.2 (static MSVC runtime) on Windows 11 build 26300: ```powershell cmake --preset dev -DX2W_WITH_OPUS=ON -DOpus_DIR=<install>/lib/cmake/Opus cmake --build --preset dev --target startup_stub_xapu startup_xapu_opus_count_check startup_xapu_queue_check startup_xapu_opus_check startup_audio_output ctest --preset dev --no-tests=error -R '^(startup_xapu_opus_count|startup_xapu_(queue|opus)|startup_audio_output)$' -V ``` - `startup_xapu_opus_count`: **passed** (2 decodes/dequeues, 7 refusals by reason, one summary, saturation, typed-completions-off control). - `startup_xapu_opus`, `startup_xapu_queue`, `startup_audio_output`: **3/3 passed**. - The default build without libopus is unchanged. ## Limits The counters prove that the optional decode path ran and that the caller consumed the results. They do not prove that the output was audible, that the desktop sink accepted the same block, or that XMA/AcpHal works. The title run behind the 27/11 audio observation was not available locally, so this PR adds the measurement, not the run receipt. Refs #1145 #870. ## Merge update (2026-11-27, `b1dd0bd7`) Merged `origin/main` (`e582a9a4`) into the branch. The only conflict was `src/startup_stubs/xapu.cpp`: main's typed Opus stream path (48 kHz stream channels, skipped frames, planar stereo, sequence/options/context result words) and this PR's counters/refusal classification now share one `QueueEntry` and one `decode_packet`. The stream path computes `entry.frames/value` and the planar buffer; the counters observe the successful decode and refusal reason. Debug `startup_xapu_opus_count`, `startup_xapu_queue`, `startup_xapu_opus` and `startup_audio_output` pass 4/4 with libopus 1.5.2 static. A separate Release libopus 1.5.2 static build now links and passes the same four tests. ## Review update (2026-11-27, `fd2f693e`) R0Y00's invalid-slot finding is fixed. Both return sites now set `DecodeRefusal::invalid_argument`: the typed stream check in `XApuEnqueueCommand` and the legacy `slot >= max_slots` check in `decode_packet`. The channel-count invalid-argument branches in the stream path set it too. `startup_xapu_opus_count_check` now sends a valid packet and output window with `slot = UINT32_MAX` through both the legacy connection and a process-1 typed stream connection. Both return `E_INVALIDARG`, queue nothing and leave the output untouched. The summary is now `type3=10 packets=2 completions=2 refusals=9 invalid_argument=3 ...`, matching the expected counts. Debug and Release with libopus 1.5.2 static: `startup_xapu_opus_count`, `startup_xapu_queue`, `startup_xapu_opus` and `startup_audio_output` pass 4/4. CI is running on `fd2f693e`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:34:48 +00:00
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 22:19 UTC · original

Merged origin/main (e582a9a4); head is b1dd0bd7. The xapu.cpp conflict now combines main's typed Opus stream path with this PR's counters and refusal reasons. Debug Opus/queue/audio tests are 4/4. The local Release link still hits the prebuilt static Opus debug-CRT mismatch (LIBCMTD vs LIBCMT), unrelated to the merge; the default no-Opus build is unaffected.

**@⁠lambirou** on GitHub · 2026-11-27 22:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229235013) Merged `origin/main` (`e582a9a4`); head is `b1dd0bd7`. The `xapu.cpp` conflict now combines main's typed Opus stream path with this PR's counters and refusal reasons. Debug Opus/queue/audio tests are 4/4. The local Release link still hits the prebuilt static Opus debug-CRT mismatch (`LIBCMTD` vs `LIBCMT`), unrelated to the merge; the default no-Opus build is unaffected.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 22:23 UTC · original

Windows checks #8436 completed successfully on b1dd0bd7.

**@⁠lambirou** on GitHub · 2026-11-27 22:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229286797) Windows checks #8436 completed successfully on `b1dd0bd7`.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 22:24 UTC · original

@⁠R0Y00 @⁠pigalot #3180 is ready for review at b1dd0bd7: main is merged, the Opus stream path and counters share one decode_packet, Debug Opus/queue/audio tests are 4/4, and Windows checks #8436 is green.

**@⁠lambirou** on GitHub · 2026-11-27 22:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229302675) @⁠R0Y00 @⁠pigalot #3180 is ready for review at `b1dd0bd7`: `main` is merged, the Opus stream path and counters share one `decode_packet`, Debug Opus/queue/audio tests are 4/4, and Windows checks #8436 is green.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 22:55 UTC · original · requested changes

I integrated b1dd0bd7 over main 4b0350ea (clean tree 1660eb86), built with libopus 1.5.2, and ran ctest --test-dir <build> --no-tests=error -j1 -V -R '^(startup_xapu_(opus_count|queue|opus)|startup_audio_output)$'. The existing suite passed 4/4 in Debug and Release /O2.

The documented invalid_argument telemetry misses out-of-range slots in two paths. The typed stream path sets hr_invalid_arg before decode_packet without setting refusal, and the legacy path in decode_packet also returns early for slot >= max_slots without setting it. I added two synthetic type-3 commands with slot = UINT32_MAX to the count fixture, using a valid packet and output window. Each returned E_INVALIDARG, queued nothing and left the output untouched. The summary changed from type3=8 invalid_argument=1 refusals=7 to type3=10 invalid_argument=1 refusals=7; I expected type3=10 invalid_argument=3 refusals=9.

Please classify the invalid slot at both returns and add a counter control covering both modes. A local change assigning DecodeRefusal::invalid_argument at the two sites produced the expected summary and passed all four Debug tests. The changes and probe stayed local.

**@⁠R0Y00** on GitHub · 2026-11-27 22:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#pullrequestreview-6094101226) · **requested changes** I integrated `b1dd0bd7` over `main` `4b0350ea` (clean tree `1660eb86`), built with libopus 1.5.2, and ran `ctest --test-dir <build> --no-tests=error -j1 -V -R '^(startup_xapu_(opus_count|queue|opus)|startup_audio_output)$'`. The existing suite passed 4/4 in Debug and Release /O2. The documented `invalid_argument` telemetry misses out-of-range slots in two paths. The typed stream path sets `hr_invalid_arg` before `decode_packet` without setting `refusal`, and the legacy path in `decode_packet` also returns early for `slot >= max_slots` without setting it. I added two synthetic type-3 commands with `slot = UINT32_MAX` to the count fixture, using a valid packet and output window. Each returned `E_INVALIDARG`, queued nothing and left the output untouched. The summary changed from `type3=8 invalid_argument=1 refusals=7` to `type3=10 invalid_argument=1 refusals=7`; I expected `type3=10 invalid_argument=3 refusals=9`. Please classify the invalid slot at both returns and add a counter control covering both modes. A local change assigning `DecodeRefusal::invalid_argument` at the two sites produced the expected summary and passed all four Debug tests. The changes and probe stayed local.
The typed-stream path rejected an out-of-range slot before decode_packet
without setting the refusal reason, and the legacy decode path returned
without classifying it. Set DecodeRefusal::invalid_argument at both sites.

The count fixture now sends slot UINT32_MAX through the legacy and stream
paths and expects type3=10, invalid_argument=3, refusals=9.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 23:11 UTC · original

Review update (2026-11-27, 01677235)

R0Y00's invalid-slot finding is fixed. Both return sites now set DecodeRefusal::invalid_argument: the typed stream check in XApuEnqueueCommand and the legacy slot >= max_slots check in decode_packet. The channel-count invalid-argument branches in the stream path set it too.

startup_xapu_opus_count_check now sends a valid packet and output window with slot = UINT32_MAX through both the legacy connection and a process-1 typed stream connection. Both return E_INVALIDARG, queue nothing and leave the output untouched. The summary is now type3=10 packets=2 completions=2 refusals=9 invalid_argument=3 ..., matching the expected counts.

Debug with libopus 1.5.2 static: startup_xapu_opus_count, startup_xapu_queue, startup_xapu_opus and startup_audio_output pass 4/4. CI is running on 01677235.

**@⁠lambirou** on GitHub · 2026-11-27 23:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229941858) ## Review update (2026-11-27, `01677235`) R0Y00's invalid-slot finding is fixed. Both return sites now set `DecodeRefusal::invalid_argument`: the typed stream check in `XApuEnqueueCommand` and the legacy `slot >= max_slots` check in `decode_packet`. The channel-count invalid-argument branches in the stream path set it too. `startup_xapu_opus_count_check` now sends a valid packet and output window with `slot = UINT32_MAX` through both the legacy connection and a process-1 typed stream connection. Both return `E_INVALIDARG`, queue nothing and leave the output untouched. The summary is now `type3=10 packets=2 completions=2 refusals=9 invalid_argument=3 ...`, matching the expected counts. Debug with libopus 1.5.2 static: `startup_xapu_opus_count`, `startup_xapu_queue`, `startup_xapu_opus` and `startup_audio_output` pass 4/4. CI is running on `01677235`.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 23:11 UTC · original

@⁠R0Y00 both invalid-slot paths now classify invalid_argument, and the fixture verifies the expected type3=10 invalid_argument=3 refusals=9 summary on 01677235. Could you re-review?

**@⁠lambirou** on GitHub · 2026-11-27 23:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229943192) @⁠R0Y00 both invalid-slot paths now classify `invalid_argument`, and the fixture verifies the expected `type3=10 invalid_argument=3 refusals=9` summary on `01677235`. Could you re-review?
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 23:15 UTC · original

Release is now verified too: with a Release libopus 1.5.2 static build, startup_xapu_opus_count, startup_xapu_queue, startup_xapu_opus and startup_audio_output pass 4/4 on fd2f693e, including type3=10 invalid_argument=3 refusals=9.

**@⁠lambirou** on GitHub · 2026-11-27 23:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7230005750) Release is now verified too: with a Release libopus 1.5.2 static build, `startup_xapu_opus_count`, `startup_xapu_queue`, `startup_xapu_opus` and `startup_audio_output` pass 4/4 on `fd2f693e`, including `type3=10 invalid_argument=3 refusals=9`.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 23:16 UTC · original

Windows checks #8462 completed successfully on fd2f693e. Debug and Release Opus/queue/audio tests are 4/4 with libopus 1.5.2 static.

**@⁠lambirou** on GitHub · 2026-11-27 23:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7230008878) Windows checks #8462 completed successfully on `fd2f693e`. Debug and Release Opus/queue/audio tests are 4/4 with libopus 1.5.2 static.
github-bot changed target branch from main to gh-pr/3178/base 2026-11-27 23:40:20 +00:00
github manually merged commit fd2f693ef2 into gh-pr/3178/base 2026-11-27 23:40:21 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 23:35 UTC · original · approved these changes

The previous invalid-slot finding is addressed on fd2f693e: both the legacy decode guard and typed stream guard now classify slot >= max_slots, and the count fixture exercises both. Independently integrated over main fad97f47 (clean tree 3208b0ee) and built with libopus 1.5.2. ctest --test-dir <build> --no-tests=error -j1 -V -R '^(startup_xapu_(opus_count|queue|opus)|startup_audio_output)$' passed 4/4 in Debug and Release /O2, no skips. Both logs contain type3=10 packets=2 completions=2 refusals=9 invalid_argument=3, and the rest of the refusal fields are intact. The intervening #3224 merge adds only GPU fixture/docs changes and leaves the audio paths and tests identical. Hosted Windows passed.

**@⁠R0Y00** on GitHub · 2026-11-27 23:35 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3178#pullrequestreview-6094311406) · **approved these changes** The previous invalid-slot finding is addressed on `fd2f693e`: both the legacy decode guard and typed stream guard now classify `slot >= max_slots`, and the count fixture exercises both. Independently integrated over `main` `fad97f47` (clean tree `3208b0ee`) and built with libopus 1.5.2. `ctest --test-dir <build> --no-tests=error -j1 -V -R '^(startup_xapu_(opus_count|queue|opus)|startup_audio_output)$'` passed 4/4 in Debug and Release /O2, no skips. Both logs contain `type3=10 packets=2 completions=2 refusals=9 invalid_argument=3`, and the rest of the refusal fields are intact. The intervening #3224 merge adds only GPU fixture/docs changes and leaves the audio paths and tests identical. Hosted Windows passed.
This discussion has been locked. Commenting is limited to contributors.
No description provided.