From df80ad53430dbb068d47fdbe8d663115505cf1f6 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Fri, 27 Mar 2026 16:24:44 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20make=20cpal/ALSA=20optional=20=E2=80=94?= =?UTF-8?q?=20headless=20Linux=20builds=20work=20without=20libasound?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cpal is now behind an 'audio' feature flag (off by default) - --live mode requires --features audio at build time - --send-tone and --record work on headless servers without audio libs - Linux build script no longer installs libasound2-dev Build for headless: cargo build --release Build with mic/speakers: cargo build --release --features audio Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/wzp-client/Cargo.toml | 6 +++++- crates/wzp-client/src/cli.rs | 10 +++++++++- crates/wzp-client/src/lib.rs | 2 ++ scripts/build-linux.sh | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/wzp-client/Cargo.toml b/crates/wzp-client/Cargo.toml index e83df9a..8dbf803 100644 --- a/crates/wzp-client/Cargo.toml +++ b/crates/wzp-client/Cargo.toml @@ -18,7 +18,11 @@ tracing-subscriber = { workspace = true } async-trait = { workspace = true } bytes = { workspace = true } anyhow = "1" -cpal = "0.15" +cpal = { version = "0.15", optional = true } + +[features] +default = [] +audio = ["cpal"] [[bin]] name = "wzp-client" diff --git a/crates/wzp-client/src/cli.rs b/crates/wzp-client/src/cli.rs index 5930097..2cc2932 100644 --- a/crates/wzp-client/src/cli.rs +++ b/crates/wzp-client/src/cli.rs @@ -134,7 +134,14 @@ async fn main() -> anyhow::Result<()> { let transport = Arc::new(wzp_transport::QuinnTransport::new(connection)); if cli.live { - run_live(transport).await + #[cfg(feature = "audio")] + { + return run_live(transport).await; + } + #[cfg(not(feature = "audio"))] + { + anyhow::bail!("--live requires the 'audio' feature (build with: cargo build --features audio)"); + } } else if cli.send_tone_secs.is_some() || cli.record_file.is_some() { run_file_mode(transport, cli.send_tone_secs, cli.record_file).await } else { @@ -326,6 +333,7 @@ async fn run_file_mode( } /// Live mode: capture from mic, encode, send; receive, decode, play. +#[cfg(feature = "audio")] async fn run_live(transport: Arc) -> anyhow::Result<()> { use wzp_client::audio_io::{AudioCapture, AudioPlayback}; diff --git a/crates/wzp-client/src/lib.rs b/crates/wzp-client/src/lib.rs index 9a773d0..d5dd99b 100644 --- a/crates/wzp-client/src/lib.rs +++ b/crates/wzp-client/src/lib.rs @@ -6,11 +6,13 @@ //! //! Targets: Android (JNI), Windows desktop, macOS/Linux (testing) +#[cfg(feature = "audio")] pub mod audio_io; pub mod bench; pub mod call; pub mod handshake; +#[cfg(feature = "audio")] pub use audio_io::{AudioCapture, AudioPlayback}; pub use call::{CallConfig, CallDecoder, CallEncoder}; pub use handshake::perform_handshake; diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 89ba6ce..98d0664 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -11,7 +11,7 @@ set -euo pipefail SSH_KEY_NAME="wz" SSH_KEY_PATH="/Users/manwe/CascadeProjects/wzp" SERVER_NAME="wzp-builder-$(date +%s)" -SERVER_TYPE="cx23" +SERVER_TYPE="cx33" IMAGE="ubuntu-24.04" REMOTE_USER="root" OUTPUT_DIR="target/linux-x86_64" @@ -56,7 +56,7 @@ done # 3. Install build dependencies echo "[3/7] Installing build dependencies..." -$SSH "apt-get update -qq && apt-get install -y -qq build-essential cmake pkg-config libasound2-dev curl git > /dev/null 2>&1" +$SSH "apt-get update -qq && apt-get install -y -qq build-essential cmake pkg-config curl git > /dev/null 2>&1" # 4. Install Rust echo "[4/7] Installing Rust..."