fix(asio): share duplex buffer state across Device handles for the same driver - #1297
fix(asio): share duplex buffer state across Device handles for the same driver#1297roderickvd wants to merge 4 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
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.
default_input_device()anddefault_output_device()each enumerate a freshDevicewith its own emptyAsioStreams, even when they resolve to the same loaded driver. This broke the reuse path inget_or_create_input_stream/get_or_create_output_stream: building both directions triggered a second, destructiveASIOCreateBufferscall that silently discarded the first direction's buffers instead of combining them into one call as designed.This PR moves the
AsioStreamsbookkeeping ontoDriverInner, alongsideDriverState, so everyDriverhandle for the same loaded driver shares it.Fixes #1287