Skip to main content

sim_lib_stream_host/placement/
audio.rs

1//! Audio placement site keys, cards, and requests.
2
3use sim_kernel::Symbol;
4
5/// Stable runtime key for an audio evaluation site.
6///
7/// The key is plain data so device catalogs can store and compare audio sites
8/// without carrying platform handles.
9#[derive(Clone, Debug, PartialEq, Eq, Hash)]
10pub struct AudioSiteKey(pub Symbol);
11
12impl AudioSiteKey {
13    /// Builds an audio site key from a stable symbolic name.
14    pub fn new(name: &str) -> Self {
15        Self(Symbol::new(name))
16    }
17}
18
19/// Export-record-style descriptor for an audio device.
20///
21/// The card carries only stable metadata and never owns platform handles.
22#[derive(Clone, Debug, PartialEq, Eq)]
23pub struct AudioDeviceCard {
24    /// Stable site key used for registration and lookup.
25    pub key: AudioSiteKey,
26    /// Human-facing device name.
27    pub display_name: String,
28    /// Number of output channels supported by this site.
29    pub channels_out: u16,
30    /// Number of input channels supported by this site.
31    pub channels_in: u16,
32    /// Advertised sample rates in hertz.
33    pub sample_rates: Vec<u32>,
34    /// Whether opening this site requires real host hardware.
35    pub hardware_required: bool,
36}
37
38impl AudioDeviceCard {
39    /// Builds a deterministic modeled stereo device card for validation.
40    pub fn modeled(key: AudioSiteKey, name: impl Into<String>) -> Self {
41        Self {
42            key,
43            display_name: name.into(),
44            channels_out: 2,
45            channels_in: 2,
46            sample_rates: vec![44_100, 48_000],
47            hardware_required: false,
48        }
49    }
50}
51
52/// Caller-side request to place an audio graph on a registered audio site.
53#[derive(Clone, Debug, PartialEq, Eq)]
54pub struct AudioPlacementRequest {
55    /// Target site key selected by placement.
56    pub site_key: AudioSiteKey,
57    /// Host stream request forwarded to the selected backend.
58    pub stream_request: crate::HostStreamConfigRequest,
59}