cpal/src/wasapi/mod.rs

42 lines
854 B
Rust
Raw Normal View History

2014-12-11 14:22:55 +01:00
extern crate libc;
extern crate winapi;
2015-03-30 11:06:46 +02:00
extern crate ole32;
2014-12-11 14:22:55 +01:00
use std::io::Error as IoError;
2014-12-11 14:22:55 +01:00
pub use self::enumerate::{EndpointsIterator, get_default_endpoint};
pub use self::voice::{Voice, Buffer};
2014-12-11 17:23:33 +01:00
mod com;
mod enumerate;
mod voice;
2014-12-11 17:23:33 +01:00
/// An opaque type that identifies an end point.
#[derive(PartialEq, Eq)]
#[allow(raw_pointer_derive)]
pub struct Endpoint(*mut winapi::IMMDevice);
2014-12-11 17:23:33 +01:00
unsafe impl Send for Endpoint {}
unsafe impl Sync for Endpoint {}
2014-12-11 19:07:58 +01:00
impl Clone for Endpoint {
fn clone(&self) -> Endpoint {
unsafe { (*self.0).AddRef(); }
Endpoint(self.0)
2014-12-22 14:16:47 +01:00
}
2014-12-11 17:23:33 +01:00
}
impl Drop for Endpoint {
2014-12-11 19:42:04 +01:00
fn drop(&mut self) {
unsafe { (*self.0).Release(); }
2014-12-11 19:42:04 +01:00
}
}
fn check_result(result: winapi::HRESULT) -> Result<(), IoError> {
2014-12-11 16:28:26 +01:00
if result < 0 {
Err(IoError::from_raw_os_error(result))
} else {
Ok(())
2014-12-11 16:28:26 +01:00
}
2014-12-11 14:22:55 +01:00
}