diff --git a/Cargo.toml b/Cargo.toml index 181f821..c6387b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cpal" -version = "0.4.0" +version = "0.4.1" authors = ["The CPAL contributors", "Pierre Krieger "] description = "Low-level cross-platform audio playing library in pure Rust." repository = "https://github.com/tomaka/cpal" diff --git a/src/wasapi/mod.rs b/src/wasapi/mod.rs index 2dd85f4..d6138d1 100644 --- a/src/wasapi/mod.rs +++ b/src/wasapi/mod.rs @@ -185,10 +185,23 @@ impl Endpoint { channels }; - let format = match (*format_ptr).SubFormat { - winapi::KSDATAFORMAT_SUBTYPE_IEEE_FLOAT => SampleFormat::F32, - winapi::KSDATAFORMAT_SUBTYPE_PCM => SampleFormat::I16, - g => panic!("Unknown SubFormat GUID returned by GetMixFormat: {:?}", g) + let format = { + fn cmp_guid(a: &winapi::GUID, b: &winapi::GUID) -> bool { + a.Data1 == b.Data1 && a.Data2 == b.Data2 && + a.Data3 == b.Data3 && a.Data4 == b.Data4 + } + if cmp_guid(&(*format_ptr).SubFormat, + &winapi::KSDATAFORMAT_SUBTYPE_IEEE_FLOAT) + { + SampleFormat::F32 + } else if cmp_guid(&(*format_ptr).SubFormat, + &winapi::KSDATAFORMAT_SUBTYPE_PCM) + { + SampleFormat::I16 + } else { + panic!("Unknown SubFormat GUID returned by GetMixFormat: {:?}", + (*format_ptr).SubFormat) + } }; (channels, format)