Commit graph

326 commits

Author SHA1 Message Date
Jaroslav Kysela
60bf4bb2af alsactl: fix the verbose compilation warnings for latest gcc
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-30 12:35:23 +02:00
Jaroslav Kysela
8ed9d7607f alsactl: fix the copy-n-paste typo (SND_RAWMIDI_STREAM_*)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-30 10:57:31 +02:00
Rudi Heitbaum
d6a71bfbde alsactl: add define to compile with glibc 2.38
strlcat and strlcpy have been added to glibc 2.38.
update the defines to use the glibc versions, and not conflict with
string.h.

ref:
- https://sourceware.org/git/?p=glibc.git;a=commit;h=454a20c8756c9c1d55419153255fc7692b3d2199

Fixes: https://github.com/alsa-project/alsa-utils/pull/225
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-01 09:36:04 +02:00
SASANO Takayoshi
cff2d1c210 alsactl: fix OpenBSD compilation (add include of os_compat.h)
Fixes: https://github.com/alsa-project/alsa-utils/pull/193
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-27 13:10:16 +01:00
SASANO Takayoshi
613372dc7c Add OpenBSD support
- ERESTART not supported platform: use EINTR instead
- add include/os_compat.h, well-used OS specific definition
- copied include/bswap.h from alsa-lib

- EPIPE and ESTRPIPE are different usage, but currently
  EPIPE is used when ESTRPIPE is not defined.

  To fix this problem, assign ESPIPE instead.

Fixes: https://github.com/alsa-project/alsa-utils/pull/186
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-03 13:08:44 +01:00
Jaroslav Kysela
f37ef4768c alsactl: Print driver name in info
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-09-27 19:06:04 +02:00
Jaroslav Kysela
bbc74a61ac alsactl: implement 'info' command
It may be useful to collect the basic sound card information.
The output is in the YAML structured syntax (human and machine readable).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-10 09:08:26 +02:00
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
Jaroslav Kysela
f5997e15d6 alsactl: add dbg() prints to init_ucm()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-02-01 19:47:53 +01:00
Alex Xu (Hello71)
d05ac4a078 alsactl: flush stdout for monitor command
It may be useful to pipe the output to another program.

Fixes: https://github.com/alsa-project/alsa-utils/pull/109
Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-27 13:22:38 +01:00
Jaroslav Kysela
8adbb2c275 alsactl: fix typo in comment in 00main
Fixes: https://github.com/alsa-project/alsa-utils/issues/132
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-27 13:19:36 +01:00
Jaroslav Kysela
fca9d89bbc alsactl: fix the error path in set_controls()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-03 16:14:31 +01:00
Jaroslav Kysela
257f3063fa alsactl: fix the check for additional elements
The driver may export only write-only elements. The previous
heuristics code do not handle this use case correctly.
Iterate through all elements and skip the write-only ones.

Fixes: https://github.com/alsa-project/alsa-utils/issues/122
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-03 11:09:57 +01:00
Jaroslav Kysela
af62c72e2d alsactl: suppress no device 'errors' for UCM
This patch adds --ucm-nodev (or -X) option to get those
messages back. The code works only with library 1.2.6+.

By default, these messages are suppressed:

  alsactl[xxx]: alsa-lib parser.c:242:(error_node) UCM is not supported for this HDA model (HDA Intel PCH...)
  alsactl[xxx]: alsa-lib main.c:1405:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -6

Fixes: https://github.com/alsa-project/alsa-utils/issues/111
Link: https://lore.kernel.org/alsa-devel/20211027144008.27002-1-tiwai@suse.de/
Link: 23198a72cd
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 12:16:11 +02:00
Andreas Müller
6a0d13ddb2 utils.c: Include limits.h explicitly to fix build on musl
Fixes:
| ../../alsa-utils-1.2.5/alsactl/utils.c: In function 'snd_card_clean_cfgdir':
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: error: 'PATH_MAX' undeclared (first use in this function)
|   309 |         char path[PATH_MAX];
|       |                   ^~~~~~~~
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: note: each undeclared identifier is reported only once for each function it appears in

Fixes: https://github.com/alsa-project/alsa-utils/pull/92
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-07 19:13:47 +02:00
Sören Tempel
6018c2014a alsactl: load_state: Only delete config if one was loaded
If load_configuration fails with open_failed == true, load_state will
jump to the out label without config being initialized and pass this
uninitialized config value to snd_config_delete. This commit fixes this
issue by initializing config with NULL and checking if it is non-null
before invoking snd_config_delete.

Fixes: https://github.com/alsa-project/alsa-utils/pull/94
Fixes: f138117 ("alsactl: load_state() - initialize config variable for the open_failed case")
BugLink: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-07 19:06:19 +02:00
Jaroslav Kysela
f138117a45 alsactl: load_state() - initialize config variable for the open_failed case
Fixes: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-07 17:21:58 +02:00
Jaroslav Kysela
cd2f779b8d alsactl: fix lock_fd unlock in load_configuration() - error path
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:08:18 +02:00
Jaroslav Kysela
646d6ff094 alsactl: state - fix ‘item’ may be used uninitialized gcc warning
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:04:50 +02:00
Jaroslav Kysela
2bc595e7bd alsactl: check for error values from snd_config_get...()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:04:00 +02:00
Jaroslav Kysela
511dd7a597 alsactl: init() - return error value from snd_card_iterator_sinit() call
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 09:56:20 +02:00
Jaroslav Kysela
d6d566a9ee alsactl: return error value in dump_config_tree()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 09:53:56 +02:00
Jaroslav Kysela
78212445de alsactl: fix the nested iteration
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>
2021-06-01 17:49:27 +02:00
Jaroslav Kysela
0fe5048a30 alsactl: ucm - try both fixed boot and boot sequences
The -ENOENT error means that there's no special configuration.
Try to fall-back to the legacy config.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-13 19:19:01 +02:00
Jaroslav Kysela
a589d88862 alsactl: clean the boot / hotplug card specific configuration directory
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>
2021-04-13 11:16:09 +02:00
Jaroslav Kysela
2c753a85a7 alsactl: snd_ctl_elem_id_compare was renamed to snd_ctl_elem_id_compare_set
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-23 17:52:13 +01:00
Jaroslav Kysela
eefc2c61cf alsactl: use card iterator functions for all card loops
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>
2021-03-11 09:23:33 +01:00
Jaroslav Kysela
9a2115b5cc alsactl: Add ucm support for the FixedBootSequence
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-11 09:23:31 +01:00
Jaroslav Kysela
7f5622c106 alsactl: fix possible memory leak for dump-cfg
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>
2021-03-10 18:13:16 +01:00
Jaroslav Kysela
c3f2344b72 alsactl: add 'clean' cmd to help, improve man page
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-07 20:18:12 +01:00
Jaroslav Kysela
b137145a92 alsactl: fix the compiler warning (uninitialized variable res)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-07 20:00:24 +01:00
Jaroslav Kysela
c1474594dc alsactl: add dump-cfg and dump-state commands
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-07 19:58:33 +01:00
MichaIng
09c04f8935 alsactl: init command now honors -g flag as well
BugLink: https://github.com/alsa-project/alsa-utils/issues/75
Signed-off-by: MichaIng <micha@dietpi.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-07 18:48:35 +01:00
Jaroslav Kysela
65453da000 alsactl: honor ignore_nocards flag in init()
BugLink: https://github.com/alsa-project/alsa-utils/issues/75
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-06 12:40:57 +01:00
Jaroslav Kysela
ade71cf8b0 alsactl: fix some compiler warnings
BugLink: https://github.com/alsa-project/alsa-utils/issues/17
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-05 21:43:47 +01:00
Jaroslav Kysela
17b4129e6c alsactl: add 'clean' command to remove the application controls
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>
2021-03-04 21:15:56 +01:00
Jaroslav Kysela
c5ecfd9789 alsactl: init - parse() - fix possible double free
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-08 18:18:53 +01:00
Jaroslav Kysela
e55534d8a5 alsactl: init - set_ctl_value() - fix bytes parsing
Use the correct error value handling from hextodigit().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-08 18:16:14 +01:00
Jaroslav Kysela
42ca978078 alsactl: daemon - read_pid_file() fix the returned code on read error
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-08 18:09:14 +01:00
Takashi Iwai
12487b40b6 alsactl: Remove asound.state file check from alsa-restore.service again
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>
2020-12-11 23:55:34 +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
860b851639 alsactl: 00main - fix typo in goto label
BugLink: https://github.com/alsa-project/alsa-utils/issues/52
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-13 17:30:15 +02:00
Jaroslav Kysela
b348abcbfe alsactl: add new -U argument text to man page
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-06 13:05:12 +02:00
Andrew Hlynskyi
d7bf45edc3 alsactl: init - add -U option to disable UCM based init
The reason is to use it with internal init extra commands like:
  alsactl -U -E CMD=info init

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-06 13:03:03 +02:00
Jaroslav Kysela
225a9afbc3 alsactl: fix the syslog message - add : delimiter after function:line
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-20 08:47:01 +02:00
Jaroslav Kysela
f8a2aad5bb alsactl: ucm - rename _once command to _boot command
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-05-25 19:21:25 +02:00
Jaroslav Kysela
570ea6c455 alsactl: allow to compile alsactl without UCM support
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-05-14 19:54:04 +02:00