Skip to content

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

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
lambirou:codex/opus-completion-count
Nov 27, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
lambirou:codex/opus-completion-count

Conversation

@lambirou

@lambirou lambirou commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

Windows checks #8436 completed successfully on b1dd0bd7.

@lambirou

Copy link
Copy Markdown
Contributor Author

@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 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@lambirou

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

@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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@R0Y00
R0Y00 merged commit 58e3183 into R0Y00:main Nov 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants