Repository navigation
feat(audio): add idle timeout to auto-release ALSA device - #13
Merged
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AlsaPipeSinkkeeps the underlying ALSA device permanently locked, even while the Sendspin server is not actively streaming audio (cat /proc/asound/.../statusshowsRUNNING).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
dmixconfigurations. 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
idle_timeout_sto theConfigstruct and config file parsing (and a matching-t SECSCLI argument).ArmPlayerListenernow tracks when the stream stops and marks the device state.audio_sink.stop()to cleanly close the ALSA handle.0(disabled) to maintain strict backward compatibility, preventing audible pop-artifacts on sensitive DACs.