finished implementing buffersizes for coreaudio

This commit is contained in:
JoshuaBatty 2020-05-22 14:03:28 +02:00
parent 9e660da433
commit 4cd9d0bcec
2 changed files with 52 additions and 22 deletions

View file

@ -4,9 +4,9 @@ extern crate cpal;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
fn main() -> Result<(), anyhow::Error> {
//let host = cpal::default_host();
let host =
cpal::host_from_id(cpal::platform::HostId::Asio).expect("failed to initialise ASIO host");
let host = cpal::default_host();
//let host =
// cpal::host_from_id(cpal::platform::HostId::Asio).expect("failed to initialise ASIO host");
let device = host
.default_output_device()
.expect("failed to find a default output device");
@ -26,7 +26,7 @@ where
T: cpal::Sample,
{
let mut config: cpal::StreamConfig = config.clone();
config.buffer_size = cpal::BufferSize::Fixed(256);
config.buffer_size = cpal::BufferSize::Fixed(16);
let sample_rate = config.sample_rate.0 as f32;
let channels = config.channels as usize;
@ -43,6 +43,7 @@ where
let stream = device.build_output_stream(
&config,
move |data: &mut [T], _: &cpal::OutputCallbackInfo| {
println!("data len = {}", data.len());
write_data(data, channels, &mut next_value)
},
err_fn,