⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

AudioDevice

Trait AudioDevice 

Source
pub trait AudioDevice {
    // Required methods
    fn configure(
        &mut self,
        config: &AudioConfig,
    ) -> Result<AudioConfig, AudioError>;
    fn start(&mut self) -> Result<(), AudioError>;
    fn stop(&mut self) -> Result<(), AudioError>;
    fn write_frames(&mut self, data: &[u8]) -> Result<usize, AudioError>;
    fn read_frames(&mut self, output: &mut [u8]) -> Result<usize, AudioError>;
    fn capabilities(&self) -> &AudioDeviceCapabilities;
    fn name(&self) -> &str;
    fn is_playback(&self) -> bool;
    fn is_capture(&self) -> bool;
}
Expand description

Unified audio device trait for playback and capture backends

Provides a common interface across ALSA PCM devices, VirtIO Sound streams, USB Audio Class devices, and any future audio backends. Implementations adapt existing backend-specific APIs to this shared contract.

Required Methods§

Source

fn configure(&mut self, config: &AudioConfig) -> Result<AudioConfig, AudioError>

Configure the device with desired parameters.

The device may adjust parameters to the nearest supported values. Returns the actual configuration that was applied.

Source

fn start(&mut self) -> Result<(), AudioError>

Start playback or capture.

Source

fn stop(&mut self) -> Result<(), AudioError>

Stop playback or capture.

Source

fn write_frames(&mut self, data: &[u8]) -> Result<usize, AudioError>

Write PCM samples for playback.

Returns the number of frames written. The data must be interleaved samples in the format specified by the current configuration.

Source

fn read_frames(&mut self, output: &mut [u8]) -> Result<usize, AudioError>

Read PCM samples from capture.

Returns the number of frames read. The output buffer is filled with interleaved samples in the format specified by the current configuration.

Source

fn capabilities(&self) -> &AudioDeviceCapabilities

Query device capabilities.

Source

fn name(&self) -> &str

Human-readable device name.

Source

fn is_playback(&self) -> bool

Returns true if this device supports playback.

Source

fn is_capture(&self) -> bool

Returns true if this device supports capture.

Implementors§