Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add IAudioClient2/3 device-backed coverage, tighten a few wrapper details, and document the repo's testing and docstring guidance.