Skip to content

[Feature] First-class PulseAudio/PipeWire audio backend #148

Description

@lqdev

Summary

Add first-class PulseAudio and PipeWire support as an optional audio backend, beyond the default ALSA compatibility layer that rodio uses.

Related: #131 (Meta-Epic: Cross-Platform Audio Playback)

Problem / Background

The MVP uses rodio's default ALSA backend on Linux. While PipeWire and PulseAudio provide ALSA compatibility layers that usually work, some configurations may have issues:

  • Containers and WSL2 environments
  • Custom PipeWire configurations that don't expose ALSA compat
  • Audio routing through PulseAudio-only sinks

Users hitting these edge cases currently fall back to the external player backend, which loses fine-grained control.

Proposed Solution

1. Cargo Feature Flags

[features]
default = []
pulseaudio = ["cpal/jack"]  # or appropriate cpal feature

2. Backend Auto-Detection

fn detect_linux_audio_backend() -> AudioBackendType {
    // Check for PipeWire first (modern default)
    if std::process::Command::new("pw-cli").arg("info").output().is_ok() {
        return AudioBackendType::PipeWire;
    }
    // Check for PulseAudio
    if std::process::Command::new("pactl").arg("info").output().is_ok() {
        return AudioBackendType::PulseAudio;
    }
    // Fall back to ALSA
    AudioBackendType::Alsa
}

3. Build Dependencies

# PulseAudio development libraries
sudo apt-get install libpulse-dev

# PipeWire development libraries (usually provides PulseAudio compat)
sudo apt-get install libpipewire-0.3-dev

Files to Modify

File Change
Cargo.toml Add optional pulseaudio feature with cpal backend flag
src/audio/mod.rs Add backend detection logic
scripts/install-build-deps.sh Add optional PulseAudio dev package
.github/workflows/release.yml Test with PulseAudio in CI (optional)
GETTING_STARTED.md Document PulseAudio build option

Acceptance Criteria

  • cargo build --features pulseaudio builds with PulseAudio support
  • Auto-detection chooses correct backend based on available audio server
  • Default build (no features) still works with ALSA only
  • CI tests both ALSA and PulseAudio builds
  • Documentation explains when and how to enable PulseAudio support

Implementation Notes

  • cpal's PulseAudio support may require the jack or specific host features — check cpal docs
  • PipeWire typically provides PulseAudio API compat, so PulseAudio support often covers PipeWire too
  • This is a build-time choice, not runtime — feature flags control which cpal backend is compiled in
  • Consider adding a config.audio.backend field: "auto", "alsa", "pulseaudio"

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priorityaudioAudio playback componentenhancementNew feature or request

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions