diff --git a/src/error.rs b/src/error.rs index 90b6dbb..f404f29 100644 --- a/src/error.rs +++ b/src/error.rs @@ -90,9 +90,9 @@ pub enum BuildStreamError { /// program is running. #[error("The requested device is no longer available. For example, it has been unplugged.")] DeviceNotAvailable, - /// The required format is not supported. - #[error("The requested stream format is not supported by the device.")] - FormatNotSupported, + /// The specified stream configuration is not supported. + #[error("The requested stream configuration is not supported by the device.")] + StreamConfigNotSupported, /// We called something the C-Layer did not understand /// /// On ALSA device functions called with a feature they do not support will yield this. E.g. diff --git a/src/host/asio/stream.rs b/src/host/asio/stream.rs index 7d339c1..42ff8ac 100644 --- a/src/host/asio/stream.rs +++ b/src/host/asio/stream.rs @@ -71,9 +71,9 @@ impl Device { // Ensure that the desired sample type is supported. let sample_format = super::device::convert_data_type(&stream_type) - .ok_or(BuildStreamError::FormatNotSupported)?; + .ok_or(BuildStreamError::StreamConfigNotSupported)?; if config.sample_format != sample_format { - return Err(BuildStreamError::FormatNotSupported); + return Err(BuildStreamError::StreamConfigNotSupported); } let num_channels = config.channels.clone(); @@ -237,9 +237,9 @@ impl Device { // Ensure that the desired sample type is supported. let sample_format = super::device::convert_data_type(&stream_type) - .ok_or(BuildStreamError::FormatNotSupported)?; + .ok_or(BuildStreamError::StreamConfigNotSupported)?; if config.sample_format != sample_format { - return Err(BuildStreamError::FormatNotSupported); + return Err(BuildStreamError::StreamConfigNotSupported); } let num_channels = config.channels.clone(); @@ -445,7 +445,7 @@ impl Device { let num_asio_channels = f.channels; check_config(&self.driver, config, num_asio_channels) } - Err(_) => Err(BuildStreamError::FormatNotSupported), + Err(_) => Err(BuildStreamError::StreamConfigNotSupported), }?; let num_channels = config.channels as usize; let ref mut streams = *self.asio_streams.lock(); @@ -485,7 +485,7 @@ impl Device { let num_asio_channels = f.channels; check_config(&self.driver, config, num_asio_channels) } - Err(_) => Err(BuildStreamError::FormatNotSupported), + Err(_) => Err(BuildStreamError::StreamConfigNotSupported), }?; let num_channels = config.channels as usize; let ref mut streams = *self.asio_streams.lock(); @@ -600,16 +600,16 @@ fn check_config( .set_sample_rate(sample_rate) .map_err(build_stream_err)?; } else { - return Err(BuildStreamError::FormatNotSupported); + return Err(BuildStreamError::StreamConfigNotSupported); } } // unsigned formats are not supported by asio match sample_format { SampleFormat::I16 | SampleFormat::F32 => (), - SampleFormat::U16 => return Err(BuildStreamError::FormatNotSupported), + SampleFormat::U16 => return Err(BuildStreamError::StreamConfigNotSupported), } if *channels > num_asio_channels { - return Err(BuildStreamError::FormatNotSupported); + return Err(BuildStreamError::StreamConfigNotSupported); } Ok(()) } diff --git a/src/host/coreaudio/mod.rs b/src/host/coreaudio/mod.rs index 2d4dee2..61800e4 100644 --- a/src/host/coreaudio/mod.rs +++ b/src/host/coreaudio/mod.rs @@ -395,7 +395,7 @@ impl From for BuildStreamError { | coreaudio::Error::NoKnownSubtype | coreaudio::Error::AudioUnit(coreaudio::error::AudioUnitError::FormatNotSupported) | coreaudio::Error::AudioCodec(_) - | coreaudio::Error::AudioFormat(_) => BuildStreamError::FormatNotSupported, + | coreaudio::Error::AudioFormat(_) => BuildStreamError::StreamConfigNotSupported, _ => BuildStreamError::DeviceNotAvailable, } } @@ -541,7 +541,7 @@ impl Device { r.mMinimum as u32 == sample_rate && r.mMaximum as u32 == sample_rate }); let range_index = match maybe_index { - None => return Err(BuildStreamError::FormatNotSupported), + None => return Err(BuildStreamError::StreamConfigNotSupported), Some(i) => i, }; diff --git a/src/host/wasapi/device.rs b/src/host/wasapi/device.rs index 65d6263..8d7ed34 100644 --- a/src/host/wasapi/device.rs +++ b/src/host/wasapi/device.rs @@ -242,7 +242,7 @@ pub unsafe fn is_format_supported( }, (winerror::S_FALSE, _) => { (*audio_client).Release(); - return Err(BuildStreamError::FormatNotSupported); + return Err(BuildStreamError::StreamConfigNotSupported); }, (_, Ok(())) => (), }; @@ -639,12 +639,12 @@ impl Device { // Computing the format and initializing the device. let waveformatex = { let format_attempt = format_to_waveformatextensible(format) - .ok_or(BuildStreamError::FormatNotSupported)?; + .ok_or(BuildStreamError::StreamConfigNotSupported)?; let share_mode = AUDCLNT_SHAREMODE_SHARED; // Ensure the format is supported. match super::device::is_format_supported(audio_client, &format_attempt.Format) { - Ok(false) => return Err(BuildStreamError::FormatNotSupported), + Ok(false) => return Err(BuildStreamError::StreamConfigNotSupported), Err(_) => return Err(BuildStreamError::DeviceNotAvailable), _ => (), } @@ -783,12 +783,12 @@ impl Device { // Computing the format and initializing the device. let waveformatex = { let format_attempt = format_to_waveformatextensible(format) - .ok_or(BuildStreamError::FormatNotSupported)?; + .ok_or(BuildStreamError::StreamConfigNotSupported)?; let share_mode = AUDCLNT_SHAREMODE_SHARED; // Ensure the format is supported. match super::device::is_format_supported(audio_client, &format_attempt.Format) { - Ok(false) => return Err(BuildStreamError::FormatNotSupported), + Ok(false) => return Err(BuildStreamError::StreamConfigNotSupported), Err(_) => return Err(BuildStreamError::DeviceNotAvailable), _ => (), }