Skip to content

fix(linux): enable PulseAudio/PipeWire system audio capture#309

Open
thalesac wants to merge 1 commit intoZackriya-Solutions:mainfrom
thalesac:fix/linux-pulseaudio-system-audio
Open

fix(linux): enable PulseAudio/PipeWire system audio capture#309
thalesac wants to merge 1 commit intoZackriya-Solutions:mainfrom
thalesac:fix/linux-pulseaudio-system-audio

Conversation

@thalesac
Copy link

Summary

  • Fix Linux system audio capture by properly enumerating PulseAudio/PipeWire monitor sources
  • Previously, only microphone audio was captured on Linux because cpal's ALSA backend doesn't see PulseAudio monitor sources

Changes

  • linux.rs: Enumerate monitor sources via pactl list sources short command instead of relying on cpal's ALSA backend
  • configuration.rs: Use PULSE_SOURCE env var with 'pulse' ALSA device for capturing from PulseAudio sources
  • speakers.rs: Add default_system_audio_device() for Linux that finds the best available monitor source
  • recording_manager.rs: Use Linux-specific system audio device selection

How it works

  1. Query pactl for .monitor sources (system audio capture points)
  2. Set PULSE_SOURCE environment variable to the selected monitor
  3. Use the pulse ALSA device which routes through PulseAudio
  4. Fall back to ALSA loopback devices if pactl unavailable

Test plan

  • Build with pnpm run tauri:build on Linux
  • Verify PulseAudio monitors appear in Settings > Audio Devices > System Audio dropdown
  • Select a monitor source (e.g., "Built-in Audio" / alsa_output.pci-*.monitor)
  • Start recording while playing YouTube/audio
  • Verify both microphone AND system audio are captured

System tested

  • Ubuntu/Linux with PipeWire (PulseAudio compatibility layer)
  • NVIDIA GPU with CUDA acceleration

🤖 Generated with Claude Code

- Enumerate monitor sources via pactl for system audio capture
- Use PULSE_SOURCE env var with 'pulse' ALSA device for capture
- Add default_system_audio_device() for Linux to find monitors
- Fix device resolution to handle PulseAudio source names
- Prioritize built-in audio monitors (pci-*) over others

Previously, Linux only recorded microphone audio because cpal's ALSA
backend doesn't see PulseAudio/PipeWire monitor sources. Now we:
1. Query pactl for .monitor sources (system audio)
2. Set PULSE_SOURCE and use 'pulse' ALSA device for capture
3. Fall back to ALSA loopback devices if pactl unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@thalesac
Copy link
Author

disclaimer: vibe coded - fyi @sujithatzackriya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant