};
use crate::{
- error::M17Error,
+ error::{M17Error, SoundmodemError},
soundmodem::{InputSource, OutputBuffer, OutputSink, SoundmodemEvent},
};
continue;
};
if configs
- .find(|config| {
- config.channels() == 1 && config.sample_format() == SampleFormat::I16
- })
- .is_some()
+ .any(|config| config.channels() == 1 && config.sample_format() == SampleFormat::I16)
{
let Ok(name) = d.name() else {
continue;
continue;
};
if configs
- .find(|config| {
- config.channels() == 1 && config.sample_format() == SampleFormat::I16
- })
- .is_some()
+ .any(|config| config.channels() == 1 && config.sample_format() == SampleFormat::I16)
{
let Ok(name) = d.name() else {
continue;
}
impl InputSource for SoundcardInputSource {
- fn start(&self, samples: SyncSender<SoundmodemEvent>) {
- let _ = self.event_tx.send(SoundcardEvent::StartInput { samples });
+ fn start(&self, samples: SyncSender<SoundmodemEvent>) -> Result<(), SoundmodemError> {
+ Ok(self.event_tx.send(SoundcardEvent::StartInput { samples })?)
}
- fn close(&self) {
- let _ = self.event_tx.send(SoundcardEvent::CloseInput);
+ fn close(&self) -> Result<(), SoundmodemError> {
+ Ok(self.event_tx.send(SoundcardEvent::CloseInput)?)
}
}
}
impl OutputSink for SoundcardOutputSink {
- fn start(&self, event_tx: SyncSender<SoundmodemEvent>, buffer: Arc<RwLock<OutputBuffer>>) {
- let _ = self
+ fn start(
+ &self,
+ event_tx: SyncSender<SoundmodemEvent>,
+ buffer: Arc<RwLock<OutputBuffer>>,
+ ) -> Result<(), SoundmodemError> {
+ Ok(self
.event_tx
- .send(SoundcardEvent::StartOutput { event_tx, buffer });
+ .send(SoundcardEvent::StartOutput { event_tx, buffer })?)
}
- fn close(&self) {
- let _ = self.event_tx.send(SoundcardEvent::CloseOutput);
+ fn close(&self) -> Result<(), SoundmodemError> {
+ Ok(self.event_tx.send(SoundcardEvent::CloseOutput)?)
}
}