Commit graph

13 commits

Author SHA1 Message Date
Jaroslav Kysela
8403967669 alsactl: add locking for per-card initialization
Introduce the -K,--lock-dir parameter to specify the locking
directory. If the locking is active, files card<NUM>.lock
are used to serialize the multiple initialization requests
(udev, service).

Allow the relative -O,--lock-file argument (it's default now).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-02-02 15:34:40 +01:00
Jaroslav Kysela
64fa37f09b alsactl: lock - use alarm signal and F_SETLKW rather polling
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-02-01 20:45:48 +01:00
Jaroslav Kysela
ccb6d4612b alsactl: remove unused argument for state_lock_()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-02-01 20:01:08 +01:00
Takashi Iwai
c53f7cd038 alsactl: Fix race at creating a lock file
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>
2020-12-11 23:46:23 +01:00
Takashi Iwai
878e1a7c0f alsactl: Fix double decrease of lock timeout
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>
2020-12-11 23:43:34 +01:00
Jaroslav Kysela
d751320608 alsactl: lock - fix the array size (gcc warning)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-10-14 17:01:38 +02:00
Jaroslav Kysela
b1e3d945b7 Change FSF address (Franklin Street)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-14 14:28:53 +01:00
Jaroslav Kysela
1363f852e9 alsactl: Fix the file locking routines (for the state management) 2014-09-24 10:35:53 +02:00
Jaroslav Kysela
158a67f6f5 alsactl: add -L (no-lock) and change -D (lock-dir) to -O (state-lock-file)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-05-07 11:20:16 +02:00
Julian Scheel
2607d8deee alsactl: Store lockfile in /var/lock, add -D option to specify the lock dir
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>
2014-05-07 10:55:51 +02:00
Doug Goldstein
888275e66c alsactl: sprintf to snprintf prevent buffer overflow
sprintf() is a bit dangerous unless you explicitly know your type size
and want to keep it in sync always. Its safer to just use snprintf() and
ensure your string doesn't overflow and is NULL terminated.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-05-06 10:55:07 +02:00
Jaroslav Kysela
95788fea25 alsactl: Fix the string size for the lock file contents
The string length is 10 characters + LF + '\0' = 12 characters.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-15 14:44:13 +02:00
Jaroslav Kysela
cc5c3357cf alsactl: add the daemon mode
For the plug-and-play hardware, like USB devices, it may be helpful
to manage the sound state periodically, before the devices are removed.

This change implements new commands 'daemon' and 'rdaemon' to save
the sound state in defined intervals when the sound controls are changed.

The udev rules can notify the daemon using the 'kill' or 'nrestore'
commands to rescan available cards in the system.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-05 13:47:18 +02:00