LibreELEC.tv icon indicating copy to clipboard operation
LibreELEC.tv copied to clipboard

alsa-utils: restore default card state handling

Open dpapavas opened this issue 4 months ago • 7 comments

This is a first iteration of the PR regarding ALSA card state handling discussed here. The preexisting behavior, was to either restore a custom, ad-hoc state to each sound card, as it was loaded, or to restore a state saved by the user, if one existed.

The latter functionality did not work (at least not reliably; see forum thread for details) and, given the nature of the issue (briefly the udev rule runs the soundconfig script which then forks a background shell to do its work, but according to udev's manpage, any such background processes are killed once the main action finishes, so that the background shell is killed after doing whatever it managed to do, until the main script finished, which happens immediately), thefore I assume that the card resetting part of soundconfig, i.e. what it tries to do if no saved state file exists, probably doesn't work correctly either.

This PR restores the default functionality shipped with alsa-libs. Briefly this uses the alsa-restore systemd service to save the state on shutdown and restores it on next boot. The effect therefore is that the state is retained across boots. The user is then responsible for setting the mixer to the desired values, which are then retained.

This behavior works well on my setup and use-case. Nevertheless, assuming the existing functionality did work, to some extent at least and further assuming that the ad-hoc state set by the soundconfig script was in fact necessary in certain cases (where presumably the dafault state restored by ALSA on first encounter of the card, i.e. when no previously saved state exists, was not "correct" in some way), such cases may need to be fixed.

The PR is created against the 11.0 branch, as that is what I'm using. It can be rebased to other branches as needed.

dpapavas avatar Feb 25 '24 17:02 dpapavas