Allow querying the buffer size of a Stream
On Android, amongst other platforms, when using the default buffer size the platform sets the buffer size, this would be useful to query at runtime.
Context on PR - https://github.com/RustAudio/cpal/pull/1039
Agreed. #964 did some work on that. Maybe we could have both: buffer size and latency, if supported. I was thinking to work on this onto v0.18 (with v0.17 currently in release cycle). Happy to receive contributions.
I wonder whether the default buffer size could be put in Device::default_{input, output}_config, like the device's preferred sample rate already is? Currently it returns a (fairly useless, on pipewire-alsa at least) SupportedStreamConfig, in the sense that the buffer size it provides is just a range from 1 to 4194304.
Most hosts that cross my mind actually don't have a way of returning their default buffer size. You may only query it after you've created a stream.
Most hosts that cross my mind actually don't have a way of returning their default buffer size. You may only query it after you've created a stream.
After some more investigation, I believe that CoreAudio, AAudio and JACK could return a default buffer size before trying to initialize a stream. ALSA & WASAPI can't. ASIO maybe. 3 or 4 out of 6... that's right on the edge of whether it's cross-platform yes/no.
I'll be pushing a PR soon to address this issue of querying the buffer size of a stream. With a bit of a workaround that'd enable a user to try and recreate a stream, if the results of BufferSize::Default aren't to his or her liking. If in the future the need for querying ahead of stream creation still comes up, we can consider.
PR up at #1080