Fix compilation on OSX with the new API for coreaudio-rs
this builds upon the following pull request: https://github.com/tomaka/cpal/pull/81
This commit is contained in:
parent
30e96aa15a
commit
dd87dbc1d2
|
@ -21,7 +21,7 @@ pub use self::enumerate::{EndpointsIterator,
|
||||||
SupportedFormatsIterator,
|
SupportedFormatsIterator,
|
||||||
get_default_endpoint};
|
get_default_endpoint};
|
||||||
|
|
||||||
use self::coreaudio::audio_unit::{AudioUnit, Type, SubType};
|
use self::coreaudio::audio_unit::{AudioUnit, IOType};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
pub struct Endpoint;
|
pub struct Endpoint;
|
||||||
|
@ -98,8 +98,10 @@ impl Voice {
|
||||||
let underflow = Arc::new(Mutex::new(RefCell::new(false)));
|
let underflow = Arc::new(Mutex::new(RefCell::new(false)));
|
||||||
let uf_clone = underflow.clone();
|
let uf_clone = underflow.clone();
|
||||||
|
|
||||||
let audio_unit_result = AudioUnit::new(Type::Output, SubType::HalOutput)
|
let audio_unit_result = AudioUnit::new(IOType::HalOutput);
|
||||||
.render_callback(Box::new(move |channels, num_frames| {
|
|
||||||
|
if let Ok(mut audio_unit) = audio_unit_result {
|
||||||
|
if let Ok(()) = audio_unit.set_render_callback(Some(Box::new(move |channels: &mut[&mut[f32]], num_frames: NumFrames| {
|
||||||
if let Err(_) = ready_sender.send((channels.len(), num_frames)) {
|
if let Err(_) = ready_sender.send((channels.len(), num_frames)) {
|
||||||
return Err("Callback failed to send 'ready' message.".to_string());
|
return Err("Callback failed to send 'ready' message.".to_string());
|
||||||
}
|
}
|
||||||
|
@ -120,22 +122,21 @@ impl Voice {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
}))
|
}))) {
|
||||||
.start();
|
if let Ok(()) = audio_unit.start() {
|
||||||
|
return Ok(Voice {
|
||||||
match audio_unit_result {
|
|
||||||
Ok(audio_unit) => Ok(Voice {
|
|
||||||
audio_unit: audio_unit,
|
audio_unit: audio_unit,
|
||||||
ready_receiver: ready_receiver,
|
ready_receiver: ready_receiver,
|
||||||
samples_sender: samples_sender,
|
samples_sender: samples_sender,
|
||||||
underflow: underflow,
|
underflow: underflow,
|
||||||
last_ready: Arc::new(Mutex::new(RefCell::new(None)))
|
last_ready: Arc::new(Mutex::new(RefCell::new(None)))
|
||||||
}),
|
})
|
||||||
Err(_) => {
|
|
||||||
Err(CreationError::DeviceNotAvailable)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(CreationError::DeviceNotAvailable)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn append_data<'a, T>(&'a mut self, max_elements: usize) -> Buffer<'a, T> where T: Clone {
|
pub fn append_data<'a, T>(&'a mut self, max_elements: usize) -> Buffer<'a, T> where T: Clone {
|
||||||
// Block until the audio callback is ready for more data.
|
// Block until the audio callback is ready for more data.
|
||||||
|
|
Loading…
Reference in New Issue