Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

ALSA backend with pipwire-alsa buffer length mismatch causing xruns

Aperta
#1,390 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start with the linked reproduction repository’s README and the CPAL ALSA backend’s buffer size handling; reproduce the reported xrun with the beep example and PipeWire quantum set to 2048. Compare default and explicit buffer sizes against the observations in the issue. Done when the backend avoids the reported underruns in the described setup or documents a clear supported workaround.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

host - alsa platform - linux

Repro repo with a detailed README: https://github.com/karolinepauls/cpal-alsa-buffer-repro

Problem: The existing "beep" example can produce a choppy sound when run over pipewire-alsa, and so can any other code that leaves the buffer size setting default. I've reproduced it with kira (which uses CPAL with ALSA) as well as my private sound engine using CPAL's ALSA backend. In all those cases, I've had constant underruns producing audio glitches.

I believe this is ultimately a pipewire-alsa problem. Still CPAL needs to help users avoid it. Could we

A) somehow read the actual buffer size used by the device and use that?
B) or at least suggest against using BufferSize::Default and set it to e.g.:

    let buffer_size = if let &SupportedBufferSize::Range { min, max } = default_config.buffer_size()
    {
        2048.clamp(min, max)
    } else {
        2048
    };

Abbreviated repro

  1. Start pw-top in background to monitor the quanta.

  2. Lock device quantum, as if another running application caused the quantum to be set (e.g. Firefox playing a video).

pw-metadata -n settings 0 clock.force-quantum 2048
  1. Run, requesting default buffer size:
cargo run

Result: running with a buffer size of 512, choppy sound.

  1. Run, requesting an explicit buffer size of 512:
cargo run -- --buffer-size 512

Same effect.

  1. Run, requesting a buffer size of at least 1024:
cargo run -- --buffer-size 1024

Result: clean sine.

  1. Run with a buffer size of 512 but also ensure that pipewire runs with it.
pw-metadata -n settings 0 clock.force-quantum 512
cargo run -- --buffer-size 512

Result: clean sine.

Observations

For some reason an app buffer size of 512 doesn't work with a device buffer size of 2048. At least with pipewire-alsa.

app device result
512 512 ok
default 2048 xrun
512 2048 xrun
1024 2048 ok
2048 2048 ok

Versions

pipewire:

Compiled with libpipewire 1.6.2
Linked with libpipewire 1.6.2

Kubuntu 26.04.1 LTS

CPAL: git 79275c2313da30e9f8b1ad8168385d091a2c9ada (current master).

Lingua principale
Rust
Stelle
4k
Fork
554
Merge medio
2g 11h
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RustAudio/cpal

Tutte le issue di RustAudio/cpal

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.