#![no_std]
#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]
#[cfg(all(feature = "coreaudio", target_os = "macos"))]
extern crate std;
#[cfg(all(feature = "coreaudio", target_os = "macos"))]
pub mod coreaudio;
#[cfg(feature = "fm1")]
pub mod fm1;
pub const FRAMES: usize = 128;
pub type Block = [[i32; 2]; FRAMES];
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Direction {
Input,
Output,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Endpoint<Id, Name> {
pub id: Id,
pub name: Name,
pub direction: Direction,
pub channels: u16,
pub rate: (u32, u32),
}
pub trait DeviceHost {
type Id: Copy + Eq;
type Name: AsRef<str>;
type Devices: AsRef<[Endpoint<Self::Id, Self::Name>]>;
type Error;
fn devices(&self) -> Result<Self::Devices, Self::Error>;
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Submission {
Written,
Late,
WouldBlock,
}
pub trait Playback {
type Error;
type Timing;
fn render(
&mut self,
render: impl FnOnce(&mut Block, Self::Timing),
) -> Result<Submission, Self::Error>;
}
pub trait Capture {
type Error;
fn read(&mut self, out: &mut Block) -> Result<bool, Self::Error>;
}