Skip to content

Add opt-in --release-device to close ALSA/PortAudio output on stream end - #100

Merged
chrisuthe merged 1 commit into
mainfrom
chrisuthe/task/add-opt-in-release-device-to-close-alsa-portaudio
Oct 27, 2026
Merged

chrisuthe merged 1 commit into
mainfrom
chrisuthe/task/add-opt-in-release-device-to-close-alsa-portaudio

Conversation

@chrisuthe

@chrisuthe chrisuthe commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Adds --release-device / release-device = true. When it is set, the ALSA or PortAudio output is closed when a stream ends and reopened at the next stream/start, so Squeezelite, AirPlay and Spotify can use the same exclusive hw: DAC between Sendspin streams. It is off by default because of the trade-off: another app can take the device between streams, and the next stream is then discarded through the existing per-stream refusal.

  • AudioSink::release() defaults to clear(). ALSA and PortAudio override it to drop, close, forget last_format_ and cancel any owed recovery, so poll() never reopens a released device. A late write() discards without logging the device-lost error.
  • PlayerListener releases before the stop hook fires, so a hook that starts another player finds the device free.
  • On other backends a one-line INFO notice says the option does nothing.
  • Tests cover option parsing, config file and bad values, SinkRecovery::cancel(), and the ordering of release vs clear relative to the stop event.

Breaking changes: none for CLI users. The option is opt-in and default behaviour is unchanged.

Manual check still to do (needs hardware): Pi with -o hw:... and --release-device. After a stop, /proc/asound/cardN/pcm0p/sub0/status should read closed, aplay -D hw:... should succeed, and the next Sendspin stream should play.

Closes #80

Lets other players take turns on an exclusive hw: DAC between Sendspin streams. Off by default: another app can take the device between streams, and every stream pays a cold open.
@chrisuthe
chrisuthe marked this pull request as ready for review October 27, 2026 04:22
@chrisuthe
chrisuthe merged commit aaeb37d into main Oct 27, 2026
18 checks passed
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.

ALSA: keep the device open only while a stream plays

1 participant