ableos_userland/libraries/audio_interface/src/lib.rs

39 lines
897 B
Rust

pub struct AudioObject {
// Play one bit per this interval
playback_speed: u64,
playback_ring: [u8; 2048],
paused: bool,
}
impl AudioInterface for AudioObject {
fn pause(&mut self) -> Result<(), AudioErrors> {
self.paused = true;
Ok(())
}
fn play() -> Result<(), AudioErrors> {
todo!()
}
fn stop() -> Result<(), AudioErrors> {
todo!()
}
fn fill_playback_buffer(&mut self, playback_slice: [u8; 128]) -> Result<(), AudioErrors> {
todo!()
}
}
pub enum AudioErrors {
EmptyPlaybackBuffer,
}
pub trait AudioInterface {
fn pause(&mut self) -> Result<(), AudioErrors>;
fn play() -> Result<(), AudioErrors>;
// Stop will clear the buffer and stop playback
fn stop() -> Result<(), AudioErrors>;
fn fill_playback_buffer(&mut self, playback_slice: [u8; 128]) -> Result<(), AudioErrors>;
}