Update for winapi

This commit is contained in:
Pierre Krieger 2015-01-20 16:45:47 +01:00
parent b0eeb2e6b8
commit 284f12f1cb
2 changed files with 11 additions and 6 deletions

View File

@ -1,7 +1,7 @@
[package] [package]
name = "cpal" name = "cpal"
version = "0.0.9-pre" version = "0.0.10-pre"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"] authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Cross-platform audio playing library in pure Rust." description = "Cross-platform audio playing library in pure Rust."
repository = "https://github.com/tomaka/cpal" repository = "https://github.com/tomaka/cpal"
@ -11,11 +11,15 @@ keywords = ["audio", "sound"]
[target.i686-pc-windows-gnu.dependencies.winapi] [target.i686-pc-windows-gnu.dependencies.winapi]
version = "0" version = "0"
features = ["ole32"]
[target.x86_64-pc-windows-gnu.dependencies.winapi] [target.x86_64-pc-windows-gnu.dependencies.winapi]
version = "0" version = "0"
features = ["ole32"]
[target.i686-pc-windows-gnu.dependencies.ole32-sys]
version = "0"
[target.x86_64-pc-windows-gnu.dependencies.ole32-sys]
version = "0"
[target.i686-unknown-linux-gnu.dependencies.alsa-sys] [target.i686-unknown-linux-gnu.dependencies.alsa-sys]
version = "0" version = "0"

View File

@ -1,5 +1,6 @@
extern crate libc; extern crate libc;
extern crate winapi; extern crate winapi;
extern crate "ole32-sys" as ole32;
use std::{slice, mem, ptr}; use std::{slice, mem, ptr};
@ -156,13 +157,13 @@ impl<'a, T> Buffer<'a, T> {
fn init() -> Result<Voice, String> { fn init() -> Result<Voice, String> {
// FIXME: release everything // FIXME: release everything
unsafe { unsafe {
try!(check_result(winapi::CoInitializeEx(::std::ptr::null_mut(), 0))); try!(check_result(ole32::CoInitializeEx(::std::ptr::null_mut(), 0)));
// building the devices enumerator object // building the devices enumerator object
let enumerator = { let enumerator = {
let mut enumerator: *mut winapi::IMMDeviceEnumerator = ::std::mem::uninitialized(); let mut enumerator: *mut winapi::IMMDeviceEnumerator = ::std::mem::uninitialized();
let hresult = winapi::CoCreateInstance(&winapi::CLSID_MMDeviceEnumerator, let hresult = ole32::CoCreateInstance(&winapi::CLSID_MMDeviceEnumerator,
ptr::null_mut(), winapi::CLSCTX_ALL, ptr::null_mut(), winapi::CLSCTX_ALL,
&winapi::IID_IMMDeviceEnumerator, &winapi::IID_IMMDeviceEnumerator,
mem::transmute(&mut enumerator)); mem::transmute(&mut enumerator));
@ -221,7 +222,7 @@ fn init() -> Result<Voice, String> {
0, 10000000, 0, format, ptr::null()); 0, 10000000, 0, format, ptr::null());
if !format_ptr.is_null() { if !format_ptr.is_null() {
winapi::CoTaskMemFree(format_ptr as *mut libc::c_void); ole32::CoTaskMemFree(format_ptr as *mut libc::c_void);
} }
try!(check_result(hresult)); try!(check_result(hresult));