fn check_config(
    driver: &sys::Driver,
    config: &StreamConfig,
    sample_format: SampleFormat,
    num_asio_channels: u16,
) -> Result<(), BuildStreamError> {
    let StreamConfig {
        channels,
        sample_rate,
        buffer_size,
    } = config;
    // Try and set the sample rate to what the user selected.
    let sample_rate = sample_rate.0.into();
    if sample_rate != driver.sample_rate().map_err(build_stream_err)? {
        if driver
            .can_sample_rate(sample_rate)
            .map_err(build_stream_err)?
        {
            driver
                .set_sample_rate(sample_rate)
                .map_err(build_stream_err)?;
        } else {
            return Err(BuildStreamError::StreamConfigNotSupported);
        }
    }
    // unsigned formats are not supported by asio
    match sample_format {
        SampleFormat::I16 | SampleFormat::F32 => (),
        SampleFormat::U16 => return Err(BuildStreamError::StreamConfigNotSupported),
    }
    if *channels > num_asio_channels {
        return Err(BuildStreamError::StreamConfigNotSupported);
    }
    Ok(())
}
/// Check whether or not the desired config is supported by the stream.
///
/// Checks sample rate, data type and then finally the number of channels.
Check whether or not the desired config is supported by the stream.
Checks sample rate, data type and then finally the number of channels.
Check whether or not the desired config is supported by the stream . Checks sample rate data type and then finally the number of channels .
fn check_config(
    driver: &sys::Driver,
    config: &StreamConfig,
    sample_format: SampleFormat,
    num_asio_channels: u16,
) -> Result<(), BuildStreamError> {
    let StreamConfig {
        channels,
        sample_rate,
        buffer_size,
    } = config;
    // Try and set the sample rate to what the user selected.
    let sample_rate = sample_rate.0.into();
    if sample_rate != driver.sample_rate().map_err(build_stream_err)? {
        if driver
            .can_sample_rate(sample_rate)
            .map_err(build_stream_err)?
        {
            driver
                .set_sample_rate(sample_rate)
                .map_err(build_stream_err)?;
        } else {
            return Err(BuildStreamError::StreamConfigNotSupported);
        }
    }
    // unsigned formats are not supported by asio
    match sample_format {
        SampleFormat::I16 | SampleFormat::F32 => (),
        SampleFormat::U16 => return Err(BuildStreamError::StreamConfigNotSupported),
    }
    if *channels > num_asio_channels {
        return Err(BuildStreamError::StreamConfigNotSupported);
    }
    Ok(())
}
fn check_config ( driver : & sys :: Driver , config : & StreamConfig , sample_format : SampleFormat , num_asio_channels : u16 , ) -> Result < ( ) , BuildStreamError > { let StreamConfig { channels , sample_rate , buffer_size , } = config ; // Try and set the sample rate to what the user selected. let sample_rate = sample_rate . 0 . into ( ) ; if sample_rate != driver . sample_rate ( ) . map_err ( build_stream_err ) ? { if driver . can_sample_rate ( sample_rate ) . map_err ( build_stream_err ) ? { driver . set_sample_rate ( sample_rate ) . map_err ( build_stream_err ) ? ; } else { return Err ( BuildStreamError :: StreamConfigNotSupported ) ; } } // unsigned formats are not supported by asio match sample_format { SampleFormat :: I16 | SampleFormat :: F32 => ( ) , SampleFormat :: U16 => return Err ( BuildStreamError :: StreamConfigNotSupported ) , } if * channels > num_asio_channels { return Err ( BuildStreamError :: StreamConfigNotSupported ) ; } Ok ( ( ) ) }
Check whether or not the desired config is supported by the stream.
Check whether or not the desired config is supported by the stream .
driver
&sys::Driver
config
&StreamConfig
sample_format
SampleFormat
num_asio_channels
u16
driver
&sys::Driver
config
&StreamConfig
sample_format
SampleFormat
num_asio_channels
u16