]> git.alsa-project.org Git - alsa-lib.git/log
alsa-lib.git
2 years agoucm: fix geti() macro - return zero on success
Jaroslav Kysela [Sun, 15 Jan 2023 17:57:56 +0000 (18:57 +0100)]
ucm: fix geti() macro - return zero on success

Fixes: c083417b ("ucm: simplify and fix the previous patch (geti)")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: simplify and fix the previous patch (geti)
Jaroslav Kysela [Sun, 15 Jan 2023 17:32:20 +0000 (18:32 +0100)]
ucm: simplify and fix the previous patch (geti)

Use macro to maintain only one code. The status may be 0 or 1 - handle
both values correctly.

Also, fix the possible memory leak in snd_use_case_geti() - string
str should be freed even when the error is returned.

Fixes: 436cd5b6 ("ucm: add existence checks to geti calls")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: add existence checks to geti calls
Curtis Malainey [Fri, 13 Jan 2023 21:21:55 +0000 (13:21 -0800)]
ucm: add existence checks to geti calls

Right now in snd_use_case_geti you cannot tell if the item being queried
exists or not when being checked. This also means the only way to check
for the existence of something in the client of the library is to
iterate over the list of mods/devs even if we know exactly the name we
are looking for. We have functions that do exactly this internally so
lets return this information in a logical fashion through geti.

Also clean up some trailing white space nearby.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix possible memory leak in execute_sysw()
Jaroslav Kysela [Thu, 5 Jan 2023 14:42:31 +0000 (15:42 +0100)]
ucm: fix possible memory leak in execute_sysw()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: rate: fix last_commit_ptr boundary wrapping
Alan Young [Fri, 30 Dec 2022 16:48:14 +0000 (16:48 +0000)]
pcm: rate: fix last_commit_ptr boundary wrapping

Wrap last_commit_ptr using boundary. Was just wrapped to 0, which is
correct only if the buffer size, and hence the boundary, is an integer
multiple of the period size.

Fixes: 467d69c5bc1 ("Fix CPU hog with combination of rate plugin")
Fixes: 29041c52207 ("fix infinite draining of the rate plugin in SND_PCM_NONBLOCK mode")
Link: https://lore.kernel.org/alsa-devel/20221230164814.901457-1-consult.awy@gmail.com/
Signed-off-by: Alan Young <consult.awy@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: route/softvol use snd_config_get_ireal vs get_real to handle also integers
Jaroslav Kysela [Tue, 13 Dec 2022 09:31:32 +0000 (10:31 +0100)]
pcm: route/softvol use snd_config_get_ireal vs get_real to handle also integers

Link: https://lore.kernel.org/alsa-devel/f9a7ad6a256d4ad7a31642dcf875d436@axis.com/
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoalsa-lib: conf - fix possible use-after-free in get_char_skip_comments
Jaroslav Kysela [Wed, 7 Dec 2022 13:54:30 +0000 (14:54 +0100)]
alsa-lib: conf - fix possible use-after-free in get_char_skip_comments

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: execute_sysw - fix possible use-after-free
Jaroslav Kysela [Wed, 7 Dec 2022 13:49:48 +0000 (14:49 +0100)]
ucm: execute_sysw - fix possible use-after-free

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotopology: ctl - remove the wrong (debug) code
Jaroslav Kysela [Tue, 29 Nov 2022 18:42:13 +0000 (19:42 +0100)]
topology: ctl - remove the wrong (debug) code

This code was commited by mistake. It was used for testing
of ALSA_PCM_OLD_HW/SW_PARAMS_API.

BugLink: https://github.com/thesofproject/sof/issues/6667
Related-to: 78b20e3c ("test: latency - use snd_pcm_format_physical_width()")
Reported-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotest: latency - --policy option - allow using SCHED_OTHER
Jaroslav Kysela [Thu, 24 Nov 2022 09:55:32 +0000 (10:55 +0100)]
test: latency - --policy option - allow using SCHED_OTHER

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotest: latency - add --policy option to allow using SCHED_FIFO
Jaroslav Kysela [Thu, 24 Nov 2022 07:33:47 +0000 (08:33 +0100)]
test: latency - add --policy option to allow using SCHED_FIFO

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotest: latency - usleep should not be used in the block mode
Jaroslav Kysela [Wed, 23 Nov 2022 18:45:15 +0000 (19:45 +0100)]
test: latency - usleep should not be used in the block mode

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotest: latency - add -y option (I/O usleep)
Jaroslav Kysela [Wed, 23 Nov 2022 16:56:20 +0000 (17:56 +0100)]
test: latency - add -y option (I/O usleep)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: handle empty string also for ${env:} substitution
Jaroslav Kysela [Tue, 22 Nov 2022 08:59:04 +0000 (09:59 +0100)]
ucm: handle empty string also for ${env:} substitution

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: clarify set_defaults calls
Jaroslav Kysela [Tue, 15 Nov 2022 16:25:59 +0000 (17:25 +0100)]
ucm: clarify set_defaults calls

- do full reset in snd_use_case_mgr_reload

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agolatency: add timestamps to the POS lines
Jaroslav Kysela [Mon, 14 Nov 2022 20:26:39 +0000 (21:26 +0100)]
latency: add timestamps to the POS lines

- remove first capture pos line
- measure the snd_pcm_start() call, too

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotest: latency - add more realtime tests
Jaroslav Kysela [Mon, 14 Nov 2022 19:42:10 +0000 (20:42 +0100)]
test: latency - add more realtime tests

Add '-x' and '-X' tests and '-U' - I/O update mode based
on the system timing.

It may be required to check the position updates for the specific hardware.
Print the real time / stream time differences.

Also include code to make valgrind happy (including the wrong memory
llocation for the stream buffer).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: fix the fast_ops pcm argument for fast_ops
Jaroslav Kysela [Mon, 14 Nov 2022 13:34:46 +0000 (14:34 +0100)]
pcm: fix the fast_ops pcm argument for fast_ops

The fast_ops callback invocation must always pass the fast_op_arg
as the pcm argument. Plugins expect that.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agotest: latency - use snd_pcm_format_physical_width()
Jaroslav Kysela [Mon, 14 Nov 2022 11:36:04 +0000 (12:36 +0100)]
test: latency - use snd_pcm_format_physical_width()

We need to allocate frames using the physical size not
the sample bit size.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoinclude: alsa-symbols.h - use newer gcc symver function attribute
Jaroslav Kysela [Wed, 9 Nov 2022 14:04:06 +0000 (15:04 +0100)]
include: alsa-symbols.h - use newer gcc symver function attribute

Use the symver function attribute for newer gccs (version 11+).
The symver function attribute was introduced probably earlier
(gcc-10). We can fix that on demand later.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoinclude: pcm_old.h - use a macro for the symbol versioning
Jaroslav Kysela [Wed, 9 Nov 2022 13:37:45 +0000 (14:37 +0100)]
include: pcm_old.h - use a macro for the symbol versioning

Make the header file more readable and error prone.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: rate - correct the previous fix for snd_pcm_rate_may_wait_for_avail_min()
Jaroslav Kysela [Wed, 9 Nov 2022 08:31:34 +0000 (09:31 +0100)]
pcm: rate - correct the previous fix for snd_pcm_rate_may_wait_for_avail_min()

The previous fix in aa4f56c3 was not correct. The root of the cause is
implementation in snd_pcm_may_wait_for_avail_min() inline function
where the improper pcm argument is passed to the fast_ops function.

Fixes: aa4f56c3 ("pcm: rate - fix the crash in snd_pcm_rate_may_wait_for_avail_min()")
Fixes: d9dbb57b ("pcm: rate - rewrite the may_wait_for_avail_min callback for the rate plugin")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: rate - fix the crash in snd_pcm_rate_may_wait_for_avail_min()
Jaroslav Kysela [Wed, 9 Nov 2022 07:11:42 +0000 (08:11 +0100)]
pcm: rate - fix the crash in snd_pcm_rate_may_wait_for_avail_min()

The pcm argument passed to the conversion function in
snd_pcm_plugin_may_wait_for_avail_min_conv() should be
pcm->fast_op_arg.

Test command: arecord -Dplughw:x -r12000 -c2 -fS16_LE -M temp.wav

Fixes: d9dbb57b ("pcm: rate - rewrite the may_wait_for_avail_min callback for the rate plugin")
BugLink: https://lore.kernel.org/alsa-devel/1667793912-18957-1-git-send-email-shengjiu.wang@nxp.com/
Fixes: https://github.com/alsa-project/alsa-lib/issues/282
Reported-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: fix enhanced ID parsing in snd_use_case_parse_ctl_elem_id()
Jaroslav Kysela [Wed, 2 Nov 2022 14:01:56 +0000 (15:01 +0100)]
ucm: fix enhanced ID parsing in snd_use_case_parse_ctl_elem_id()

Reported-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoRelease v1.2.8 v1.2.8
Jaroslav Kysela [Mon, 24 Oct 2022 08:17:27 +0000 (10:17 +0200)]
Release v1.2.8

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agocontrol: namehint - do not support 'card' devices
Jaroslav Kysela [Mon, 24 Oct 2022 08:02:51 +0000 (10:02 +0200)]
control: namehint - do not support 'card' devices

The card: devices do not exist. Do not return -ENOENT,
but -EINVAL in this case.

Fixes: https://github.com/alsa-project/alsa-lib/issues/277
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoucm: do not handle multiple Syntax field updates
Jaroslav Kysela [Thu, 20 Oct 2022 17:37:32 +0000 (19:37 +0200)]
ucm: do not handle multiple Syntax field updates

It is useful to include a toplevel configuration file from another
toplevel configuration file. Ignore the further Syntax updates
(assuming the that the parent knows what to do).

Also, parse the Syntax field in own function.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agocontrol: eld - skip trailing spaces
Jaroslav Kysela [Tue, 18 Oct 2022 13:53:40 +0000 (15:53 +0200)]
control: eld - skip trailing spaces

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agopcm: rate: fix the crash for the partial period copy
Jaroslav Kysela [Mon, 17 Oct 2022 11:52:51 +0000 (13:52 +0200)]
pcm: rate: fix the crash for the partial period copy

The size argument in snd_pcm_rate_commit_area can be smaller
than cont in drain. Return the original code. It should
not make things worse. Perhaps, we can fill the rest of
the period with silence in this case.

Fixes: https://github.com/alsa-project/alsa-lib/issues/274
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoRemove non existent SPDIF output on ThinkPad USB-C Dock Gen2
Swapnil Devesh [Sat, 27 Aug 2022 08:03:53 +0000 (13:33 +0530)]
Remove non existent SPDIF output on ThinkPad USB-C Dock Gen2

Fixes: https://github.com/alsa-project/alsa-lib/pull/268
Signed-off-by: Swapnil Devesh <sid.swapnildevesh@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoadd DragonFlyBSD build support (except test/)
SASANO Takayoshi [Wed, 13 Jul 2022 12:36:59 +0000 (21:36 +0900)]
add DragonFlyBSD build support (except test/)

due to undefined reference to 'environ' error, ucm_exec.c uses workaround.

Fixes: https://github.com/alsa-project/alsa-lib/pull/250
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoadd FreeBSD build support (except test/)
SASANO Takayoshi [Tue, 12 Jul 2022 11:37:44 +0000 (20:37 +0900)]
add FreeBSD build support (except test/)

Note: NetBSD and OpenBSD has both <endian.h> and <sys/endian.h>

Fixes: https://github.com/alsa-project/alsa-lib/pull/250
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agoadd NetBSD/OpenBSD build support (except test/)
SASANO Takayoshi [Sun, 10 Jul 2022 02:03:00 +0000 (11:03 +0900)]
add NetBSD/OpenBSD build support (except test/)

Fixes: https://github.com/alsa-project/alsa-lib/pull/250
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agodoc: ucm - more volume notes
Jaroslav Kysela [Fri, 16 Sep 2022 17:24:27 +0000 (19:24 +0200)]
doc: ucm - more volume notes

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2 years agodoc: ucm - add sequence graphs
Jaroslav Kysela [Fri, 16 Sep 2022 17:02:16 +0000 (19:02 +0200)]
doc: ucm - add sequence graphs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: hw_params - copy periods and buffer_time to the local variable
Jaroslav Kysela [Thu, 18 Aug 2022 09:23:42 +0000 (11:23 +0200)]
pcm: hw_params - copy periods and buffer_time to the local variable

It is expected to return the correct numbers for get_periods and
get_buffer_time requests. Copy the appropriate fields in the
hw_params call.

Fixes: https://github.com/alsa-project/alsa-lib/issues/258
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: fix the dshare delay reporting
Jaroslav Kysela [Tue, 16 Aug 2022 15:21:12 +0000 (17:21 +0200)]
pcm: fix the dshare delay reporting

Pulseaudio uses full ring buffer when the incorrect delay is reported.

BugLink: https://github.com/alsa-project/alsa-ucm-conf/issues/198
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add NULL check for card_name in open
Jaroslav Kysela [Fri, 8 Jul 2022 20:00:34 +0000 (22:00 +0200)]
ucm: add NULL check for card_name in open

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix few memory-leaks in the error paths
Jaroslav Kysela [Fri, 8 Jul 2022 19:56:57 +0000 (21:56 +0200)]
ucm: fix few memory-leaks in the error paths

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct plugins: make three more symbols private to library
Jaroslav Kysela [Fri, 8 Jul 2022 19:44:44 +0000 (21:44 +0200)]
pcm: direct plugins: make three more symbols private to library

Those symbols should not be exported:
snd_pcm_direct_poll_descriptors
snd_pcm_direct_check_xrun
snd_pcm_direct_slave_recover

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRelease v1.2.7.2 v1.2.7.2
Jaroslav Kysela [Fri, 8 Jul 2022 15:34:30 +0000 (17:34 +0200)]
Release v1.2.7.2

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoinclude/sound/type_compat.h: fix include guard
SASANO Takayoshi [Fri, 1 Jul 2022 20:55:11 +0000 (05:55 +0900)]
include/sound/type_compat.h: fix include guard

include/sound/type_compat.h uses #define __TYPE_COMPAT_H but it conflicts
same include guard of include/type_compat.h

now, include/sound/type_compat.h uses #define __SOUND_TYPE_COMPAT_H

this is already done in NetBSD's pkgsrc patch.

(thanks to tsutsui@netbsd.org)

Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix st_mode check for symbolic links
Stephan Gerhold [Fri, 8 Jul 2022 12:50:54 +0000 (14:50 +0200)]
ucm: fix st_mode check for symbolic links

The file type in the st_mode field is not encoded as unique bits but as
an enumerator. Checking if some bits of S_IFLNK are set does not work
correctly because it happens to evaluate to true for regular files as
well.

The POSIX man page suggests using the following approach to check
the file type:

    if ((sb.st_mode & S_IFMT) == S_IFLNK)

Alternatively, there is a S_ISLNK() macro to check this more easily.

Make use of the latter so that readlink() is only called on actual
symbolic links and not regular files. This makes audio work again
with slightly older alsa-ucm-conf versions or alternative top-level
ucm.conf configurations that do not make use of symlinks.

Fixes: d6adde0e ("ucm: top-level path - set directory from symlink")
Fixes: https://github.com/alsa-project/alsa-lib/pull/249
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agomixer: add documentation about postcondition of removal event processing
Takashi Sakamoto [Mon, 27 Jun 2022 00:24:29 +0000 (09:24 +0900)]
mixer: add documentation about postcondition of removal event processing

PulseAudio and PipeWire seems to appear including careless code to
process events of mixer element in implementation of mixer class.

 * https://lore.kernel.org/alsa-devel/YrbxZ2b+3rIdi7Ut@workstation/

They register own implementation of mixer class. At addition event,
they attach own mixer element into hcontrol element. However at removal
event, they never detach the mixer element from hcontrol element. They
hit assertion in mixer API internal due to unsatisfied postcondition.

This commit adds documentation about postcondition of removal event
processing so that developer for implementation of mixer class easily
realize the way to satisfy the postcondition.

Fixes: https://github.com/alsa-project/alsa-lib/pull/244
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: share plugin: handle -EINTR
Jaroslav Kysela [Mon, 27 Jun 2022 11:36:12 +0000 (13:36 +0200)]
pcm: share plugin: handle -EINTR

Fixes: https://github.com/alsa-project/alsa-lib/pull/242
Fixes: b97047b4 ("pcm: share plugin: return error if socket read or write call fails")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: share plugin: return error if socket read or write call fails
Tomohiro IKEDA [Sat, 18 Jun 2022 22:05:17 +0000 (07:05 +0900)]
pcm: share plugin: return error if socket read or write call fails

Fixes: https://github.com/alsa-project/alsa-lib/pull/242
Signed-off-by: Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: fix the params_mode check condition in snd_rawmidi_tread()
Jaroslav Kysela [Sun, 26 Jun 2022 14:07:56 +0000 (16:07 +0200)]
rawmidi: fix the params_mode check condition in snd_rawmidi_tread()

The condition should be obviously reversed.

Reported-by: Mark ZurSchmiede <zursch@gmail.com>
Fixes: 5ac61983 ("rawmidi: allow timestamp reads only for the appropriate read mode")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRelease v1.2.7.1 v1.2.7.1
Jaroslav Kysela [Fri, 17 Jun 2022 09:42:05 +0000 (11:42 +0200)]
Release v1.2.7.1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agooutput: include stdarg.h
Bernd Kuhls [Sat, 11 Jun 2022 17:12:19 +0000 (19:12 +0200)]
output: include stdarg.h

Fixes a build error with alsa-utils when build with a uClibc toolchain:

alsa-utils/host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/alsa/output.h:75:66:
 error: unknown type name ‘va_list’
   75 | int snd_output_vprintf(snd_output_t *output, const char *format, va_list args);
      |                                                                  ^~~~~~~
alsa-utils/host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/alsa/output.h:1:1:
 note: ‘va_list’ is defined in header ‘<stdarg.h>’; did you forget to ‘#include <stdarg.h>’?

Fixes: https://github.com/alsa-project/alsa-lib/pull/237
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: dmix - Add error handler for `fgets`
Tomohiro IKEDA [Tue, 14 Jun 2022 23:45:19 +0000 (08:45 +0900)]
pcm: dmix - Add error handler for `fgets`

Fixes: https://github.com/alsa-project/alsa-lib/pull/238
Signed-off-by: Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: list also hardware configs (hw:X) in uc_mgr_scan_master_configs() fcn
Jaroslav Kysela [Thu, 16 Jun 2022 16:03:03 +0000 (18:03 +0200)]
ucm: list also hardware configs (hw:X) in uc_mgr_scan_master_configs() fcn

BugLink: https://github.com/alsa-project/alsa-ucm-conf/issues/168
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: eld - fix the decoding for older hw
Jaroslav Kysela [Mon, 6 Jun 2022 10:11:24 +0000 (12:11 +0200)]
control: eld - fix the decoding for older hw

It seems that the monitor name is not always present in the
ELD structure. Add asterisk suffix to notify user about
the monitor present for this case.

Thanks goes to Bernhard Rosenkränzer <bero@lindev.ch> for the report.

Fixes: https://github.com/alsa-project/alsa-lib/pull/233
Fixes: https://github.com/alsa-project/alsa-lib/pull/234
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: Use ino64_t to save and compare inode numbers
Simon McVittie [Wed, 25 May 2022 11:33:42 +0000 (12:33 +0100)]
conf: Use ino64_t to save and compare inode numbers

On 32-bit platforms when not using the large-file-support ABI,
struct stat64 contains ino64_t which is 64-bit, while ino_t is only
32-bit.

snd_config_update_r() checks whether a file has been replaced by saving
the ino member of a struct stat64 and comparing it with a previously-saved
inode number. On 32-bit platforms, assigning the 64-bit member of struct
stat64 to a 32-bit member of struct finfo will truncate it modulo 1<<32,
which could conceivably result in libasound not reloading configuration
when it should (although the inode number space is large enough to make
this failure mode highly unlikely).

Fixes: https://github.com/alsa-project/alsa-lib/pull/231
Signed-off-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRelease v1.2.7 v1.2.7
Jaroslav Kysela [Tue, 31 May 2022 14:25:33 +0000 (16:25 +0200)]
Release v1.2.7

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix the reload call (snd_use_case_mgr_reload)
Jaroslav Kysela [Fri, 27 May 2022 12:28:13 +0000 (14:28 +0200)]
ucm: fix the reload call (snd_use_case_mgr_reload)

Handle the local configuration and macros trees properly.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: implement disdevall sequence command
Jaroslav Kysela [Tue, 24 May 2022 14:28:21 +0000 (16:28 +0200)]
ucm: implement disdevall sequence command

It is useful to run all disable sequences for all
UCM devices in a verb to ensure the valid, expected
initial state.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agouse-case.h: add Channels/ChannelPos values to the documentation
Jaroslav Kysela [Tue, 24 May 2022 12:24:10 +0000 (14:24 +0200)]
use-case.h: add Channels/ChannelPos values to the documentation

We have use cases, where the channel split is required. We
can use alsa-lib plugins for this job, but some sound servers
or applications may want to do the split themselves.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix memory leak in the error path (Include)
Jaroslav Kysela [Mon, 23 May 2022 11:29:36 +0000 (13:29 +0200)]
ucm: fix memory leak in the error path (Include)

The included configuration tree must be freed
in the error path, too.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: hw: change rate range syntax
Jaroslav Kysela [Fri, 20 May 2022 16:37:01 +0000 (18:37 +0200)]
pcm: hw: change rate range syntax

Allow three configuration types:

  rate 48000 # single rate
  rate [ 48000 ] # single rate (2nd)
  rate [ 44100 48000 ] # range

Fixes: https://github.com/alsa-project/alsa-lib/pull/191
Fixes: ac04cb63 ("hw: add "min_rate" and "max_rate" as alternatives to single "rate" parameter")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: hw: add "min_rate" and "max_rate" as alternatives to single "rate" parameter
Benedek Kupper [Wed, 20 Oct 2021 20:28:23 +0000 (22:28 +0200)]
pcm: hw: add "min_rate" and "max_rate" as alternatives to single "rate" parameter

Fixes: https://github.com/alsa-project/alsa-lib/pull/191
Signed-off-by: Benedek Kupper <benedek.kupper@streamunlimited.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconfigure: remove --with-lfs option, but keep the autodetection code
Jaroslav Kysela [Fri, 20 May 2022 12:35:11 +0000 (14:35 +0200)]
configure: remove --with-lfs option, but keep the autodetection code

Fixes: a513e65e ("configure: add --with-lfs option")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: rate - rewrite the may_wait_for_avail_min callback for the rate plugin
Jaroslav Kysela [Fri, 20 May 2022 08:47:43 +0000 (10:47 +0200)]
pcm: rate - rewrite the may_wait_for_avail_min callback for the rate plugin

Shuffle the code to avoid special conditions using the plugin type
in the generic plugin code. The rate plugin has the own
may_wait_for_avail_min callback implementation now.

Fixes: d21e0e01 ("pcm: plugin - fix avail_min calculation on rate plugin")
Fixes: https://github.com/alsa-project/alsa-lib/pull/218
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: plugin - fix avail_min calculation on rate plugin
Andreas Pape [Tue, 22 Mar 2022 11:45:37 +0000 (12:45 +0100)]
pcm: plugin - fix avail_min calculation on rate plugin

commit 88e4ae27ff1f669d introduced a dynamic recalculation of the slave's
avail_min value.
The calculated avail_min setting did not take into account, that the avail_min value
depends on the used sampling rate and must be adapted accordingly
if the slave is using a different sampling rate.
That leads to too large/too small calculated avail_min settings and inaccurate
period wake-up events if a rate converter plugin is used.

This patch is adapting the avail_min calculation to consider a different
sampling rate between actual pcm and it's slave.

Fixes: https://github.com/alsa-project/alsa-lib/pull/218
Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agomixer: simple module: python 3.10 PyTuple_SET_ITEM() fix
Graham Inggs [Thu, 20 Jan 2022 07:29:37 +0000 (09:29 +0200)]
mixer: simple module: python 3.10 PyTuple_SET_ITEM() fix

Make code compatible with Python 3.10 As noted in bpo-30459,
PyTuple_SET_ITEM() does not return a value.

Link: https://bugs.python.org/issue30459
Fixes: https://github.com/alsa-project/alsa-lib/pull/210
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: dmix: fix wrong scaling in 32bits pcm mixing
Katsuhiro Suzuki [Thu, 28 Apr 2022 16:17:27 +0000 (01:17 +0900)]
pcm: dmix: fix wrong scaling in 32bits pcm mixing

Generic mixing function for 32bits pcm has used 8bits right shift for
pre-scaling. But this is generating wrong result if pcm data is
negative value because return value type of bswap_32() is unsigned int.

This patch adds type cast bswap_32() result to signed int.

Fixes: https://github.com/alsa-project/alsa-lib/pull/222
Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconfigure: add --with-lfs option
Jaroslav Kysela [Fri, 20 May 2022 07:52:54 +0000 (09:52 +0200)]
configure: add --with-lfs option

We are forcibly use the LFS (64-bit) calls in the source now. Add a new
check to the configure script and use compatibility defines when those
calls are not available for a reason.

Fixes: https://github.com/alsa-project/alsa-lib/pull/223
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: ladspa - Use LFS calls (readdir64)
Jaroslav Kysela [Thu, 19 May 2022 16:37:46 +0000 (18:37 +0200)]
pcm: ladspa - Use LFS calls (readdir64)

Continue the work in commit ba86ac55 ("conf: Use LFS calls when reading
config files") and fix the PCM LADSPA code, too.

Fixes: https://github.com/alsa-project/alsa-lib/pull/223
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: Use LFS calls (stat, scandir)
Jaroslav Kysela [Thu, 19 May 2022 15:37:46 +0000 (17:37 +0200)]
ucm: Use LFS calls (stat, scandir)

Continue the work in commit ba86ac55 ("conf: Use LFS calls when reading
config files") and fix the UCM code, too.

Fixes: https://github.com/alsa-project/alsa-lib/pull/223
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: Use LFS calls when reading config files
Sebastian Krzyszkowiak [Thu, 28 Apr 2022 20:46:56 +0000 (22:46 +0200)]
conf: Use LFS calls when reading config files

Although at first glance it doesn't seem useful to support config
files larger than 2GB, LFS also influences inode size. Without this,
32-bit libasound may be unable to read config files on filesystems
with 64-bit inodes, such as Btrfs or NFS.

Fixes: https://github.com/alsa-project/alsa-lib/pull/223
Signed-off-by: Sebastian Krzyszkowiak <dos@dosowisko.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: main - fix the compilation error (signess)
Jaroslav Kysela [Fri, 20 May 2022 07:22:33 +0000 (09:22 +0200)]
ucm: main - fix the compilation error (signess)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agogitcompile: fix 32 bit compilation support
Jaroslav Kysela [Fri, 20 May 2022 06:46:43 +0000 (08:46 +0200)]
gitcompile: fix 32 bit compilation support

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: eld - add missing ctype.h header inclusion
Jaroslav Kysela [Thu, 19 May 2022 16:00:15 +0000 (18:00 +0200)]
control: eld - add missing ctype.h header inclusion

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: fix for the unitialized write buffer
Jaroslav Kysela [Thu, 19 May 2022 15:35:08 +0000 (17:35 +0200)]
pcm: fix for the unitialized write buffer

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: vc4-hdmi: use a proper hdmi pcm, fix broken default pcm
Matthias Reichl [Sat, 30 Apr 2022 14:28:45 +0000 (16:28 +0200)]
conf: vc4-hdmi: use a proper hdmi pcm, fix broken default pcm

Userspace expects to see a HDMI pcm, so remove the somewhat broken
front and iec958 pcms and add a proper hdmi pcm instead.

The hdmi pcm supports HD/HBR audio passthrough and relays the IEC958
status bits on to the kernel driver so it can switch to HBR audio
packets if needed. The control hook is marked optional because kernels
before 5.14 didn't expose the IEC958 controls.

The default pcm never worked as dmix doesn't support the iec958 format.
So drop dmix, only use plug and softvol, and use the hdmi pcm for
iec958 formatting.

Fixes: https://github.com/alsa-project/alsa-lib/issues/229
Link: https://lore.kernel.org/alsa-devel/20220430142845.229409-1-hias@horus.com/
Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoremove .travis.yml (using github actions)
Jaroslav Kysela [Thu, 19 May 2022 10:49:49 +0000 (12:49 +0200)]
remove .travis.yml (using github actions)

Fixes: https://github.com/alsa-project/alsa-lib/pull/226
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoREADME: Add link to GitHub Actions
Tomohiro IKEDA [Sun, 15 May 2022 01:05:11 +0000 (10:05 +0900)]
README: Add link to GitHub Actions

Fixes: https://github.com/alsa-project/alsa-lib/pull/225
From: Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agogithub actions: move to checkout@v3
Jaroslav Kysela [Thu, 19 May 2022 09:46:49 +0000 (11:46 +0200)]
github actions: move to checkout@v3

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro - make argument names shorter
Jaroslav Kysela [Thu, 19 May 2022 09:27:37 +0000 (11:27 +0200)]
ucm: macro - make argument names shorter

It seems that the use the macro name as the variable prefix is too large.
Use just two underscores as prefix for the macro arguments to make
macro definitions more readable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: doc - describe variants, minor corrections
Jaroslav Kysela [Thu, 19 May 2022 08:18:38 +0000 (10:18 +0200)]
ucm: doc - describe variants, minor corrections

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: implement enadev2 and disdev2 sequence commands
Jaroslav Kysela [Thu, 19 May 2022 08:08:48 +0000 (10:08 +0200)]
ucm: implement enadev2 and disdev2 sequence commands

It may be useful to call the sequences from devices from
the verb sequences or another device sequences.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add support for verb variants
Jaroslav Kysela [Wed, 18 May 2022 11:10:35 +0000 (13:10 +0200)]
ucm: add support for verb variants

The bellow configuration example creates two verbs ("HiFi" and "HiFi 7+1")
with different playback channels for the "Speaker" device.

SectionUseCase."HiFi" {
        File "HiFi.conf"
        Variant."HiFi" {
Comment "Default"
}
Variant."HiFi 7+1" {
Comment "HiFi 7.1"
         }
}

SectionDevice."Speaker" {
Value {
PlaybackChannels 2
}
Variant."HiFi 7+1".Value {
PlaybackChannels 8
}
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: set SYNTAX_VERSION_MAX to 6
Jaroslav Kysela [Wed, 18 May 2022 06:53:34 +0000 (08:53 +0200)]
ucm: set SYNTAX_VERSION_MAX to 6

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: move macros and evali substitution to Syntax 6
Jaroslav Kysela [Wed, 18 May 2022 06:45:33 +0000 (08:45 +0200)]
ucm: move macros and evali substitution to Syntax 6

There should be printed an error when the new configuration
blocks are used with the older alsa-lib.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro - add deep call protection (recursion)
Jaroslav Kysela [Tue, 17 May 2022 17:25:20 +0000 (19:25 +0200)]
ucm: macro - add deep call protection (recursion)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro call inplace evaluate inside macro
Jaroslav Kysela [Tue, 17 May 2022 17:21:22 +0000 (19:21 +0200)]
ucm: macro call inplace evaluate inside macro

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro - fix the error message, print id
Jaroslav Kysela [Tue, 17 May 2022 16:19:44 +0000 (18:19 +0200)]
ucm: macro - fix the error message, print id

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: return empty string for undefined "open" variables (arguments)
Jaroslav Kysela [Tue, 17 May 2022 12:37:39 +0000 (14:37 +0200)]
ucm: return empty string for undefined "open" variables (arguments)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: allow '-' prefix to avoid errors when the variable is not defined
Jaroslav Kysela [Tue, 17 May 2022 12:35:51 +0000 (14:35 +0200)]
ucm: allow '-' prefix to avoid errors when the variable is not defined

It may be useful to check if variable is not defined.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: allow passing variables through ucm open string
Jaroslav Kysela [Mon, 16 May 2022 11:16:01 +0000 (13:16 +0200)]
ucm: allow passing variables through ucm open string

It is useful to pass information like application capabilities
to the UCM configuration parser. Those variables are prefixed
with '@' for the configuration files.

An example:

   "<<<v1='a b c',x=12>>>hw:1"

Variables can substituted in the configuration:

   "${var:@v1}" -> "a b c"
   "${var:@x}" -> 12

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agouse-case.h: add SND_USE_CASE_DEV_DIRECT define
Jaroslav Kysela [Sat, 14 May 2022 14:20:29 +0000 (16:20 +0200)]
use-case.h: add SND_USE_CASE_DEV_DIRECT define

It may be useful to define the devices without channel remapping
(e.g. ProAudio devices).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: implement MacroDefine and Macro subtree evaluation
Jaroslav Kysela [Fri, 13 May 2022 14:07:38 +0000 (16:07 +0200)]
ucm: implement MacroDefine and Macro subtree evaluation

The arguments are set as temporary variables as /MACRO_NAME/_/ARGUMENT_NAME/.

Example:

  # define new macro MyMacro with arguments ctl_name and ctl_value
  DefineMacro.MyMacro {
    BootSequence [
      cset "name='${var:MyMacro_ctl_name}' ${var:MyMacro_ctl_value}"
    ]
  }

  # instantiate macro for Speaker control (short version)
  Macro.headphone.MyMacro "ctl_name='Speaker Switch',ctl_value=off"

  # instantiate macro for Mic control (second version)
  Macro.mic.MyMacro {
ctl_name "Mic Switch"
ctl_value "off"
  }

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix memory leak in snd_config_substitute() for strings
Jaroslav Kysela [Fri, 13 May 2022 14:19:48 +0000 (16:19 +0200)]
conf: fix memory leak in snd_config_substitute() for strings

When destination type is SND_CONFIG_TYPE_STRING, the old string
must be freed.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: local_config may be NULL (error path)
Jaroslav Kysela [Fri, 13 May 2022 07:32:51 +0000 (09:32 +0200)]
ucm: local_config may be NULL (error path)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add ${evali:} substitution
Jaroslav Kysela [Thu, 12 May 2022 16:33:29 +0000 (18:33 +0200)]
ucm: add ${evali:} substitution

Example:

  Define.var1 2

  LibraryConfig.test.SubstiConfig {
          a "${evali:$var1+1}"
  }

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: shm - initialize write buffer
Jaroslav Kysela [Thu, 5 May 2022 12:37:52 +0000 (14:37 +0200)]
control: shm - initialize write buffer

  ccontrol_shm.c: In function ‘snd_ctl_shm_action’:
  control_shm.c:54:23: error: invalid initializer
     54 |         char buf[1] = 0;
        |                       ^

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: decode HDMI device name from ELD
Jaroslav Kysela [Thu, 5 May 2022 12:28:41 +0000 (14:28 +0200)]
control: decode HDMI device name from ELD

The HDMI drivers set an uniform PCM names. Use ELD (EDID) to obtain
the HDMI device name and send this string to applications for a better
user experience.

Example (aplay -l):

  card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
    Subdevices: 1/1

  vs improved:

  card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [Philips 272P4]
    Subdevices: 1/1

Fixes: https://github.com/alsa-project/alsa-lib/issues/209
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: multi: return correct hwptr and avail from snd_pcm_multi_status()
Yutao Yuan [Wed, 4 May 2022 03:01:34 +0000 (11:01 +0800)]
pcm: multi: return correct hwptr and avail from snd_pcm_multi_status()

Ensure the logic of snd_pcm_multi_status() is consistent with
snd_pcm_multi_avail_update().

Fixes: https://github.com/alsa-project/alsa-lib/pull/224
Fixes: https://github.com/alsa-project/alsa-lib/issues/217
Signed-off-by: Yutao Yuan <infmagic2047reg@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - allow 'off' string for hw_ptr_alignment
Jaroslav Kysela [Tue, 3 May 2022 17:12:03 +0000 (19:12 +0200)]
pcm: direct - allow 'off' string for hw_ptr_alignment

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - cleanups for snd_pcm_direct_reset_slave_ptr()
Jaroslav Kysela [Tue, 3 May 2022 17:08:59 +0000 (19:08 +0200)]
pcm: direct - cleanups for snd_pcm_direct_reset_slave_ptr()

- improve readability
- pass slave hw_ptr as argument - improves the code flow

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - add support for channel bindings in snd_pcm_direct_query_chmaps()
Jaroslav Kysela [Wed, 6 Apr 2022 18:17:58 +0000 (20:17 +0200)]
pcm: direct - add support for channel bindings in snd_pcm_direct_query_chmaps()

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