There may be nested iterations for hw: card names.
Handle this card name in snd_card_iterator_sinit().
BugLink: https://github.com/alsa-project/alsa-lib/issues/142
Fixes: eefc2c6 ("alsactl: use card iterator functions for all card loops")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The /var/lib/alsa/card<NUMBER>.conf.d directories should be emptied
when the card is initialized. Implement this functionality directly
to alsactl.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Take the card iterator idea from the monitor code and
use it for all card loops. It reduces the code duplications
and makes things easy to review.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Also remove extra snd_config_update_free_global() call for dump-state.
There's a global call in the main() function.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It is handy to remove all card controls created by applications.
This change allows to remove those controls for all cards, selected
card or selected card with a control id filter list like:
alsactl clean 0 "name='PCM'" "name='Mic Phantom'"
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
We added the check of asound.state file presence some time ago to
assure that alsactl gets called only if the state file is already
present. Since then, the situation has changed significantly:
e.g. now alsactl does initialize if the state file isn't present, and
the same alsa-restore.service is used to save the state. This means
that we should start this service no matter the state file exists at
the boot time or not. So, revert the old change again.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
A race at creating a lock file in state_lock() was discovered
recently: namely, between the first open(O_RDWR) and the second
open(O_RDWR|O_CREAT|O_EXCL) calls, another alsactl invocation may
already create a lock file, then the second open() will return EEXIST,
which isn't handled properly and treated as a fatal error.
In this patch, we check EEXIST case and try again open() with O_RDWR.
This must succeed usually, and if it fails, handle finally as the
fatal error.
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1179904
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The state_lock() has a loop to wait for the lock file creation, and
the timeout value gets decremented twice mistakenly, which leads to a
half timeout (5 seconds) than expected 10 seconds. Fix it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The generic initialization code returns error code 99 (-99). Take
all those codes equal or above (bellow) this value as non-fatal.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
As man page says: "If successful, the sched_setparam() function shall return zero."
Without update I got this output in the syslog (journalctl):
abr 16 09:25:30 mypc alsactl[1652]: alsactl 1.2.2 daemon started
abr 16 09:25:30 mypc alsactl[1652]: /usr/bin/alsactl: do_nice:165sched_setparam failed: No such file or directory
If sched_setscheduler() returns 0, so it means that the call was successful.
Signed-off-by: Oscar Megía <megia.oscar@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The timeout wasn't really being used for anything; disabling it should
reduce idle energy consumption slightly.
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>
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>