Commit graph

4532 commits

Author SHA1 Message Date
Jaroslav Kysela
d80616c0c1 ucm: add NULL check for card_name in open
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-07-08 22:00:34 +02:00
Jaroslav Kysela
fc86eafa08 ucm: fix few memory-leaks in the error paths
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-07-08 21:56:57 +02:00
Jaroslav Kysela
378c6a9215 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>
2022-07-08 21:44:50 +02:00
Jaroslav Kysela
27cfa707e3 Release v1.2.7.2
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-07-08 17:34:30 +02:00
SASANO Takayoshi
9230d000b3 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>
2022-07-08 17:32:51 +02:00
Stephan Gerhold
cfd3da47fa 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>
2022-07-08 17:31:58 +02:00
Takashi Sakamoto
351a237b2d 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>
2022-06-27 13:38:25 +02:00
Jaroslav Kysela
65c4796a85 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>
2022-06-27 13:36:36 +02:00
Tomohiro IKEDA
b97047b450 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>
2022-06-27 13:35:44 +02:00
Jaroslav Kysela
917f412484 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>
2022-06-26 16:07:56 +02:00
Jaroslav Kysela
f91c89da99 Release v1.2.7.1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-06-17 11:42:05 +02:00
Bernd Kuhls
92fff4e9d0 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>
2022-06-17 10:25:39 +02:00
Tomohiro IKEDA
ff0db96bbc 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>
2022-06-17 10:23:43 +02:00
Jaroslav Kysela
2d56ff8ded 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>
2022-06-16 18:03:03 +02:00
Jaroslav Kysela
89ee619147 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>
2022-06-06 12:14:24 +02:00
Simon McVittie
87ff5318e3 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>
2022-06-05 10:24:26 +02:00
Jaroslav Kysela
d836146e91 Release v1.2.7
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-31 16:25:33 +02:00
Jaroslav Kysela
0418fd32c7 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>
2022-05-27 14:28:23 +02:00
Jaroslav Kysela
4119e33d28 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>
2022-05-24 16:28:23 +02:00
Jaroslav Kysela
0ba999591b 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>
2022-05-24 14:42:44 +02:00
Jaroslav Kysela
7474518a96 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>
2022-05-23 13:29:39 +02:00
Jaroslav Kysela
7f2d6c3aac 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>
2022-05-20 18:45:23 +02:00
Benedek Kupper
d85c0d8d46 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>
2022-05-20 18:44:42 +02:00
Jaroslav Kysela
a19ce72310 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>
2022-05-20 14:35:11 +02:00
Jaroslav Kysela
d9dbb57b94 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>
2022-05-20 10:50:27 +02:00
Andreas Pape
d21e0e01c6 pcm: plugin - fix avail_min calculation on rate plugin
commit 88e4ae27, ff1f669d 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>
2022-05-20 10:35:45 +02:00
Graham Inggs
ea15c83525 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>
2022-05-20 10:03:10 +02:00
Katsuhiro Suzuki
b62fc061e4 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>
2022-05-20 10:01:10 +02:00
Jaroslav Kysela
a513e65e19 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>
2022-05-20 09:55:17 +02:00
Jaroslav Kysela
4fb83669ef 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>
2022-05-20 09:55:12 +02:00
Jaroslav Kysela
edec439a0c 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>
2022-05-20 09:55:03 +02:00
Sebastian Krzyszkowiak
45b65fa4c1 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>
2022-05-20 09:54:32 +02:00
Jaroslav Kysela
87034d6fc6 ucm: main - fix the compilation error (signess)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-20 09:23:17 +02:00
Jaroslav Kysela
c087bc1e44 gitcompile: fix 32 bit compilation support
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-20 08:47:07 +02:00
Jaroslav Kysela
9b279d11a4 control: eld - add missing ctype.h header inclusion
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-20 08:47:07 +02:00
Jaroslav Kysela
a53c2b25f1 pcm: fix for the unitialized write buffer
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-20 08:47:07 +02:00
Matthias Reichl
df621629d8 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>
2022-05-19 17:13:59 +02:00
Jaroslav Kysela
17ba712447 remove .travis.yml (using github actions)
Fixes: https://github.com/alsa-project/alsa-lib/pull/226
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-19 12:50:03 +02:00
Tomohiro IKEDA
812a772de4 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>
2022-05-19 12:47:24 +02:00
Jaroslav Kysela
06ddcbe88e github actions: move to checkout@v3
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-19 12:38:18 +02:00
Jaroslav Kysela
5f0479762b 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>
2022-05-19 11:27:40 +02:00
Jaroslav Kysela
2389f04541 ucm: doc - describe variants, minor corrections
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-19 10:18:38 +02:00
Jaroslav Kysela
4b66e5fbce 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>
2022-05-19 10:08:50 +02:00
Jaroslav Kysela
c3a5d32ac3 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>
2022-05-18 13:10:35 +02:00
Jaroslav Kysela
25e44bbeb9 ucm: set SYNTAX_VERSION_MAX to 6
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-18 08:53:34 +02:00
Jaroslav Kysela
b45fbeee34 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>
2022-05-18 08:52:50 +02:00
Jaroslav Kysela
55340cf96a ucm: macro - add deep call protection (recursion)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-17 19:25:28 +02:00
Jaroslav Kysela
80ac6f9866 ucm: macro call inplace evaluate inside macro
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-17 19:21:22 +02:00
Jaroslav Kysela
70e2ed50a3 ucm: macro - fix the error message, print id
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-17 18:19:44 +02:00
Jaroslav Kysela
b67257e6fd ucm: return empty string for undefined "open" variables (arguments)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-17 14:37:41 +02:00