Skip to content

Commit

Permalink
Replace assert in WASAPI check with bubble'd error (RustAudio#797)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ryanmcgrath committed Aug 31, 2023
1 parent f063271 commit f51589c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/host/wasapi/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit f51589c

Please sign in to comment.