Skip to content

Add IAudioClient2/3 coverage and tighten wrapper guidance - #72

Merged
HEnquist merged 8 commits into
masterfrom
rel0.26
Oct 11, 2026
Merged

HEnquist merged 8 commits into
masterfrom
rel0.26

Conversation

@HEnquist

Copy link
Copy Markdown
Owner

Add IAudioClient2/3 device-backed coverage, tighten a few wrapper details, and document the repo's testing and docstring guidance.

  • add device-backed tests for the IAudioClient2 and IAudioClient3 wrapper methods
  • remove the deprecated methods and bump the crate version to 0.26.0
  • copy whole slices in the deque paths instead of byte-by-byte copies, and explain that change in the examples
  • update examples and wrapper docs around the newer behaviour
  • add AGENTS.md guidance for test scope, docstring style, and documenting strange WASAPI behaviour rather than trying to normalise it away

Covers the casts to the two interfaces, the order of their out parameters, the
WAVEFORMATEX parse that get_current_shared_mode_engine_period is the only caller
of, and the client fields that initialize_shared_audio_stream sets by hand.
Nothing asserts a period, a buffer limit or an offload answer, since those are
the engine's and the driver's to pick.
AudioClient::get_periods and AudioCaptureClient::get_next_nbr_frames were
renamed in 0.17.0, and AudioClient::set_audio_stream_category was superseded by
set_properties in 0.20.0. Use get_device_period, get_next_packet_size and
set_properties instead.

StreamCategory::ForegroundOnlyMedia stays, since that one is deprecated by
Windows rather than by this crate.
write_to_device_from_deque drained the deque with one pop_front per byte, and
read_from_device_to_deque filled it with one push_back per byte. Both now go
through at most two memcpy calls, using the deque's two contiguous runs.

A VecDeque holds its contents as one or two runs, so write_to_device_from_deque
copies run by run through a new copy_from_deque helper and then drains the front,
which only moves the head index. read_from_device_to_deque extends from the
buffer slice, which std specialises into a reserve and a copy for Copy types.

For an 8 channel stream at 192 kHz the old loops ran about six million calls per
second on the callback thread. The same pattern in the CamillaDSP CoreAudio
backend was profiled at around half the run time of the render callback, see
HEnquist/camilladsp#534.

The helper is pure, so it is unit tested directly, including a deque whose ring
wraps. That is the case the old loops could not get wrong and the bulk copies
can, and it is not reachable through the public API on a device test.
The loops that fill a chunk from the deque stay as they are, since copying the
two contiguous runs needs index arithmetic that would bury what the example is
there to show. They get a comment saying what it costs and what to do instead.

Two loops in the loopback example go the other way and get shorter, because the
bulk form is the simpler one to read: pushing a chunk onto the deque is extend,
and filling it with silence up to a target length is resize.

Background in HEnquist/camilladsp#534.
@HEnquist
HEnquist merged commit 7afc1c7 into master Oct 11, 2026
3 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.

1 participant