Merge pull request #139 from tomaka/win-fix

Fix compilation on windows
This commit is contained in:
tomaka 2016-11-16 08:26:48 +01:00 committed by GitHub
commit 871352ce60
2 changed files with 18 additions and 5 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "cpal" name = "cpal"
version = "0.4.0" version = "0.4.1"
authors = ["The CPAL contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"] authors = ["The CPAL contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Low-level cross-platform audio playing library in pure Rust." description = "Low-level cross-platform audio playing library in pure Rust."
repository = "https://github.com/tomaka/cpal" repository = "https://github.com/tomaka/cpal"

View File

@ -185,10 +185,23 @@ impl Endpoint {
channels channels
}; };
let format = match (*format_ptr).SubFormat { let format = {
winapi::KSDATAFORMAT_SUBTYPE_IEEE_FLOAT => SampleFormat::F32, fn cmp_guid(a: &winapi::GUID, b: &winapi::GUID) -> bool {
winapi::KSDATAFORMAT_SUBTYPE_PCM => SampleFormat::I16, a.Data1 == b.Data1 && a.Data2 == b.Data2 &&
g => panic!("Unknown SubFormat GUID returned by GetMixFormat: {:?}", g) 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) (channels, format)