cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Feature Request: read default buffer size from `Stream`, and/or query device's preferred buffer size

Open j-n-f opened this issue 11 months ago • 1 comments

With ASIO the driver will report a preferred buffer size, and I'm guessing this is what gets used when the default buffer size is chosen. It'd be nice to know what this value is before starting a stream.

Alternatively, one can use BufferSize::Fixed, but would need a way to query what that preferred buffer size is for some Host and Device.

Something like:

enum PreferredBufferSize {
    /// Device doesn't provide this information
    Unknown,
    /// Device can provide this information
    Fixed(usize),
}

let preferred_input_size = device.preferred_input_buffer_size();

j-n-f avatar Jan 25 '25 22:01 j-n-f

Small correction: it seems like the "default" buffer size is just whatever buffer size the device is already set to. This may be device/driver specific behaviour.

What I'm looking for is the buffer size the device reports as optimal, where the driver doesn't have to split/combine blocks (i.e. usually the same as the device's internal buffer size).

j-n-f avatar Feb 01 '25 05:02 j-n-f

Querying stream buffer sizes I'd like to consolidate to issue #1042.

What I'm looking for is the buffer size the device reports as optimal, where the driver doesn't have to split/combine blocks (i.e. usually the same as the device's internal buffer size).

Best take would the device default buffer size. In v0.17 I overhauled the buffer size system to move from cpal defaults to real device defaults. So when you use BufferSize::Default, you get that "device's internal buffer size" you speak of.

roderickvd avatar Dec 10 '25 20:12 roderickvd

PR up at #1080 for reading default buffer size from Stream.

roderickvd avatar Dec 23 '25 20:12 roderickvd