Skip to content

fix(asio): share duplex buffer state across Device handles for the same driver - #1297

Open
roderickvd wants to merge 4 commits into
masterfrom
fix/asio-duplex-buffer-reuse
Open

fix(asio): share duplex buffer state across Device handles for the same driver#1297
roderickvd wants to merge 4 commits into
masterfrom
fix/asio-duplex-buffer-reuse

Conversation

@roderickvd

Copy link
Copy Markdown
Member

default_input_device() and default_output_device() each enumerate a fresh Device with its own empty AsioStreams, even when they resolve to the same loaded driver. This broke the reuse path in get_or_create_input_stream / get_or_create_output_stream: building both directions triggered a second, destructive ASIOCreateBuffers call that silently discarded the first direction's buffers instead of combining them into one call as designed.

This PR moves the AsioStreams bookkeeping onto DriverInner, alongside DriverState, so every Driver handle for the same loaded driver shares it.

Fixes #1287

…me driver

default_input_device() and default_output_device() each enumerate a fresh
Device with its own empty AsioStreams, even when they resolve to the same
loaded driver. This broke the reuse path in get_or_create_input_stream /
get_or_create_output_stream: building both directions triggered a second,
destructive ASIOCreateBuffers call that silently discarded the first
direction's buffers instead of combining them into one call as designed.

Move the AsioStreams bookkeeping onto DriverInner, alongside DriverState,
so every Driver handle for the same loaded driver shares it.

Fixes #1287

@1rhino2 1rhino2 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

code review (no ASIO hardware here so this is static only). cargo check --all-targets green on the PR branch under the default windows host.

the root cause story matches the code: get_or_create_input_stream / get_or_create_output_stream only combine via prepare_*_stream when the other direction already lives in the same AsioStreams mutex. on master, default_input_device() and default_output_device() each mint a Device with its own empty Arc, so the second build can't see the first and ASIOCreateBuffers runs again. moving streams onto DriverInner so every Driver/Device for that loaded driver shares one Arc looks like the right fix.

feedback.rs --asio flag + sample-format dispatch is a nice independent improvement for repros.

one note from #1287: after clarifying build order, the reporter said they saw no perceived difference between master and this branch. that doesn't kill the change for me (order sensitivity on master is itself a smell for the discarded-buffers failure mode), but it'd be good to get one more clean A/B with the RMS harness (input-first and output-first) logged on both tips before merge. i don't have an ASIO interface to run that myself yet.

happy to help chase any leftover edge cases if someone can share a failing recipe that still repros on this branch.

@1rhino2 1rhino2 mentioned this pull request Aug 2, 2026
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: ASIO modified feedback example no mic input

2 participants