From c69195fe06d3061bb99df573cda7320fe71ff523 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Thu, 9 Apr 2026 14:56:02 +0400 Subject: [PATCH] step C(android): compile engine.rs on Android with a stub CallEngine::start Third incremental variable. Previously the engine module was cfg-gated out of the Android build entirely (`#[cfg(not(target_os = "android"))] mod engine;` in lib.rs). Now it's always compiled, so any link-time effect of having engine.rs in the compilation unit can be measured against the working baseline from build #19. Changes kept deliberately small: - lib.rs: drop the cfg gate on `mod engine;`. `use engine::CallEngine` stays gated because the Android-specific connect/disconnect/... stubs in lib.rs don't reference the type. - engine.rs: the `wzp_client::{audio_io, call}` imports + CodecId + QualityProfile are gated to non-Android (they require the `audio` feature on wzp-client which Android doesn't pull in). On Android we keep only the MediaTransport import for transport.close(). The impl block now has two `start()` methods: the full CPAL-backed one for desktop, and a 6-line Android stub that returns `Err("audio engine not yet wired on Android")` so attempts to `connect` from the UI fail cleanly. Goal: verify that linking in the compiled engine module (plus the types it references) on Android doesn't regress the working baseline. Home screen should still render and register_signal should still work. Co-Authored-By: Claude Opus 4.6 (1M context) --- desktop/src-tauri/src/engine.rs | 36 +++++++++++++++++++++++++++++++++ desktop/src-tauri/src/lib.rs | 8 +++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/desktop/src-tauri/src/engine.rs b/desktop/src-tauri/src/engine.rs index 4247238..6120d03 100644 --- a/desktop/src-tauri/src/engine.rs +++ b/desktop/src-tauri/src/engine.rs @@ -1,5 +1,12 @@ //! Call engine for the desktop app — wraps wzp-client audio + transport //! into a clean async interface for Tauri commands. +//! +//! Step C of the incremental Android rewrite: the module now compiles on +//! Android too (previously cfg-gated out entirely in lib.rs), but the +//! actual `CallEngine::start()` body uses CPAL via `wzp_client::audio_io` +//! which is only available on desktop. On Android we expose a stub +//! `start()` that returns an error, so the frontend's `connect` command +//! still fails cleanly but the rest of the engine code links in. use std::net::SocketAddr; use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}; @@ -7,12 +14,21 @@ use std::sync::Arc; use std::time::Instant; use tokio::sync::Mutex; +#[cfg(not(target_os = "android"))] use tracing::{error, info}; +#[cfg(not(target_os = "android"))] use wzp_client::audio_io::{AudioCapture, AudioPlayback}; +#[cfg(not(target_os = "android"))] use wzp_client::call::{CallConfig, CallEncoder}; +#[cfg(not(target_os = "android"))] use wzp_proto::{CodecId, MediaTransport, QualityProfile}; +// On Android we still need MediaTransport (for transport.close()) and nothing +// else from wzp_proto — this keeps the struct/stop()/status() code compiling. +#[cfg(target_os = "android")] +use wzp_proto::MediaTransport; + const FRAME_SAMPLES_40MS: usize = 1920; /// Resolve a quality string from the UI to a QualityProfile. @@ -80,6 +96,26 @@ pub struct CallEngine { } impl CallEngine { + /// Android stub — the real audio pipeline depends on wzp_client's + /// CPAL-backed audio_io module, which isn't available here. Returns an + /// error so the `connect` Tauri command fails cleanly. We'll replace + /// this in a later step with an Oboe-backed implementation. + #[cfg(target_os = "android")] + pub async fn start( + _relay: String, + _room: String, + _alias: String, + _os_aec: bool, + _quality: String, + _event_cb: F, + ) -> Result + where + F: Fn(&str, &str) + Send + Sync + 'static, + { + Err(anyhow::anyhow!("audio engine not yet wired on Android (step C)")) + } + + #[cfg(not(target_os = "android"))] pub async fn start( relay: String, room: String, diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index 71074cf..3125c25 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -6,11 +6,13 @@ windows_subsystem = "windows" )] -// CPAL-backed audio engine — desktop only. On Android we'll plug in an -// oboe/AAudio backend in a later step. -#[cfg(not(target_os = "android"))] +// Call engine — now compiled on every platform. On desktop it runs the real +// CPAL/VPIO audio pipeline; on Android `CallEngine::start()` currently returns +// an error stub (see engine.rs — that's step C of the Oboe integration). mod engine; +// CallEngine is only referenced from the non-Android connect/disconnect/etc +// commands; the Android stubs return errors directly. #[cfg(not(target_os = "android"))] use engine::CallEngine;