From 61ac0528e7f4d838b60b952edcf1058e226306a3 Mon Sep 17 00:00:00 2001 From: Peter Atashian Date: Thu, 17 Sep 2015 14:22:36 -0400 Subject: [PATCH] Update winapi dependency Signed-off-by: Peter Atashian --- Cargo.toml | 2 +- src/wasapi/mod.rs | 56 +++++++++++++++------------------------------ src/wasapi/voice.rs | 36 ++++++++++++++--------------- 3 files changed, 37 insertions(+), 57 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dfed4c9..e9fa5a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["audio", "sound"] [dependencies] libc = "*" lazy_static = "0.1" -winapi = "0.2.3" +winapi = "0.2.4" ole32-sys = "0.1" [target.i686-unknown-linux-gnu.dependencies.alsa-sys] diff --git a/src/wasapi/mod.rs b/src/wasapi/mod.rs index 4394d76..4d5ae68 100644 --- a/src/wasapi/mod.rs +++ b/src/wasapi/mod.rs @@ -18,26 +18,6 @@ pub use self::voice::{Voice, Buffer}; pub type SupportedFormatsIterator = OptionIntoIter; -// TODO: these constants should be moved to winapi -const SPEAKER_FRONT_LEFT: winapi::DWORD = 0x1; -const SPEAKER_FRONT_RIGHT: winapi::DWORD = 0x2; -const SPEAKER_FRONT_CENTER: winapi::DWORD = 0x4; -const SPEAKER_LOW_FREQUENCY: winapi::DWORD = 0x8; -const SPEAKER_BACK_LEFT: winapi::DWORD = 0x10; -const SPEAKER_BACK_RIGHT: winapi::DWORD = 0x20; -const SPEAKER_FRONT_LEFT_OF_CENTER: winapi::DWORD = 0x40; -const SPEAKER_FRONT_RIGHT_OF_CENTER: winapi::DWORD = 0x80; -const SPEAKER_BACK_CENTER: winapi::DWORD = 0x100; -const SPEAKER_SIDE_LEFT: winapi::DWORD = 0x200; -const SPEAKER_SIDE_RIGHT: winapi::DWORD = 0x400; -const SPEAKER_TOP_CENTER: winapi::DWORD = 0x800; -const SPEAKER_TOP_FRONT_LEFT: winapi::DWORD = 0x1000; -const SPEAKER_TOP_FRONT_CENTER: winapi::DWORD = 0x2000; -const SPEAKER_TOP_FRONT_RIGHT: winapi::DWORD = 0x4000; -const SPEAKER_TOP_BACK_LEFT: winapi::DWORD = 0x8000; -const SPEAKER_TOP_BACK_CENTER: winapi::DWORD = 0x10000; -const SPEAKER_TOP_BACK_RIGHT: winapi::DWORD = 0x20000; - mod com; mod enumerate; mod voice; @@ -153,24 +133,24 @@ impl Endpoint { let mut channels = Vec::new(); let mask = (*format_ptr).dwChannelMask; - if (mask & SPEAKER_FRONT_LEFT) != 0 { channels.push(ChannelPosition::FrontLeft); } - if (mask & SPEAKER_FRONT_RIGHT) != 0 { channels.push(ChannelPosition::FrontRight); } - if (mask & SPEAKER_FRONT_CENTER) != 0 { channels.push(ChannelPosition::FrontCenter); } - if (mask & SPEAKER_LOW_FREQUENCY) != 0 { channels.push(ChannelPosition::LowFrequency); } - if (mask & SPEAKER_BACK_LEFT) != 0 { channels.push(ChannelPosition::BackLeft); } - if (mask & SPEAKER_BACK_RIGHT) != 0 { channels.push(ChannelPosition::BackRight); } - if (mask & SPEAKER_FRONT_LEFT_OF_CENTER) != 0 { channels.push(ChannelPosition::FrontLeftOfCenter); } - if (mask & SPEAKER_FRONT_RIGHT_OF_CENTER) != 0 { channels.push(ChannelPosition::FrontRightOfCenter); } - if (mask & SPEAKER_BACK_CENTER) != 0 { channels.push(ChannelPosition::BackCenter); } - if (mask & SPEAKER_SIDE_LEFT) != 0 { channels.push(ChannelPosition::SideLeft); } - if (mask & SPEAKER_SIDE_RIGHT) != 0 { channels.push(ChannelPosition::SideRight); } - if (mask & SPEAKER_TOP_CENTER) != 0 { channels.push(ChannelPosition::TopCenter); } - if (mask & SPEAKER_TOP_FRONT_LEFT) != 0 { channels.push(ChannelPosition::TopFrontLeft); } - if (mask & SPEAKER_TOP_FRONT_CENTER) != 0 { channels.push(ChannelPosition::TopFrontCenter); } - if (mask & SPEAKER_TOP_FRONT_RIGHT) != 0 { channels.push(ChannelPosition::TopFrontRight); } - if (mask & SPEAKER_TOP_BACK_LEFT) != 0 { channels.push(ChannelPosition::TopBackLeft); } - if (mask & SPEAKER_TOP_BACK_CENTER) != 0 { channels.push(ChannelPosition::TopBackCenter); } - if (mask & SPEAKER_TOP_BACK_RIGHT) != 0 { channels.push(ChannelPosition::TopBackRight); } + if (mask & winapi::SPEAKER_FRONT_LEFT) != 0 { channels.push(ChannelPosition::FrontLeft); } + if (mask & winapi::SPEAKER_FRONT_RIGHT) != 0 { channels.push(ChannelPosition::FrontRight); } + if (mask & winapi::SPEAKER_FRONT_CENTER) != 0 { channels.push(ChannelPosition::FrontCenter); } + if (mask & winapi::SPEAKER_LOW_FREQUENCY) != 0 { channels.push(ChannelPosition::LowFrequency); } + if (mask & winapi::SPEAKER_BACK_LEFT) != 0 { channels.push(ChannelPosition::BackLeft); } + if (mask & winapi::SPEAKER_BACK_RIGHT) != 0 { channels.push(ChannelPosition::BackRight); } + if (mask & winapi::SPEAKER_FRONT_LEFT_OF_CENTER) != 0 { channels.push(ChannelPosition::FrontLeftOfCenter); } + if (mask & winapi::SPEAKER_FRONT_RIGHT_OF_CENTER) != 0 { channels.push(ChannelPosition::FrontRightOfCenter); } + if (mask & winapi::SPEAKER_BACK_CENTER) != 0 { channels.push(ChannelPosition::BackCenter); } + if (mask & winapi::SPEAKER_SIDE_LEFT) != 0 { channels.push(ChannelPosition::SideLeft); } + if (mask & winapi::SPEAKER_SIDE_RIGHT) != 0 { channels.push(ChannelPosition::SideRight); } + if (mask & winapi::SPEAKER_TOP_CENTER) != 0 { channels.push(ChannelPosition::TopCenter); } + if (mask & winapi::SPEAKER_TOP_FRONT_LEFT) != 0 { channels.push(ChannelPosition::TopFrontLeft); } + if (mask & winapi::SPEAKER_TOP_FRONT_CENTER) != 0 { channels.push(ChannelPosition::TopFrontCenter); } + if (mask & winapi::SPEAKER_TOP_FRONT_RIGHT) != 0 { channels.push(ChannelPosition::TopFrontRight); } + if (mask & winapi::SPEAKER_TOP_BACK_LEFT) != 0 { channels.push(ChannelPosition::TopBackLeft); } + if (mask & winapi::SPEAKER_TOP_BACK_CENTER) != 0 { channels.push(ChannelPosition::TopBackCenter); } + if (mask & winapi::SPEAKER_TOP_BACK_RIGHT) != 0 { channels.push(ChannelPosition::TopBackRight); } assert_eq!((*format_ptr).Format.nChannels as usize, channels.len()); channels diff --git a/src/wasapi/voice.rs b/src/wasapi/voice.rs index 9e0b065..7b9f205 100644 --- a/src/wasapi/voice.rs +++ b/src/wasapi/voice.rs @@ -73,24 +73,24 @@ impl Voice { let mut mask = 0; for &channel in format.channels.iter() { let raw_value = match channel { - ChannelPosition::FrontLeft => super::SPEAKER_FRONT_LEFT, - ChannelPosition::FrontRight => super::SPEAKER_FRONT_RIGHT, - ChannelPosition::FrontCenter => super::SPEAKER_FRONT_CENTER, - ChannelPosition::LowFrequency => super::SPEAKER_LOW_FREQUENCY, - ChannelPosition::BackLeft => super::SPEAKER_BACK_LEFT, - ChannelPosition::BackRight => super::SPEAKER_BACK_RIGHT, - ChannelPosition::FrontLeftOfCenter => super::SPEAKER_FRONT_LEFT_OF_CENTER, - ChannelPosition::FrontRightOfCenter => super::SPEAKER_FRONT_RIGHT_OF_CENTER, - ChannelPosition::BackCenter => super::SPEAKER_BACK_CENTER, - ChannelPosition::SideLeft => super::SPEAKER_SIDE_LEFT, - ChannelPosition::SideRight => super::SPEAKER_SIDE_RIGHT, - ChannelPosition::TopCenter => super::SPEAKER_TOP_CENTER, - ChannelPosition::TopFrontLeft => super::SPEAKER_TOP_FRONT_LEFT, - ChannelPosition::TopFrontCenter => super::SPEAKER_TOP_FRONT_CENTER, - ChannelPosition::TopFrontRight => super::SPEAKER_TOP_FRONT_RIGHT, - ChannelPosition::TopBackLeft => super::SPEAKER_TOP_BACK_LEFT, - ChannelPosition::TopBackCenter => super::SPEAKER_TOP_BACK_CENTER, - ChannelPosition::TopBackRight => super::SPEAKER_TOP_BACK_RIGHT, + ChannelPosition::FrontLeft => winapi::SPEAKER_FRONT_LEFT, + ChannelPosition::FrontRight => winapi::SPEAKER_FRONT_RIGHT, + ChannelPosition::FrontCenter => winapi::SPEAKER_FRONT_CENTER, + ChannelPosition::LowFrequency => winapi::SPEAKER_LOW_FREQUENCY, + ChannelPosition::BackLeft => winapi::SPEAKER_BACK_LEFT, + ChannelPosition::BackRight => winapi::SPEAKER_BACK_RIGHT, + ChannelPosition::FrontLeftOfCenter => winapi::SPEAKER_FRONT_LEFT_OF_CENTER, + ChannelPosition::FrontRightOfCenter => winapi::SPEAKER_FRONT_RIGHT_OF_CENTER, + ChannelPosition::BackCenter => winapi::SPEAKER_BACK_CENTER, + ChannelPosition::SideLeft => winapi::SPEAKER_SIDE_LEFT, + ChannelPosition::SideRight => winapi::SPEAKER_SIDE_RIGHT, + ChannelPosition::TopCenter => winapi::SPEAKER_TOP_CENTER, + ChannelPosition::TopFrontLeft => winapi::SPEAKER_TOP_FRONT_LEFT, + ChannelPosition::TopFrontCenter => winapi::SPEAKER_TOP_FRONT_CENTER, + ChannelPosition::TopFrontRight => winapi::SPEAKER_TOP_FRONT_RIGHT, + ChannelPosition::TopBackLeft => winapi::SPEAKER_TOP_BACK_LEFT, + ChannelPosition::TopBackCenter => winapi::SPEAKER_TOP_BACK_CENTER, + ChannelPosition::TopBackRight => winapi::SPEAKER_TOP_BACK_RIGHT, }; // channels must be in the right order