use std::sync::mpsc::{Sender, Receiver}; use thiserror::Error; #[derive(Error, Debug)] pub enum AudioError { #[error("Failed to initialize audio backend: {0}")] Init(String), #[error("Audio device error: {0}")] Device(String), #[error("Stream error: {0}")] Stream(String), #[error("Audio buffer overflow/underflow")] BufferError, #[error("Other audio error: {0}")] Other(String), } pub trait AudioBackend: Send + Sync { /// Starts capturing raw PCM audio from the input device (microphone), /// sending chunks of samples (e.g. `Vec`) to the provided Sender. fn start_capture(&self, tx: Sender>, target_node: Option) -> Result<(), AudioError>; /// Starts playing back raw PCM audio to the output device (speaker), /// reading mixed/incoming chunks of samples from the provided Receiver. fn start_playback(&self, rx: Receiver>, target_node: Option) -> Result<(), AudioError>; /// Stops both capture and playback streams. fn stop(&self) -> Result<(), AudioError>; } pub mod pipewire_impl;