pub struct CaptureHandle { /* private fields */ }Expand description
Handle for receiving AEC-processed audio samples. Capture stops automatically when dropped (channel disconnect stops backend).
Implementations§
Source§impl CaptureHandle
impl CaptureHandle
Sourcepub fn new(config: AecConfig) -> Result<Self, AecError>
pub fn new(config: AecConfig) -> Result<Self, AecError>
Create and start a new AEC capture stream. Audio samples are received via the async recv() or blocking recv_blocking() methods.
Sourcepub async fn recv(&self) -> Option<Result<Vec<f32>, AecError>>
pub async fn recv(&self) -> Option<Result<Vec<f32>, AecError>>
Receive audio samples asynchronously. Returns None when the capture stream is closed.
Sourcepub fn recv_blocking(&self) -> Option<Result<Vec<f32>, AecError>>
pub fn recv_blocking(&self) -> Option<Result<Vec<f32>, AecError>>
Receive audio samples, blocking the current thread. Returns None when the capture stream is closed.
Sourcepub fn try_recv(&self) -> Option<Result<Vec<f32>, AecError>>
pub fn try_recv(&self) -> Option<Result<Vec<f32>, AecError>>
Try to receive audio samples without blocking. Returns None if no samples are available or stream is closed.
Sourcepub fn native_sample_rate(&self) -> u32
pub fn native_sample_rate(&self) -> u32
Get the actual sample rate being used by the backend. May differ from requested rate if resampling is active.
Sourcepub fn play_audio(
&self,
samples: Vec<f32>,
sample_rate: u32,
) -> Result<(), AecError>
pub fn play_audio( &self, samples: Vec<f32>, sample_rate: u32, ) -> Result<(), AecError>
Play audio through the same engine used for capture. This enables AEC to cancel the played audio from the recording. Audio is played at the specified sample rate.
Sourcepub fn start_playback_stream(
&self,
sample_rate: u32,
) -> Result<PlaybackStreamHandle, AecError>
pub fn start_playback_stream( &self, sample_rate: u32, ) -> Result<PlaybackStreamHandle, AecError>
Start a streaming playback session. Returns a handle for sending audio chunks incrementally. The stream ends when the handle is dropped.