Skip to content

Improve PulseAudio/PipeWire integration and audio device discovery - #240

Merged
balloob merged 2 commits into
mainfrom
claude/fix-audio-source-visibility-e5WFs
Apr 29, 2026
Merged

Improve PulseAudio/PipeWire integration and audio device discovery#240
balloob merged 2 commits into
mainfrom
claude/fix-audio-source-visibility-e5WFs

Conversation

@balloob

@balloob balloob commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR enhances Sendspin's audio output handling on Linux desktop environments by properly identifying the application to the sound server and improving the audio device discovery experience.

Key Changes

  • PulseAudio/PipeWire metadata: Added _set_pulse_client_metadata() function that sets libpulse environment variables before client connection, allowing the audio stream to register as "Sendspin" instead of a generic "ALSA plug-in [python3]" name. Users can override these defaults by setting their own environment variables.

  • Audio device recommendations: Enhanced list_audio_devices() to display recommended desktop audio routing options (pulse, pipewire, default) when available, making it easier for users to choose appropriate devices.

  • Improved help text: Updated help documentation for the --audio-device argument in both player and daemon modes to explicitly mention that pulse, pipewire, and default are available routing options on Linux desktops.

  • Automatic initialization: The metadata setup is called automatically in main() before argument parsing, ensuring proper identification with the sound server from the start.

Implementation Details

  • The metadata function uses os.environ.setdefault() to respect user overrides
  • Recommended devices are filtered to only show those actually available on the system
  • The changes are backward compatible and only affect Linux desktop environments using PulseAudio or PipeWire

https://claude.ai/code/session_01H1fE1RpT8dQd3FEhveB5qe

Set PULSE_PROP_application.{name,id,icon_name} and media.role at process
startup so that libpulse (used by the ALSA pulse/pipewire plug devices and
pipewire-pulse) registers the playback stream as "Sendspin" instead of a
generic "ALSA plug-in [python3]". Highlight the pulse/pipewire/default
device names in `audio-devices list` and the --audio-device help so users
discover the sound-server-routed options.

Refs #239

https://claude.ai/code/session_01H1fE1RpT8dQd3FEhveB5qe
Copilot AI review requested due to automatic review settings April 29, 2026 03:56
@balloob balloob linked an issue Apr 29, 2026 that may be closed by this pull request
@balloob balloob added bugfix Fixes a bug new-feature Request or implement a new feature and removed bugfix Fixes a bug labels Apr 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Linux desktop audio output ergonomics by setting PulseAudio/PipeWire client metadata for better stream identification and by making common desktop routing device choices easier to discover and understand from the CLI.

Changes:

  • Add _set_pulse_client_metadata() to set libpulse-related environment properties before audio client connections.
  • Enhance audio-devices list output with “Recommended for desktop usage” routing options when present (pulse, pipewire, default).
  • Update --audio-device help text in both player and daemon modes to mention desktop routing options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sendspin/cli.py Outdated

def main() -> int:
"""Run the CLI client."""
_set_pulse_client_metadata()

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_set_pulse_client_metadata() is called unconditionally from main(), so these PulseAudio/PipeWire-related env vars are set even on non-Linux platforms and for subcommands that never touch audio output (e.g., serve/servers/clients). If the intent is “only affect Linux desktop environments”, add a sys.platform.startswith("linux") (or similar) guard around the call (or inside the helper) to avoid unnecessary global environment side effects.

Suggested change
_set_pulse_client_metadata()
if sys.platform.startswith("linux"):
_set_pulse_client_metadata()

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 145404b. Wrapped the call in if sys.platform.startswith("linux"): so non-Linux platforms and the audio-less subcommands (serve, servers list, clients list) don't touch the global env at all.


Generated by Claude Code

Comment thread sendspin/cli.py
Comment thread sendspin/cli.py
- Only call _set_pulse_client_metadata() on Linux; the PULSE_PROP_* env
  vars have no effect elsewhere and there's no reason to mutate the
  global env on macOS/Windows or for the serve/servers/clients
  subcommands.
- Update the daemon --audio-device help to mention raw ALSA device names
  (e.g. dmixer, olohuone) — the daemon goes through the same
  resolve_audio_device() / _try_alsa_device() path as the player, so the
  help should match.

https://claude.ai/code/session_01H1fE1RpT8dQd3FEhveB5qe
@balloob
balloob merged commit 77fa84f into main Apr 29, 2026
1 check passed
@balloob
balloob deleted the claude/fix-audio-source-visibility-e5WFs branch April 29, 2026 12:41
trudenboy added a commit to trudenboy/sendspin-bt-bridge that referenced this pull request May 8, 2026
Upstream rolled two minors with material fixes for our flows:

7.2.0 (PR Sendspin/sendspin-python-cli#240, #241):
- Better PulseAudio / PipeWire integration and audio device discovery
- Fixed an ALSA device leak

7.3.0 (PR Sendspin/sendspin-python-cli#246, #245, #244, #247):
- Fixed unwanted catch-up when joining mid-stream playback — the bridge
  rejoins streams routinely (after BT reconnect, after warm_restart from
  /api/config saves, after standby exit), so this was a recurring source
  of audible artifacts at the start of speaker resumes.
- Fixed wrong audio sync delta after a server-driven delay change —
  matters because MA pushes per-player static_delay_ms (we advertise
  set_static_delay since v2.68.0), and a slider drag in MA produced a
  brief glitch from the bad delta.
- Aligned stream/clear and stream/end with the protocol spec (drops
  role versions).
- Bumped aiosendspin to 5.2 — already on our side via #271.

No breaking changes between 7.1.0 and 7.3.0; the 7.0.0 per-player
delay break is already absorbed (see CHANGELOG 2.68.0).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature Request or implement a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sendspin playback source not shown in pulseaudio or pipewire GUI tools?

3 participants