Load libasound at runtime, or make the ALSA host optional, so Linux binaries don't require libasound
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 14/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- linux, rust
- Ambito
- build-system
Direzione di ricerca
Start with the ALSA host's is_available(), which currently returns a hardcoded true, and the Host::new(), default_host() and available_hosts() paths that depend on it. The alsa-sys dependency and its pkg-config link are where the runtime-loading option would go. The issue asks for a maintainer decision between two designs (dlopen in alsa-sys, or a default-on alsa feature), so it is not ready for a patch yet. Done would be an agreed design plus a build with no libasound in NEEDED.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
On Linux and the BSDs, cpal always depends on alsa, and alsa-sys links libasound through pkg-config. So every binary that uses cpal has libasound.so.2 in NEEDED, and that has two costs:
- At run time, the binary won't start without libasound (
error while loading shared libraries: libasound.so.2), even when audio is an optional part of a larger program and the host never touches a device: a headless server, a minimal container, a CI runner. - At build time, every build needs the ALSA headers and pkg-config (
libasound2-dev), includingcargo installon a machine that only wants the non-audio parts. This also gets in the way of cross and static builds (see #982 and diwic/alsa-sys#10).
The ALSA host's is_available() is the natural place to report this, but today it returns a hardcoded true.
Proposal
Either of these would solve it. The first is preferred, because it keeps raw ALSA on hosts without a sound server.
- Load libasound at runtime (dlopen). An opt-in feature in which the ALSA host resolves the
snd_*symbols fromlibasound.so.2on first use.is_available()returnsfalsewhen the library is missing,Host::new()returnsHostUnavailable, anddefault_host()/available_hosts()fall through. The loading would most naturally live inalsa-sysbehind a feature (bindgen can generate a dynamic-loading wrapper), and cpal would forward it. The build then needs no ALSA headers or pkg-config either. This is how other audio stacks handle it: SDL (SDL_AUDIO_DRIVER_ALSA_DYNAMIC), miniaudio (runtime linking by default), and Firefox's cubeb all dlopen libasound. - Make the ALSA host optional on Linux. A default-on
alsafeature, so a build withdefault-features = false, features = ["pulseaudio"]uses only the PulseAudio host. That host is built on the pure-Rustpulseaudioprotocol crate, so the build needs no system audio library at all. The cost is that hosts without a sound server have no devices. This is close to thealsafeature being considered for FreeBSD in #1404 (also mentioned in #988 and asked about in #929), extended to Linux.
Use case
moq ships moq-cli, a tool for publishing and playing live media, as prebuilt binaries and through cargo install. Microphone capture and speaker playback go through cpal (0.18.2). On Linux, cpal is the one dependency that links a system library at load time: camera capture needs none, and our hardware video codecs (VA-API, NVENC) already dlopen theirs. So capture and playback are off by default today. Turning them on would make every Linux user install libasound2-dev to cargo install, and the same binary that runs on a desktop wouldn't start on a server or in a container without ALSA, even when it's only publishing a file. We'd like to ship one Linux binary that uses ALSA (or PulseAudio) where it exists and reports no audio host where it doesn't.
(Written by Opus 5.5)
- Lingua principale
- Rust
- Stelle
- 4k
- Fork
- 554
- Merge medio
- 3g 3h
- PR unite (30g)
- 4
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RustAudio/cpal
-
aaudio: dynamic buffer tuning never grows the buffer (set_buffer_size_in_frames reports Err on success)Forse già presa @dannyward630 l’ha presa 9 giorni fa. Apertahost - aaudio platform - android
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
WebAudio wasm build fails with wasm-bindgen panic=unwind closuresForse già presa @bogusyogi l’ha presa 17 giorni fa. Apertahost - webaudio platform - web
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
RustAudio/cpal#1394 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Don't emit `fmt::Error`ApertaAPI design correctness
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
RustAudio/cpal#1419 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
New WASAPI implementationForse già presa @LastExceed l’ha presa 1 giorno fa. Apertacode quality dependencies host - wasapi platform - windows
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
RustAudio/cpal#1416 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
host - pipewire platform - linux
Difficoltà 4/5 1-2 giorni Idoneità per principianti 52/100
RustAudio/cpal#1405 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di RustAudio/cpal
Issue simili
-
Perl - Readme DriftForse già presa @Omnideth l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
CommunityToolkit/Aspire#2375 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno