Skip to content

feat(audio): add idle timeout to auto-release ALSA device - #13

Merged
LeoLTM merged 1 commit into
LeoLTM:mainfrom
jojo141185:feature/idle-timeout-release
Aug 10, 2026
Merged

LeoLTM merged 1 commit into
LeoLTM:mainfrom
jojo141185:feature/idle-timeout-release

Conversation

@jojo141185

Copy link
Copy Markdown
Contributor

Description

Coming over from Snapcast, I started using sendspin-armv6 on my Raspberry Pi Zero W. While testing, I quickly ran into an issue regarding audio device management: By default, the AlsaPipeSink keeps the underlying ALSA device permanently locked, even while the Sendspin server is not actively streaming audio (cat /proc/asound/.../status shows RUNNING).

In embedded environments, this blocks other services (e.g., TTS engines, notification handlers, or other audio players) from sharing the sound card without setting up complex dmix configurations. Additionally, having a reliable way to detect active playback vs. idle state is extremely helpful to control other hardware or trigger a relay.

This PR introduces an optional idle timeout that seamlessly closes the ALSA device after a period of stream inactivity.

Changes

  • Added idle_timeout_s to the Config struct and config file parsing (and a matching -t SECS CLI argument).
  • The ArmPlayerListener now tracks when the stream stops and marks the device state.
  • The main loop evaluates the timeout and issues audio_sink.stop() to cleanly close the ALSA handle.
  • The feature defaults to 0 (disabled) to maintain strict backward compatibility, preventing audible pop-artifacts on sensitive DACs.
  • Included an extended startup log block to provide a quick overview of loaded config parameters.

- Added `idle_timeout_s` parameter (via `-t SECS` CLI flag and config file). Disabled by default (`0`) to ensure backward compatibility and avoid pop noise on some DACs.
- Track stream stop events and device status in `ArmPlayerListener`.
- Evaluate timeout in main loop to cleanly issue `audio_sink.stop()`.
- Added startup log block displaying active configuration parameters.
@LeoLTM LeoLTM added documentation Improvements or additions to documentation enhancement New feature or request labels Aug 10, 2026
@LeoLTM
LeoLTM merged commit 2f79205 into LeoLTM:main Aug 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants