commit
b1216f5e12
|
@ -93,7 +93,7 @@ fn new_voice() -> Result<Voice, String> {
|
||||||
let (samples_sender, samples_receiver) = channel();
|
let (samples_sender, samples_receiver) = channel();
|
||||||
|
|
||||||
let audio_unit_result = AudioUnit::new(Type::Output, SubType::HalOutput)
|
let audio_unit_result = AudioUnit::new(Type::Output, SubType::HalOutput)
|
||||||
.render_callback(box move |channels, num_frames| {
|
.render_callback(Box::new(move |channels, num_frames| {
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ fn new_voice() -> Result<Voice, String> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
})
|
}))
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
match audio_unit_result {
|
match audio_unit_result {
|
||||||
|
@ -130,4 +130,3 @@ fn new_voice() -> Result<Voice, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ a conversion on your data.
|
||||||
If you have the possibility, you should try to match the format of the voice.
|
If you have the possibility, you should try to match the format of the voice.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub use samples_formats::{SampleFormat, Sample};
|
pub use samples_formats::{SampleFormat, Sample};
|
||||||
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
@ -87,7 +88,7 @@ pub struct Voice(cpal_impl::Voice);
|
||||||
/// Number of channels.
|
/// Number of channels.
|
||||||
pub type ChannelsCount = u16;
|
pub type ChannelsCount = u16;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct SamplesRate(pub u32);
|
pub struct SamplesRate(pub u32);
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ pub struct SamplesRate(pub u32);
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct Buffer<'a, T: 'a> where T: Sample {
|
pub struct Buffer<'a, T: 'a> where T: Sample {
|
||||||
// also contains something, taken by `Drop`
|
// also contains something, taken by `Drop`
|
||||||
target: Option<cpal_impl::Buffer<'a, T>>,
|
target: Option<cpal_impl::Buffer<'a, T>>,
|
||||||
|
|
||||||
// if this is non-none, then the data will be written to `conversion.intermediate_buffer`
|
// if this is non-none, then the data will be written to `conversion.intermediate_buffer`
|
||||||
// instead of `target`, and the conversion will be done in buffer's destructor
|
// instead of `target`, and the conversion will be done in buffer's destructor
|
||||||
|
@ -215,7 +216,7 @@ impl Voice {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Buffer {
|
Buffer {
|
||||||
target: Some(self.0.append_data(max_elements)),
|
target: Some(self.0.append_data(max_elements)),
|
||||||
conversion: None,
|
conversion: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue