OSDN Git Service

android-x86/external-alsa-lib.git
2 years agoAndroid: add makefile and config.h oreo-x86 pie-x86 android-x86-8.1-r6
Chih-Wei Huang [Fri, 18 Jun 2021 08:30:30 +0000 (16:30 +0800)]
Android: add makefile and config.h

This is the porting of alsa-lib 1.2.5 to Android.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
2 years agopcm: rate: Improve the support multiple formats
Takashi Iwai [Thu, 17 Jun 2021 08:03:17 +0000 (10:03 +0200)]
pcm: rate: Improve the support multiple formats

This patch extends the PCM rate plugin for allowing its converter
plugin to deal with multiple formats.  Currently, the converter plugin
is allowed to take different formats only when convert callback is
defined.  And for this way (so far only the standard linear rate
plugin does), all linear formats have to be handled, and it's
cumbersome.

OTOH, most other rate plugins are implemented with convert_s16
callback, which accepts only S16 format.  This is often not ideal
because many converter engines can handle 32bit formats.  Also, the
target format is often 32bit format, hence this would require
additional conversion even if the converter engine can output 32bit
natively.

In this patch, for addressing the problems above, the rate plugin API
is extended in the following way:

- The new get_supported_formats callback is added; this stores the bit
  masks of the supported input and output formats, as well as the
  behavior flags.  Currently only linear formats are allowed.
- When the plugin accepts only the interleaved stream, set
  SND_PCM_RATE_FLAG_INTERLEAVED flag bit.  Otherwise the code has to
  handle snd_pcm_channel_area at each call.
- When both input and output formats have to be identical, pass
  SND_PCM_RATE_FLAG_SYNC_FORMATS flag bit.
- When the converter wants to process different formats, use convert
  callback instead of convert_s16.  You can put both in the ops for
  compatibility, too.
  The input and output formats are found in the info argument of init
  callback.
- Now the PCM rate plugin core will skip the temporary buffer
  allocation and conversions for pre- and post-process if not needed
  (i.e. matching with the requested input or output format).

The rate plugin API version is bumped to 0x010003.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agopcm: rate: Refactoring temporary buffer allocations
Takashi Iwai [Thu, 17 Jun 2021 08:20:25 +0000 (10:20 +0200)]
pcm: rate: Refactoring temporary buffer allocations

Introduce common helpers to allocate and release the temporary buffers
and the associated snd_pcm_channel.  Now two allocated objects are
used instead of one malloc to be split.

Also, change the snd_pcm_channel set up to be in interleaved mode.
This will be necessary in the following change in the rate plugin.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agocontrol: empty - fix the static build
Jaroslav Kysela [Tue, 15 Jun 2021 21:21:42 +0000 (23:21 +0200)]
control: empty - fix the static build

Reported-by: Jan Palus <atler@pld-linux.org>
Fixes: https://github.com/alsa-project/alsa-lib/issues/157
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agocontrol: remap - fix an infinite recursive call in the async callback
Chih-Wei Huang [Mon, 14 Jun 2021 05:08:08 +0000 (13:08 +0800)]
control: remap - fix an infinite recursive call in the async callback

The function snd_ctl_remap_async will call itself infinitely. Looks like
a typo.

Fixes: a64391a42 ("control: remap plugin - initial version")
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoFix EXPORT_SYMBOL attribute for clang
Chih-Wei Huang [Mon, 14 Jun 2021 04:41:11 +0000 (12:41 +0800)]
Fix EXPORT_SYMBOL attribute for clang

Clang doesn't have the externally_visible attribute.

    src/pcm/pcm.c:1503:1: error: unknown attribute 'externally_visible' ignored [-Werror,-Wunknown-attributes]
    #define EXPORT_SYMBOL __attribute__((visibility("default"),externally_visible))                                                         ^

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconfigure: check if eaccess() is available
Chih-Wei Huang [Mon, 14 Jun 2021 04:24:10 +0000 (12:24 +0800)]
configure: check if eaccess() is available

To fix the build error on Android:
  src/ucm/parser.c:2521:7: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                if (eaccess(filename, R_OK))
                    ^
  src/ucm/parser.c:2521:7: note: did you mean 'access'?

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: include sys/wait.h to fix build on Android
Chih-Wei Huang [Mon, 14 Jun 2021 04:21:35 +0000 (12:21 +0800)]
ucm: include sys/wait.h to fix build on Android

    src/ucm/main.c:788:8: error: implicit declaration of function 'WIFSIGNALED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        if (WIFSIGNALED(err)) {
                            ^
    src/ucm/main.c:790:10: error: implicit declaration of function 'WIFEXITED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        } if (WIFEXITED(err)) {
                              ^
    src/ucm/main.c:791:34: error: implicit declaration of function 'WEXITSTATUS' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                if (ignore_error == false && WEXITSTATUS(err) != 0) {

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm_exec.c: Include limits.h explicitly to fix build on musl
Andreas Müller [Thu, 3 Jun 2021 10:29:03 +0000 (12:29 +0200)]
ucm_exec.c: Include limits.h explicitly to fix build on musl

Fixes:
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c: In function 'find_exec':
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:43:18: error: 'PATH_MAX' undeclared (first use in this function)
|    43 |         char bin[PATH_MAX];
|       |                  ^~~~~~~~
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:43:18: note: each undeclared identifier is reported only once for each function it appears in
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c: In function 'uc_mgr_exec':
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:177:18: error: 'PATH_MAX' undeclared (first use in this function)
|   177 |         char bin[PATH_MAX];
|       |                  ^~~~~~~~

Fixes: https://github.com/alsa-project/alsa-lib/pull/145
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: compound_merge() - fix use after free (and logic)
Jaroslav Kysela [Thu, 3 Jun 2021 07:00:51 +0000 (09:00 +0200)]
ucm: compound_merge() - fix use after free (and logic)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix possible memory leak in parse_verb_file()
Jaroslav Kysela [Thu, 3 Jun 2021 05:30:27 +0000 (07:30 +0200)]
ucm: fix possible memory leak in parse_verb_file()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: direct - remove dead code
Jaroslav Kysela [Thu, 3 Jun 2021 05:29:43 +0000 (07:29 +0200)]
pcm: direct - remove dead code

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: snd_config_get_card() remove unused assignment
Jaroslav Kysela [Thu, 3 Jun 2021 05:29:11 +0000 (07:29 +0200)]
conf: snd_config_get_card() remove unused assignment

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix out-of-array access in rval_device_lookup_init()
Jaroslav Kysela [Wed, 2 Jun 2021 18:01:08 +0000 (20:01 +0200)]
ucm: fix out-of-array access in rval_device_lookup_init()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: check error value in parse_lookup_query()
Jaroslav Kysela [Wed, 2 Jun 2021 17:59:10 +0000 (19:59 +0200)]
ucm: check error value in parse_lookup_query()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix possible NULL pointer dereference in uc_mgr_exec()
Jaroslav Kysela [Wed, 2 Jun 2021 17:58:04 +0000 (19:58 +0200)]
ucm: fix possible NULL pointer dereference in uc_mgr_exec()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: find_exec() - fix memory leak (dir)
Jaroslav Kysela [Wed, 2 Jun 2021 17:56:01 +0000 (19:56 +0200)]
ucm: find_exec() - fix memory leak (dir)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix if_eval_path() - access NULL pointer
Jaroslav Kysela [Wed, 2 Jun 2021 17:53:24 +0000 (19:53 +0200)]
ucm: fix if_eval_path() - access NULL pointer

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix use after free in if_eval_regex_match()
Jaroslav Kysela [Wed, 2 Jun 2021 17:52:12 +0000 (19:52 +0200)]
ucm: fix use after free in if_eval_regex_match()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix error path in execute_cfgsave()
Jaroslav Kysela [Wed, 2 Jun 2021 17:51:13 +0000 (19:51 +0200)]
ucm: fix error path in execute_cfgsave()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotimer: remove dead code in _snd_timer_hw_open()
Jaroslav Kysela [Wed, 2 Jun 2021 17:50:17 +0000 (19:50 +0200)]
timer: remove dead code in _snd_timer_hw_open()

2 years agopcm: softvol - fix early exit in add_tlv_info()
Jaroslav Kysela [Wed, 2 Jun 2021 17:49:29 +0000 (19:49 +0200)]
pcm: softvol - fix early exit in add_tlv_info()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: remove extra NULL checks in snd_pcm_dshare_open()
Jaroslav Kysela [Wed, 2 Jun 2021 17:46:46 +0000 (19:46 +0200)]
pcm: remove extra NULL checks in snd_pcm_dshare_open()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: remove extra NULL checks in snd_pcm_dsnoop_open()
Jaroslav Kysela [Wed, 2 Jun 2021 17:39:32 +0000 (19:39 +0200)]
pcm: remove extra NULL checks in snd_pcm_dsnoop_open()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: remove extra NULL checks in snd_pcm_dmix_open()
Jaroslav Kysela [Wed, 2 Jun 2021 17:37:53 +0000 (19:37 +0200)]
pcm: remove extra NULL checks in snd_pcm_dmix_open()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: direct - fix pcmp error path in _snd_pcm_direct_new()
Jaroslav Kysela [Wed, 2 Jun 2021 17:35:44 +0000 (19:35 +0200)]
pcm: direct - fix pcmp error path in _snd_pcm_direct_new()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agocontrol: remap - fix uninitialized value in parse_map_vindex()
Jaroslav Kysela [Wed, 2 Jun 2021 17:28:32 +0000 (19:28 +0200)]
control: remap - fix uninitialized value in parse_map_vindex()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: remove dead code in snd_config_get_card()
Jaroslav Kysela [Wed, 2 Jun 2021 17:26:47 +0000 (19:26 +0200)]
conf: remove dead code in snd_config_get_card()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix _alibpref string (add '.' delimiter to the end)
Jaroslav Kysela [Wed, 2 Jun 2021 09:21:54 +0000 (11:21 +0200)]
ucm: fix _alibpref string (add '.' delimiter to the end)

Fixes: 0e4ba2ea ("ucm: add _alibpref to get the private device prefix")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: add _alibpref to get the private device prefix
Jaroslav Kysela [Wed, 2 Jun 2021 09:09:43 +0000 (11:09 +0200)]
ucm: add _alibpref to get the private device prefix

It may be useful to get the device prefix for the local configuration.

Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1251
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: fix load_for_all_cards()
Jaroslav Kysela [Wed, 2 Jun 2021 06:49:32 +0000 (08:49 +0200)]
conf: fix load_for_all_cards()

The 63f7745b commit is loading the driver specific configuration
multiple times which ends with the array merges (see the bug).

Introduce the loaded compound which traces the already loaded
driver configurations and skip the multiple load requests.

Fixes: https://github.com/alsa-project/alsa-lib/issues/143
Fixes: 63f7745b ("conf: extend load_for_all_cards hook (id/value table)")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoRelease v1.2.5
Jaroslav Kysela [Thu, 27 May 2021 21:30:16 +0000 (23:30 +0200)]
Release v1.2.5

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: hw - correct the comment in snd_pcm_hw_state()
Jaroslav Kysela [Thu, 27 May 2021 21:26:02 +0000 (23:26 +0200)]
pcm: hw - correct the comment in snd_pcm_hw_state()

Fixes: c7a939ee ("pcm: hw - fix again snd_pcm_hw_state() when the driver was disconnected")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: hw - fix again snd_pcm_hw_state() when the driver was disconnected
Jaroslav Kysela [Thu, 27 May 2021 20:01:25 +0000 (22:01 +0200)]
pcm: hw - fix again snd_pcm_hw_state() when the driver was disconnected

Fixes: 2c8e31f5 ("pcm: hw - fix snd_pcm_hw_state()")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoseq: fix snd_seq_parse_address()
Jaroslav Kysela [Wed, 26 May 2021 15:28:53 +0000 (17:28 +0200)]
seq: fix snd_seq_parse_address()

Use safe_strtol() for the integer conversion. Also accept
client name in "" or '' notation.

BugLink: https://github.com/alsa-project/alsa-utils/issues/90
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotopology/pcm.c: remove duplicated AC97 hw format
Chao Song [Wed, 26 May 2021 06:00:21 +0000 (14:00 +0800)]
topology/pcm.c: remove duplicated AC97 hw format

Remove the second occurrence of AC97 hardware format
from audio hardware format array.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoinclude: try to fix the out-of-source-tree build
Jaroslav Kysela [Tue, 25 May 2021 15:12:47 +0000 (17:12 +0200)]
include: try to fix the out-of-source-tree build

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoinclude: fix out-of-source-tree build
Jaroslav Kysela [Tue, 25 May 2021 14:35:23 +0000 (16:35 +0200)]
include: fix out-of-source-tree build

Fixes:

  cd alsa-lib
  if test -r Makefile; then
    make distclean
  fi
  mkdir build
  cd build
  ../configure
  make

Note:

  The srcdir is used for the symlinks to generated include files :-(
  I've not found a better (easy) way to fix this.

Fixes: https://github.com/alsa-project/alsa-lib/issues/136
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: hw - fix snd_pcm_hw_state()
Jaroslav Kysela [Tue, 25 May 2021 13:29:22 +0000 (15:29 +0200)]
pcm: hw - fix snd_pcm_hw_state()

The pcm status function should not return an error code.
Return always only the mmaped status.

Fixes: https://github.com/alsa-project/alsa-lib/issues/137
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: compound_merge - use snd_config_merge()
Jaroslav Kysela [Mon, 24 May 2021 07:51:37 +0000 (09:51 +0200)]
ucm: compound_merge - use snd_config_merge()

It's useful to do the full tree merge (append).

Fixes: https://github.com/alsa-project/alsa-ucm-conf/pull/92
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: snd_config_merge() - substitute non-compound config handles
Jaroslav Kysela [Mon, 24 May 2021 08:00:08 +0000 (10:00 +0200)]
conf: snd_config_merge() - substitute non-compound config handles

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: snd_config_merge() - merge (concat) correctly arrays
Jaroslav Kysela [Mon, 24 May 2021 07:37:13 +0000 (09:37 +0200)]
conf: snd_config_merge() - merge (concat) correctly arrays

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: return count of items in snd_config_is_array()
Jaroslav Kysela [Mon, 24 May 2021 07:27:17 +0000 (09:27 +0200)]
conf: return count of items in snd_config_is_array()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: recognize first '-' character as ignore error for exec/shell
Jaroslav Kysela [Tue, 18 May 2021 14:36:49 +0000 (16:36 +0200)]
ucm: recognize first '-' character as ignore error for exec/shell

It may be useful to ignore the returned errors (like modprobe etc).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: print quoted string more wisely
Jaroslav Kysela [Tue, 18 May 2021 11:02:56 +0000 (13:02 +0200)]
conf: print quoted string more wisely

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: cfg-save - allow to save the sub-tree including root keys
Jaroslav Kysela [Tue, 18 May 2021 10:22:46 +0000 (12:22 +0200)]
ucm: cfg-save - allow to save the sub-tree including root keys

The leading '+' in the keys specification add the key prefix
(sub-tree root identification) to the saved configuration.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: libconfig - merge not override items
Jaroslav Kysela [Tue, 18 May 2021 09:20:56 +0000 (11:20 +0200)]
ucm: libconfig - merge not override items

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: libconfig parser - fix memory leaks
Jaroslav Kysela [Tue, 18 May 2021 09:20:18 +0000 (11:20 +0200)]
ucm: libconfig parser - fix memory leaks

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: fix snd_config_merge() - merge schema
Jaroslav Kysela [Tue, 18 May 2021 08:57:17 +0000 (10:57 +0200)]
conf: fix snd_config_merge() - merge schema

All child compounds must be traversed and merged.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agocontrol: remap - add no-op when the remapping is not active
Jaroslav Kysela [Mon, 17 May 2021 15:03:37 +0000 (17:03 +0200)]
control: remap - add no-op when the remapping is not active

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: add cfg-save command
Jaroslav Kysela [Fri, 14 May 2021 10:20:18 +0000 (12:20 +0200)]
ucm: add cfg-save command

Allow to save whole (or partial) local UCM alsa library configuration
to a file.

Syntax (saves key1.key2 sub-tree):

Sequence [
cfg-save "/tmp/my-file.conf:key1.key2"
]

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix memory leak in execute_cset()
Jaroslav Kysela [Fri, 14 May 2021 10:49:03 +0000 (12:49 +0200)]
ucm: fix memory leak in execute_cset()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: parse LibraryConfig also in the toplevel file
Jaroslav Kysela [Thu, 13 May 2021 16:28:20 +0000 (18:28 +0200)]
ucm: parse LibraryConfig also in the toplevel file

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: load the card specific configurations to the config sub-tree
Jaroslav Kysela [Thu, 13 May 2021 09:04:14 +0000 (11:04 +0200)]
conf: load the card specific configurations to the config sub-tree

The /var/lib/alsa/card<CARDNO>.conf.d configurations are loaded
to the cards.<CARDNO> tree only (overwrite mode).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: add snd_config_make_path() function
Jaroslav Kysela [Thu, 13 May 2021 09:02:41 +0000 (11:02 +0200)]
conf: add snd_config_make_path() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: add snd_config_is_empty() function
Jaroslav Kysela [Thu, 13 May 2021 08:59:43 +0000 (10:59 +0200)]
conf: add snd_config_is_empty() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: fix open in direct plugins - wrong pointer assignment
Jaroslav Kysela [Thu, 13 May 2021 08:18:27 +0000 (10:18 +0200)]
pcm: fix open in direct plugins - wrong pointer assignment

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: _snd_config_evaluate - remove 'delete compound members' call
Jaroslav Kysela [Wed, 12 May 2021 10:12:57 +0000 (12:12 +0200)]
conf: _snd_config_evaluate - remove 'delete compound members' call

With the recent snd_config_substitute() fix, remove the duplicate
code.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: fix snd_config_substitute() - memory leak
Jaroslav Kysela [Wed, 12 May 2021 09:39:05 +0000 (11:39 +0200)]
conf: fix snd_config_substitute() - memory leak

There's an issue with the current code: It says append for compounds,
but it does overwrite without the proper members delete from
the overwritten (destination) compound node.

Don't change the behaviour, just fix the comment and memory leak.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: fix snd_config_merge() - double free in overwrite mode
Jaroslav Kysela [Wed, 12 May 2021 08:07:12 +0000 (10:07 +0200)]
conf: fix snd_config_merge() - double free in overwrite mode

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix regexec() REG_NOMATCH state handling for define regex
Jaroslav Kysela [Wed, 12 May 2021 07:53:18 +0000 (09:53 +0200)]
ucm: fix regexec() REG_NOMATCH state handling for define regex

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: add exec sequence command
Jaroslav Kysela [Tue, 11 May 2021 12:48:16 +0000 (14:48 +0200)]
ucm: add exec sequence command

This change renames the original exec command to shell which
is more appropriate. Implement a light version of the exec
command which calls directly the specified executable without
the shell interaction (man 3 system).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoalsa: conf - use card number roots for device redirects
Jaroslav Kysela [Tue, 4 May 2021 18:48:52 +0000 (20:48 +0200)]
alsa: conf - use card number roots for device redirects

The change device definitions (pcm.front etc.) from the driver
roots (cards.<DRIVER_NAME>) to the card number roots (cards.<CARDNO>).

This will allow us to do custom overrides (like UCM) in
/var/lib/alsa/card<CARDNO>.conf.d.

For dmix and dsnoop default values, use the card ID instead
the card driver name. It's more flexible.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoconf: extend load_for_all_cards hook (id/value table)
Jaroslav Kysela [Tue, 4 May 2021 18:27:45 +0000 (20:27 +0200)]
conf: extend load_for_all_cards hook (id/value table)

For the per-card configuration, add possibility to define
card number -> card driver link table.

Example:

  cards.0 'cards.USB-Audio'
  cards.1 'cards.USB-Audio'
  cards.2 'cards.HDA-Intel'
  cards.3 'cards.USB-Audio'

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agomixer: simple - Fix "Capture Volume" and "Capture Switch" being seen as global controls
Hans de Goede [Tue, 4 May 2021 15:58:30 +0000 (17:58 +0200)]
mixer: simple - Fix "Capture Volume" and "Capture Switch" being seen as global controls

Fix the "Capture Volume" and "Capture Switch" exceptions no longer
working after commit 86b9c67774bc ("mixer: simple - Unify simple_none:
base_len() exception handling") because they were moved to after the
suffix checking, so they would be treated as CTL_GLOBAL_VOLUME resp.
CTL_GLOBAL_SWITCH based on their suffix before the exception check
has a chance to check for a match.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: Fix sysw sequence command not working when requesting to ignore errors
Hans de Goede [Mon, 3 May 2021 20:52:44 +0000 (22:52 +0200)]
ucm: Fix sysw sequence command not working when requesting to ignore errors

When the user requests to ignore sysfs write errors by prefixing
the path with a '-' then we need to skip the '-' when building the
actual path otherwise the write will never work.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix the local ucm control device name caching
Jaroslav Kysela [Fri, 23 Apr 2021 15:24:36 +0000 (17:24 +0200)]
ucm: fix the local ucm control device name caching

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: remap - don't allow I/O on renamed IDs
Jaroslav Kysela [Fri, 23 Apr 2021 14:35:26 +0000 (16:35 +0200)]
control: remap - don't allow I/O on renamed IDs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: add missing src/conf/ctl/Makefile.am
Jaroslav Kysela [Fri, 23 Apr 2021 10:28:33 +0000 (12:28 +0200)]
control: add missing src/conf/ctl/Makefile.am

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: limit the master config scan to conf.virt.d
Jaroslav Kysela [Thu, 22 Apr 2021 09:47:48 +0000 (11:47 +0200)]
ucm: limit the master config scan to conf.virt.d

The composition of the list of valid UCM cards is a bit
tricky. Scan only ucm2/conf.virt.d tree.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fixed find-device substitution (non-continuous PCM devices)
Jaroslav Kysela [Fri, 16 Apr 2021 12:48:08 +0000 (14:48 +0200)]
ucm: fixed find-device substitution (non-continuous PCM devices)

The PCM device numbers may be non-continous. Skip them when -ENOENT error
is returned.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: allow to escape the trailing variable substitution character
Jaroslav Kysela [Fri, 16 Apr 2021 10:34:29 +0000 (12:34 +0200)]
ucm: allow to escape the trailing variable substitution character

Example:

  ${find-device:ctl='hw:0',type=pcm,field=id,regex='USB A{1\\}'}

Unescaped find-device arguments:

  ctl='hw:0',type=pcm,field=id,regex='USB A{1}'

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: find-device / pcm - the ctl_list may be empty
Jaroslav Kysela [Fri, 16 Apr 2021 08:48:35 +0000 (10:48 +0200)]
ucm: find-device / pcm - the ctl_list may be empty

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add missing uc_mgr_card_close() call to snd_use_case_mgr_open()
Jaroslav Kysela [Thu, 15 Apr 2021 14:58:24 +0000 (16:58 +0200)]
ucm: add missing uc_mgr_card_close() call to snd_use_case_mgr_open()

Handle the error path correctly.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: cosmetic code reshuffle in rval_lookup_main()
Jaroslav Kysela [Thu, 15 Apr 2021 14:45:12 +0000 (16:45 +0200)]
ucm: cosmetic code reshuffle in rval_lookup_main()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix uc_mgr_has_local_config()
Jaroslav Kysela [Thu, 15 Apr 2021 09:49:32 +0000 (11:49 +0200)]
ucm: fix uc_mgr_has_local_config()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: rewrite device value only when the local config exists
Jaroslav Kysela [Thu, 15 Apr 2021 09:38:39 +0000 (11:38 +0200)]
ucm: rewrite device value only when the local config exists

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoutils/alsa.m4: another quick fix for the brackets
asavah [Tue, 13 Apr 2021 19:16:26 +0000 (22:16 +0300)]
utils/alsa.m4: another quick fix for the brackets

BugLink: https://github.com/alsa-project/alsa-lib/pull/133
From: asavah <asavah@avh.od.ua>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoutils/alsa.m4: a quick fix for missing end brackets
Jaroslav Kysela [Tue, 13 Apr 2021 18:30:07 +0000 (20:30 +0200)]
utils/alsa.m4: a quick fix for missing end brackets

Fixes: c6e0f24e ("utils/alsa.m4: update for newer autoconf.")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: usb - correct 'SB Omni Surround 5.1' iec958 device
Jaroslav Kysela [Tue, 13 Apr 2021 17:58:01 +0000 (19:58 +0200)]
conf: usb - correct 'SB Omni Surround 5.1' iec958 device

BugLink: https://github.com/alsa-project/alsa-lib/issues/101
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotest: audio_time - fix timestamp2ns() and usage()
Jaroslav Kysela [Tue, 13 Apr 2021 17:49:44 +0000 (19:49 +0200)]
test: audio_time - fix timestamp2ns() and usage()

BugLink: https://github.com/alsa-project/alsa-lib/issues/132
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoutils/alsa.m4: update for newer autoconf.
Ozkan Sezer [Thu, 17 Dec 2020 11:11:28 +0000 (14:11 +0300)]
utils/alsa.m4: update for newer autoconf.

fixes autoconf-2.70 warnings. should be compatible down to autoconf-2.59.

BugLink: https://github.com/alsa-project/alsa-lib/pull/106
Signed-off-by: Ozkan Sezer <sezeroz@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: return error if fixedboot_list is empty
Jaroslav Kysela [Tue, 13 Apr 2021 17:13:20 +0000 (19:13 +0200)]
ucm: return error if fixedboot_list is empty

The application should know, that there is no special
initialization sequence. It's counterpart for
"ucm: return error if boot_list is empty".

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: return error if boot_list is empty
Hui Wang [Thu, 29 Oct 2020 06:51:30 +0000 (14:51 +0800)]
ucm: return error if boot_list is empty

If bootlist is empty, that means there is no BootSequence defined
in the ucm for this sound card, let set_boot_user() return error,
then alsactl could have chance to use non-ucm ways to initialize the
sound card.

BugLink: https://github.com/alsa-project/alsa-lib/pull/94
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: USB - add "Cmedia Audio" to USB-Audio.pcm.iec958_device
Hui Wang [Mon, 1 Mar 2021 05:51:54 +0000 (13:51 +0800)]
conf: USB - add "Cmedia Audio" to USB-Audio.pcm.iec958_device

Otherwise, there will be a "Digital Output(S/PDIF)-Cmedia Audio" from
Gnome UI, but there is no this physical interface on the card.

BugLink: https://github.com/alsa-project/alsa-lib/pull/122
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRemove non-existent SPDIF output on Dell AE515
James [Wed, 3 Mar 2021 21:03:37 +0000 (21:03 +0000)]
Remove non-existent SPDIF output on Dell AE515

The Dell Professional Sound Bar AE515 shows up in GNOME Settings with
a digital output that doesn't physically exist. Add it to the list
to suppress this.

BugLink: https://github.com/alsa-project/alsa-lib/pull/124
From: drjhe
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: No SPDIF on Plantronics 3220 headset
James [Tue, 16 Mar 2021 17:41:48 +0000 (17:41 +0000)]
conf: No SPDIF on Plantronics 3220 headset

The Plantronics Blackwire 3220 Series headset (USB ID 047f:c056) shows up
in GNOME Settings with a non-existent digital output. Add it to the list
to suppress this.

BugLink: https://github.com/alsa-project/alsa-lib/pull/126
From: drjhe
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - move the direct struct init to _snd_pcm_direct_new()
Jaroslav Kysela [Tue, 13 Apr 2021 16:55:37 +0000 (18:55 +0200)]
pcm: direct - move the direct struct init to _snd_pcm_direct_new()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: dshare - fix shared memory pointer check
Vanitha Channaiah [Sun, 21 Mar 2021 11:00:48 +0000 (16:30 +0530)]
pcm: dshare - fix shared memory pointer check

Currently shared memory pointer is initialized to 0 and set to -1
in some, but not in all error paths.
In cleanup path of open the shm pointer is only compared to be non-NULL
before dereferencing it which leads to SEGFAULT in case it was set to -1.

This patch initializes pointer to -1 to have a unique identification
for invalid pointer and also checks for pointer being not -1 on
access in cleanup path.

Signed-off-by: Vanitha Channaiah <vanitha.channaiah@in.bosch.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoinclude: fix SND_LIB_VER() macro
Jaroslav Kysela [Tue, 13 Apr 2021 16:01:09 +0000 (18:01 +0200)]
include: fix SND_LIB_VER() macro

Fixes: c132509a ("include: add SND_LIB_VER() macro")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: ucm_filename() - avoid double //
Jaroslav Kysela [Tue, 13 Apr 2021 15:19:54 +0000 (17:19 +0200)]
ucm: ucm_filename() - avoid double //

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: handle better the system() call
Jaroslav Kysela [Tue, 13 Apr 2021 07:52:35 +0000 (09:52 +0200)]
ucm: handle better the system() call

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add LibraryConfig support
Jaroslav Kysela [Mon, 12 Apr 2021 16:09:21 +0000 (18:09 +0200)]
ucm: add LibraryConfig support

This commit allows to define private alsa-lib's configuration. When
the configuration is present, the device values ("PlaybackCTL",
"CaptureCTL", "PlaybackMixer", "CaptureMixer", "CapturePCM")
are prefixed with '_ucmHEXA.' string where HEXA is replaced by the
unique hexadecimal number identifying the opened ucm manager handle.

    Syntax 4

    LibraryConfig.a_label.SubstiConfig {
            # substituted library configuration like:
            usr_share_dir "${ConfLibDir}"
    }

    LibraryConfig.b_label.Config {
            # non-substituted library configuration like:
            usr_share_dir "/usr/share/alsa"
    }

    The File counterparts:

    LibraryConfig.c_label.SubstiFile "/some/path"
    LibraryConfig.d_label.File "/some/path"

Note that for files the contents is substituted on the request,
but the file name is always substituted (useful for ${ConfDir} etc.).

The private configuration is not saved or preserved. It's life time
belongs to the opened ucm manager handle.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agooutput: Add snd_output_buffer_steal() function
Jaroslav Kysela [Mon, 12 Apr 2021 14:47:58 +0000 (16:47 +0200)]
output: Add snd_output_buffer_steal() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add snd_config_merge() function
Jaroslav Kysela [Fri, 9 Apr 2021 16:11:57 +0000 (18:11 +0200)]
conf: add snd_config_merge() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add ${ConfLibDir} substitution
Jaroslav Kysela [Thu, 8 Apr 2021 10:48:38 +0000 (12:48 +0200)]
ucm: add ${ConfLibDir} substitution

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add /var/lib/alsa/conf.d directory lookup
Jaroslav Kysela [Thu, 8 Apr 2021 10:31:47 +0000 (12:31 +0200)]
conf: add /var/lib/alsa/conf.d directory lookup

It may be handy to put the configurations or symlinks
to the global runtime directory.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add /var/lib/alsa/card<NUMBER>.conf.d directory lookups
Jaroslav Kysela [Tue, 6 Apr 2021 19:05:31 +0000 (21:05 +0200)]
conf: add /var/lib/alsa/card<NUMBER>.conf.d directory lookups

It may be handy to put extra configurations or symlinks to
the global runtime directory. The configurations may be
created at boot / hotplug event by udev or other scripts.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: extend hook load_for_all_cards
Jaroslav Kysela [Tue, 6 Apr 2021 18:00:36 +0000 (20:00 +0200)]
conf: extend hook load_for_all_cards

Pass also card integer number.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoinclude: add SND_LIB_VER() macro
Jaroslav Kysela [Tue, 6 Apr 2021 16:32:57 +0000 (18:32 +0200)]
include: add SND_LIB_VER() macro

Signed-off-by: Jaroslav Kysela <perex@perex.cz>