alsactl: Manage both save and restore in a single unit

With RemainAfterExit=true, we can manage both save and restore of the
card state in a single unit file.  This will fix also the case where
systemd reloads the service; with two individual units, it will
restore the previous state before saving, and may lead to inconsistent
state suddenly.

Also fix alsa-state.service as well to make both start and stop
working in a simpler way.

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=929619
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2015-09-29 17:26:34 +02:00
parent cd1bb5f4a7
commit 7d6673cc13
4 changed files with 5 additions and 35 deletions

View file

@ -25,20 +25,15 @@ if HAVE_SYSTEMD
systemdsystemunit_DATA = \ systemdsystemunit_DATA = \
alsa-state.service \ alsa-state.service \
alsa-restore.service \ alsa-restore.service
alsa-store.service
install-data-hook: install-data-hook:
$(MKDIR_P) -m 0755 \ $(MKDIR_P) -m 0755 \
$(DESTDIR)$(systemdsystemunitdir)/basic.target.wants \ $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants
$(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants
( cd $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants && \ ( cd $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants && \
rm -f alsa-state.service alsa-restore.service && \ rm -f alsa-state.service alsa-restore.service && \
$(LN_S) ../alsa-state.service alsa-state.service && \ $(LN_S) ../alsa-state.service alsa-state.service && \
$(LN_S) ../alsa-restore.service alsa-restore.service) $(LN_S) ../alsa-restore.service alsa-restore.service)
( cd $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants && \
rm -f alsa-store.service && \
$(LN_S) ../alsa-store.service alsa-store.service )
endif endif
@ -54,22 +49,17 @@ alsa-state.service: alsa-state.service.in
alsa-restore.service: alsa-restore.service.in alsa-restore.service: alsa-restore.service.in
$(edit) $(edit)
alsa-store.service: alsa-store.service.in
$(edit)
90-alsa-restore.rules: 90-alsa-restore.rules.in 90-alsa-restore.rules: 90-alsa-restore.rules.in
$(edit) $(edit)
EXTRA_DIST += \ EXTRA_DIST += \
alsa-state.service.in \ alsa-state.service.in \
alsa-restore.service.in \ alsa-restore.service.in \
alsa-store.service.in \
90-alsa-restore.rules.in 90-alsa-restore.rules.in
CLEANFILES = \ CLEANFILES = \
alsa-state.service \ alsa-state.service \
alsa-restore.service \ alsa-restore.service \
alsa-store.service \
90-alsa-restore.rules 90-alsa-restore.rules
%.7: %.xml %.7: %.xml

View file

@ -4,15 +4,14 @@
# #
[Unit] [Unit]
Description=Restore Sound Card State Description=Save/Restore Sound Card State
ConditionPathExists=!@daemonswitch@ ConditionPathExists=!@daemonswitch@
ConditionPathExistsGlob=/dev/snd/control* ConditionPathExistsGlob=/dev/snd/control*
DefaultDependencies=no
After=alsa-state.service After=alsa-state.service
Before=shutdown.target
Conflicts=shutdown.target
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=true
ExecStart=-@sbindir@/alsactl restore ExecStart=-@sbindir@/alsactl restore
ExecStop=-@sbindir@/alsactl store
StandardOutput=syslog StandardOutput=syslog

View file

@ -6,10 +6,7 @@
[Unit] [Unit]
Description=Manage Sound Card State (restore and store) Description=Manage Sound Card State (restore and store)
ConditionPathExists=@daemonswitch@ ConditionPathExists=@daemonswitch@
DefaultDependencies=no
After=sysinit.target After=sysinit.target
Before=shutdown.target
Conflicts=shutdown.target
[Service] [Service]
Type=simple Type=simple

View file

@ -1,16 +0,0 @@
#
# Note that two different ALSA card state management schemes exist and they
# can be switched using a file exist check - /etc/alsa/state-daemon.conf .
#
[Unit]
Description=Store Sound Card State
ConditionPathExists=!@daemonswitch@
ConditionPathExistsGlob=/dev/snd/control*
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=@sbindir@/alsactl store
StandardOutput=syslog