Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
run: nix-shell --arg withRust true --run 'cargo fmt --check'
- name: Clippy
run: nix-shell --arg withRust true --run 'cargo clippy --all-targets --locked -- -D warnings'
# Without PulseAudio, as static (musl) builds link voxl.
- name: Clippy (no PulseAudio)
run: nix-shell --arg withRust true --run 'cargo clippy --all-targets --locked --no-default-features -- -D warnings'
# Unit tests, including the Linux-only ones (dynamic resolution).
- name: Test
run: nix-shell --arg withRust true --run 'cargo test --locked'
Expand Down
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ path = "src/lib.rs"
name = "voxl"
path = "src/main.rs"

[features]
default = ["pulseaudio"]
# Desktop audio on Linux, from PulseAudio. Without it voxl links no PulseAudio, so it can
# be built static (musl) and runs without its libraries, but has no desktop audio on
# Linux. macOS and Windows don't use it.
pulseaudio = []

[dependencies]
tokio = { version = "1", features = [
"rt-multi-thread",
Expand Down Expand Up @@ -90,7 +97,6 @@ x11rb = { version = "0.13", features = [
"shape",
"xinput",
"randr",
"allow-unsafe-code",
] }

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ nix-shell
cargo build --release
```

On Linux, `--no-default-features` leaves out PulseAudio, and with it desktop audio: a
voxl that can be linked statically (musl) and runs without PulseAudio's libraries.

Or install it from [crates.io](https://crates.io/crates/voxl-server) with the same
libraries on your system (the crate is `voxl-server`, the binary is `voxl`):

Expand Down
7 changes: 5 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");
}

/// x264, libyuv, Opus and PulseAudio from pkg-config; returns x264's include paths.
/// x264, libyuv, Opus and PulseAudio (with the pulseaudio feature) from pkg-config;
/// returns x264's include paths.
fn unix_libs(target: &str) -> Vec<std::path::PathBuf> {
let x264 = pkg_config::probe_library("x264").expect("x264");
// macOS captures NV12 (no libyuv) and gets audio from ScreenCaptureKit (no PulseAudio).
let libs: &[&str] = if target == "macos" {
&["opus"]
} else {
} else if std::env::var_os("CARGO_FEATURE_PULSEAUDIO").is_some() {
&["libyuv", "opus", "libpulse-simple"]
} else {
&["libyuv", "opus"]
};
let others: Vec<_> = libs
.iter()
Expand Down
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! `tembo voxl`) embed the server the same way.

mod access;
#[cfg(target_os = "linux")]
#[cfg(all(target_os = "linux", feature = "pulseaudio"))]
mod audio;
#[cfg(target_os = "linux")]
mod capture;
Expand Down Expand Up @@ -182,6 +182,11 @@ async fn serve(a: HashMap<String, String>) {
to_client: matches!(clip, "true" | "out"),
};
let audio_on = truthy(a.get("audio-enabled"), true);
#[cfg(all(target_os = "linux", not(feature = "pulseaudio")))]
let audio_on = audio_on && {
log::info!("desktop audio off: this voxl was built without PulseAudio");
false
};

let hub = hub::Hub::new();
// --read-only: the viewer watches the desktop, it does not drive it. Only the
Expand Down Expand Up @@ -255,6 +260,7 @@ async fn serve(a: HashMap<String, String>) {
Ok(tx) => *hub.input.lock() = Some(tx),
Err(e) => log::error!("input init failed: {e}"),
}
#[cfg(any(not(target_os = "linux"), feature = "pulseaudio"))]
if audio_on {
let dev = a
.get("audio-device-name")
Expand Down
Loading