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

Merged
lambirou merged 4 commits from upstream-pr/3178 into main 2026-11-27 23:36:27 +00:00
lambirou commented 2026-11-27 20:30:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T20:30:11Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5532714436 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T20:30:11Z. --- ## 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`.
lambirou commented 2026-11-27 22:19:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T22:19:50Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229235013 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229235013). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T22:19:50Z. --- 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 commented 2026-11-27 22:23:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T22:23:22Z.


Windows checks #8436 completed successfully on b1dd0bd7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229286797 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229286797). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T22:23:22Z. --- Windows checks #8436 completed successfully on `b1dd0bd7`.
lambirou commented 2026-11-27 22:24:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T22:24:30Z.


@R0Y00 @pigalot #3178 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229302675 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229302675). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T22:24:30Z. --- @R0Y00 @pigalot #3178 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.
R0Y00 commented 2026-11-27 22:55:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T22:55:33Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6094101226 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#pullrequestreview-6094101226). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T22:55:33Z. **Review:** CHANGES_REQUESTED --- 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.
lambirou commented 2026-11-27 23:11:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T23:11:15Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229941858 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229941858). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T23:11:15Z. --- ## 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 commented 2026-11-27 23:11:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T23:11:21Z.


@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?

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229943192 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7229943192). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T23:11:21Z. --- @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 commented 2026-11-27 23:15:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T23:15:59Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7230005750 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7230005750). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T23:15:59Z. --- 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 commented 2026-11-27 23:16:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T23:16:13Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7230008878 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#issuecomment-7230008878). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-27T23:16:13Z. --- Windows checks #8462 completed successfully on `fd2f693e`. Debug and Release Opus/queue/audio tests are 4/4 with libopus 1.5.2 static.
R0Y00 commented 2026-11-27 23:35:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T23:35:59Z.

Review: APPROVED


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 #3222 merge adds only GPU fixture/docs changes and leaves the audio paths and tests identical. Hosted Windows passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6094311406 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3178#pullrequestreview-6094311406). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T23:35:59Z. **Review:** APPROVED --- 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 #3222 merge adds only GPU fixture/docs changes and leaves the audio paths and tests identical. Hosted Windows passed.
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!3178
No description provided.