Commit graph

4158 commits

Author SHA1 Message Date
Takashi Iwai
119d9c1678 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>
2021-06-17 11:40:38 +02:00
Takashi Iwai
5089358aa9 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>
2021-06-17 10:20:25 +02:00
Jaroslav Kysela
81e7923fbf 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>
2021-06-15 23:24:26 +02:00
Chih-Wei Huang
f4c061f349 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>
2021-06-14 10:14:40 +02:00
Chih-Wei Huang
8253c1c1f9 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>
2021-06-14 10:11:42 +02:00
Chih-Wei Huang
76d1aa0cd7 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>
2021-06-14 10:10:58 +02:00
Chih-Wei Huang
01960fa856 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>
2021-06-14 10:10:02 +02:00
Andreas Müller
abe805ed6c 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>
2021-06-04 09:26:36 +02:00
Jaroslav Kysela
0325f4357d ucm: compound_merge() - fix use after free (and logic)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-03 09:00:51 +02:00
Jaroslav Kysela
e213309060 ucm: fix possible memory leak in parse_verb_file()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-03 07:30:27 +02:00
Jaroslav Kysela
a154cb2904 pcm: direct - remove dead code
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-03 07:29:43 +02:00
Jaroslav Kysela
42c0ccf327 conf: snd_config_get_card() remove unused assignment
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-03 07:29:11 +02:00
Jaroslav Kysela
30d1d256e7 ucm: fix out-of-array access in rval_device_lookup_init()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 20:01:08 +02:00
Jaroslav Kysela
64a6d4d1e8 ucm: check error value in parse_lookup_query()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:59:10 +02:00
Jaroslav Kysela
26ab7fc3e4 ucm: fix possible NULL pointer dereference in uc_mgr_exec()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:58:04 +02:00
Jaroslav Kysela
7fcb1aadd5 ucm: find_exec() - fix memory leak (dir)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:56:13 +02:00
Jaroslav Kysela
7764e3e621 ucm: fix if_eval_path() - access NULL pointer
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:53:24 +02:00
Jaroslav Kysela
9b71d53bde ucm: fix use after free in if_eval_regex_match()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:52:12 +02:00
Jaroslav Kysela
200d18cda7 ucm: fix error path in execute_cfgsave()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:51:13 +02:00
Jaroslav Kysela
cf3846d460 timer: remove dead code in _snd_timer_hw_open() 2021-06-02 19:50:17 +02:00
Jaroslav Kysela
eabadf545c pcm: softvol - fix early exit in add_tlv_info()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:49:29 +02:00
Jaroslav Kysela
74c6382df6 pcm: remove extra NULL checks in snd_pcm_dshare_open()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:46:58 +02:00
Jaroslav Kysela
01a45aec6f pcm: remove extra NULL checks in snd_pcm_dsnoop_open()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:39:32 +02:00
Jaroslav Kysela
eb95cad4e2 pcm: remove extra NULL checks in snd_pcm_dmix_open()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:37:53 +02:00
Jaroslav Kysela
2fee6af9b6 pcm: direct - fix pcmp error path in _snd_pcm_direct_new()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:35:44 +02:00
Jaroslav Kysela
013ec607db control: remap - fix uninitialized value in parse_map_vindex()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:28:32 +02:00
Jaroslav Kysela
2a1dafdbe5 conf: remove dead code in snd_config_get_card()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:27:27 +02:00
Jaroslav Kysela
9621d0bff2 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>
2021-06-02 11:21:54 +02:00
Jaroslav Kysela
0e4ba2ea8c 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>
2021-06-02 11:09:46 +02:00
Jaroslav Kysela
ddfc32abf5 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>
2021-06-02 08:49:32 +02:00
Jaroslav Kysela
9f16fa5729 Release v1.2.5
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-27 23:30:16 +02:00
Jaroslav Kysela
1e56b1031f 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>
2021-05-27 23:28:20 +02:00
Jaroslav Kysela
c7a939ee31 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>
2021-05-27 22:01:38 +02:00
Jaroslav Kysela
c8f608d674 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>
2021-05-26 17:29:48 +02:00
Chao Song
aa70b19d4c 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>
2021-05-26 10:19:15 +02:00
Jaroslav Kysela
f9bb2487ac include: try to fix the out-of-source-tree build
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 17:13:06 +02:00
Jaroslav Kysela
b0e99e4cfe 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>
2021-05-25 16:43:25 +02:00
Jaroslav Kysela
2c8e31f509 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>
2021-05-25 15:30:45 +02:00
Jaroslav Kysela
6b72840569 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>
2021-05-24 12:14:47 +02:00
Jaroslav Kysela
b623b5dfed conf: snd_config_merge() - substitute non-compound config handles
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-24 12:14:47 +02:00
Jaroslav Kysela
6a944d1b2a conf: snd_config_merge() - merge (concat) correctly arrays
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-24 12:14:45 +02:00
Jaroslav Kysela
e3edbf6e3b conf: return count of items in snd_config_is_array()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-24 09:27:17 +02:00
Jaroslav Kysela
3fd1de5cbe 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>
2021-05-18 16:37:17 +02:00
Jaroslav Kysela
8eaa03b7c9 conf: print quoted string more wisely
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-18 13:17:13 +02:00
Jaroslav Kysela
0ee4642a69 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>
2021-05-18 12:33:43 +02:00
Jaroslav Kysela
225d3aecb6 ucm: libconfig - merge not override items
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-18 11:30:21 +02:00
Jaroslav Kysela
b2b3658fb9 ucm: libconfig parser - fix memory leaks
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-18 11:30:21 +02:00
Jaroslav Kysela
4522e2008f conf: fix snd_config_merge() - merge schema
All child compounds must be traversed and merged.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-18 11:30:15 +02:00
Jaroslav Kysela
d6f9e9f590 control: remap - add no-op when the remapping is not active
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-17 17:03:39 +02:00
Jaroslav Kysela
5e7c507152 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>
2021-05-17 16:49:46 +02:00