Replace assert in WASAPI check with bubble'd error (#797)

Replace assert in WASAPI WAVEFORMTEX supported format check with bubbled error message.

For our use case, this stops a crash that pops up for some users who encounter this path and allows us to gracefully just not play audio and log a message elsewhere.
This commit is contained in:
Ryan McGrath
2023-08-31 16:57:39 -07:00
committed by GitHub
parent f063271c23
commit f51589c552

View File

@@ -441,7 +441,12 @@ impl Device {
.map_err(windows_err_to_cpal_err::<SupportedStreamConfigsError>)?;
// If the default format can't succeed we have no hope of finding other formats.
assert!(is_format_supported(client, default_waveformatex_ptr.0)?);
if !is_format_supported(client, default_waveformatex_ptr.0)? {
let description =
"Could not determine support for default `WAVEFORMATEX`".to_string();
let err = BackendSpecificError { description };
return Err(err.into());
}
// Copy the format to use as a test format (as to avoid mutating the original format).
let mut test_format = {