Skip to content

Commit 089d117

Browse files
committed
fix(examples): make duplex_feedback macOS-only
Duplex streams are currently only implemented for CoreAudio. Add platform guards so the example compiles cleanly on other platforms with a helpful message about platform support status.
1 parent 0d4e6bd commit 089d117

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

examples/duplex_feedback.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//!
33
//! Unlike the `feedback.rs` example which uses separate input/output streams with a ring buffer,
44
//! duplex streams provide hardware-synchronized input/output without additional buffering.
5+
//!
6+
//! Note: Currently only supported on macOS (CoreAudio). Windows (WASAPI) and Linux (ALSA)
7+
//! implementations are planned.
58
69
use clap::Parser;
710
use cpal::duplex::DuplexStreamConfig;
@@ -46,6 +49,7 @@ struct Opt {
4649
jack: bool,
4750
}
4851

52+
#[cfg(target_os = "macos")]
4953
fn main() -> anyhow::Result<()> {
5054
let opt = Opt::parse();
5155

@@ -132,3 +136,9 @@ fn main() -> anyhow::Result<()> {
132136
println!("Done!");
133137
Ok(())
134138
}
139+
140+
#[cfg(not(target_os = "macos"))]
141+
fn main() {
142+
eprintln!("Duplex streams are currently only supported on macOS.");
143+
eprintln!("Windows (WASAPI) and Linux (ALSA) support is planned.");
144+
}

0 commit comments

Comments
 (0)