step C(android): compile engine.rs on Android with a stub CallEngine::start
Some checks failed
Mirror to GitHub / mirror (push) Failing after 36s
Build Release Binaries / build-amd64 (push) Has been cancelled

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) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-04-09 14:56:02 +04:00
parent ae4f366b05
commit c69195fe06
2 changed files with 41 additions and 3 deletions

View File

@@ -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<F>(
_relay: String,
_room: String,
_alias: String,
_os_aec: bool,
_quality: String,
_event_cb: F,
) -> Result<Self, anyhow::Error>
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<F>(
relay: String,
room: String,

View File

@@ -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;