Previously, things like attaching strace to a running 'alsactl monitor'
process would cause it to exit.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The `L` length modifier only applies to floating-point conversion
specifiers, and `ll` is used for `long long` integers.
Although glibc accepts %Li, musl does not and returns EINVAL.
Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
They are equivalent, but __func__ is in C99. __FUNCTION__ exists only
for backwards compatibility with old gcc versions.
Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
In a mode of 'monitor, event loop runs to dispatch asynchronous event
emitted by control node. In this case, UNIX signal is used to terminate
the event loop.
This commit uses signalfd to catch the UNIX signal.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
At present, plug-and-play is not supported in a mode of 'monitor',
thus new sound card is not handled during runtime. This is not happy.
This commit uses Linux-specific inotify(7) to monitor '/dev/snd'
directory. When some files are newly added to the directory,
event dispatcher is suspended. Event sources are scanned again and the
dispatcher continue to run.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Once sound card becomes disconnection state, corresponding control node
becomes to emit error event for listeners. When catching this type of
event, event dispatcher should stop observation of the node. However,
at present, a mode of monitor can't handle this correctly. As a result,
poll(2) is executed quite frequently in loop with no wait. This results
100% consumption of CPU time.
This commit takes the dispatcher to remove the node from observation
list when detecting the disconnection state.
Reported-by: Thomas Gläßle <thomas@coldfix.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In former commits, handlers of control node are maintained by link list,
instead of one-dimensional array.
This commit obsoletes the array and split source preparation to a
function.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In a previous commit, handlers of control nodes are maintained by link
list.
This commit uses the list to register/unregister event sources to
dispatcher.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
At present, handlers for control nodes are maintained by one-dimensional
array. This is not necessarily useful to maintain handlers with
associated information.
This commit adds link-list for the maintenance.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Linux kernel supports unique system call; epoll(7). This allows
applications to make associations for descriptor-unique data in a
easy way.
This commit uses epoll(7) instead of poll(2) for this point.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In a mode of 'monitor', when given no argument, all of available control
node is observed for their events. At present, discovering the nodes is
done according to sound card number, instead of listing nodes in
configuration space of alsa-lib.
This commit adds a structure to discover sound cards with a simple
interface.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In a mode of 'monitor', an event loop runs.
This commit applies a small refactoring to splits the loop into a
function for readability.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This solves the chicken and egg problem on fresh installations whereby
the alsa state file does not yet exist, and alsa-restore unit attempted
to launch without first having a state file.
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ensures soundcard is ready before restoring state.
sound.target added to systemd in v18:
https://cgit.freedesktop.org/systemd/systemd/commit/?id=88dfa2938af
Simplify dependencies:
- After=alsa-state.service is not needed because both units test for
@daemonswitch@ with opposite outcomes.
- After=sysinit.target is automatically added by systemd.
First proposed by Tom Yan.
Signed-off-by: Chris Mayo <aklhfex@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
`/lib/systemd/system/alsa-restore.service` specifies
`StandardOutput=syslog`. This overrides the `DefaultStandardOutput`
setting from `/etc/systemd/system.conf`, which the system administrator
can use to specify how output gets logged. In particular, the sysadmin
may want output to go to the journal, or to syslog, or nowhere at all [1].
This patch removes the definition entirely, so the units can use the
system default.
Upstream the patch from the Debian package [2].
[1] https://bugs.debian.org/741123
"systemd services should not use StandardOutput=syslog; should rely
on DefaultStandardOutput"
[2] https://sources.debian.net/src/alsa-utils/1.1.2-1/debian/patches/systemd_standardoutput.patch/
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
CC: Jordi Mallach <jordi@debian.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The code releasing the each card object may access to NULL when a
bogus count is given. Add a NULL check just to make sure.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
With alsa-restore.service and alsa-store.service, systemd invokes
alsactl at boot and shutdown times. When this is invoked on a system
without sound cards, it results in an ugly error message from alsact
/usr/sbin/alsactl: save_state:1590: No soundcards found...
return code is "19"
Add ConditionPathExistsGlob checks of /dev/snd/control* devices for
avoiding unnecessary invocations of alsactl on such a system.
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=940950
Signed-off-by: Takashi Iwai <tiwai@suse.de>
readlink does not guarantee that its result string is nul-terminated.
Instead, increase the buffer by one byte to make sure that we can
add '\0' at the end.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
We now enable more outputs than just the main speaker, so update
the basic rules to reflect the actual situation.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use the "mydatadir" name consistently.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Sometimes 90-alsa-restore.rules is run before /usr is mounted,
and alsactl restore depends on /usr/share/alsa being present.
If /usr/share/alsa is not present, we're so early in the boot
process that alsa-restore.service (or upstart equivalent) will
run later on.
BugLink: https://bugs.launchpad.net/bugs/1289730
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It can not be generally assumed that the directories in which asound.state
resides are writable. Use /var/lock and allow users to alter this path.
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
$attr{number} in the RUN rule is an empty expansion. This makes sense,
because the path doesn't exist -- i.e., it refers to the path:
/sys/devices/pci0000:00/foo/bar/sound/card0/controlC0/number
Instead, refer to $attr{device/number}, which does exist.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
SND_CTL_EVENT_MASK_REMOVE has to be checked at first and ignore the
rest if it matches. Suggested by Clemens.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The file alsactl/init/00main includes the line:
CARDINFO{driver}=="CA0106", INCLUDE="ca0106", GOTO="init_end"
However, the file alsactl/init/ca0106 is not making it into the
release tarballs (nor to user installations).
This patch adds the ca0106 file to the build.
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>