Skip to content

Instantly share code, notes, and snippets.

@m-hilgendorf
Last active May 29, 2019 00:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-hilgendorf/3cb26792575a1a8a72893f922c15cd72 to your computer and use it in GitHub Desktop.
Save m-hilgendorf/3cb26792575a1a8a72893f922c15cd72 to your computer and use it in GitHub Desktop.
draft of audio HAL API
pub struct DeviceInfo {
id : i32,
name : [u8; 64],
num_input_channels : usize,
num_output_channels : usize,
}
pub trait Stream {
fn start(self, sample_rate : usize, buffer_size : usize) -> Self;
fn stop(self) -> Self;
}
struct StreamParameters {
pub num_ins : usize,
pub num_outs : usize,
pub sample_rate : usize,
pub buffer_size : usize,
}
pub trait Device {
type SampleRateIter : Iterator<usize>;
type BufferSizeIter : Iterator<usize>;
type DeviceInfoIter : Iterator<DeviceInfo>;
type StreamHandle : Stream;
fn devices() -> Self::DeviceInfoIter;
fn sample_rates(d : &DeviceInfo) -> Self::SampleRateIter;
fn buffer_sizes(d : &DeviceInfo) -> Self::DeviceInfoIter;
fn default_input() -> &DeviceInfo;
fn default_output() ->&DeviceInfo;
fn open_input_stream (
params : StreamParameters,
input : Option<DeviceInfo>,
output : Option<DeviceInfo>,
callback : CbkFn) -> (Self::StreamHandle, StreamParameters);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment