[feat](trx-core): add AudioSource trait and RigCat::as_audio_source
Add AudioSource trait to trx-core rig module providing subscribe_pcm() for demodulated PCM audio. Add opt-in as_audio_source() default method to RigCat returning None; SDR backends will override to return Some(self). Re-export AudioSource from the crate root. Marks SDR-01 complete. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -10,6 +10,7 @@ pub mod rig;
|
||||
|
||||
pub type DynResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||
|
||||
pub use rig::AudioSource;
|
||||
pub use rig::command::RigCommand;
|
||||
pub use rig::request::RigRequest;
|
||||
pub use rig::response::{RigError, RigResult};
|
||||
|
||||
@@ -57,6 +57,13 @@ fn default_min_freq_step_hz() -> u64 {
|
||||
1
|
||||
}
|
||||
|
||||
/// Trait for rigs that can provide demodulated PCM audio.
|
||||
pub trait AudioSource: Send + Sync {
|
||||
/// Subscribe to demodulated PCM audio from the primary channel.
|
||||
/// Returns a broadcast receiver that yields 20ms frames of mono f32 PCM.
|
||||
fn subscribe_pcm(&self) -> tokio::sync::broadcast::Receiver<Vec<f32>>;
|
||||
}
|
||||
|
||||
/// Common interface for rig backends.
|
||||
pub trait Rig {
|
||||
fn info(&self) -> &RigInfo;
|
||||
@@ -103,6 +110,8 @@ pub trait RigCat: Rig + Send {
|
||||
fn lock<'a>(&'a mut self) -> Pin<Box<dyn Future<Output = DynResult<()>> + Send + 'a>>;
|
||||
|
||||
fn unlock<'a>(&'a mut self) -> Pin<Box<dyn Future<Output = DynResult<()>> + Send + 'a>>;
|
||||
|
||||
fn as_audio_source(&self) -> Option<&dyn AudioSource> { None }
|
||||
}
|
||||
|
||||
/// Snapshot of a rig's status that every backend can expose.
|
||||
|
||||
Reference in New Issue
Block a user