Jaroslav Kysela [Wed, 3 May 2023 20:24:47 +0000 (22:24 +0200)]
pcm: hw: fix the silence size setup in drain
The silence size cannot exceed the silence threshold. Move the check
from the manual condition to the common code. This may happen for
small ring buffers (where the 1/10th second is too large).
Suggested-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The application may not require to touch the playback
sample stream for the drain operation at all. In this case,
the application is responsible to setup a silencing mechanism
for the playback or another graceful stop (like using the
rewind operation).
Jaroslav Kysela [Tue, 25 Apr 2023 12:36:19 +0000 (14:36 +0200)]
pcm: hw: introduce SNDRV_PCM_INFO_PERFECT_DRAIN
Handle the driver informing us that it is not necessary to set up
silencing upon playback draining. This will be the case for drivers
which are guaranteed to not read any samples beyond the application
pointer.
Jaroslav Kysela [Fri, 21 Apr 2023 14:12:24 +0000 (16:12 +0200)]
pcm: hw: setup explicit silencing for snd_pcm_drain by default
Some applications may not alignt transfers to the period size
and also the driver developers may not follow the consequeces of the
access beyond valid samples in the playback DMA buffer.
To avoid clicks, fill a little silence at the end of the playback
ring buffer when snd_pcm_drain() is called.
Related: https://lore.kernel.org/alsa-devel/20230420113324.877164-2-oswald.buddenhagen@gmx.de/
Related: https://lore.kernel.org/alsa-devel/20230405201219.2197789-2-oswald.buddenhagen@gmx.de/ Signed-off-by: Jaroslav Kysela <perex@perex.cz>
- rename devname -> pcmdev, it conflicts *BSD <stdlib.h> function
- replace <values.h> -> <limits.h> and fix K&R style related warning
- use config.h to determine include <malloc.h>
- add OpenBSD support and fix printf() warning
- fix warning
Fixes: https://github.com/alsa-project/alsa-lib/pull/298 Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology: Parse ignore_suspend property for dapm widget
snd_soc_tplg_dapm_widget has ignore_suspend field, but there is no way
to set value for it, because we don't parse topology field for it.
Fix this by adding parsing code.
Fixes: https://github.com/alsa-project/alsa-lib/pull/230 Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology: Add decompilation support for ignore_suspend
Previous patch added build support for ignore_suspend, however it should
be also possible to decompile binary back to human readable form and not
lose data.
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cezary Rojewski [Wed, 27 Mar 2019 14:45:04 +0000 (15:45 +0100)]
topology: Parse ignore_suspend flag
XXX_VOICE_WAKEUP also known as 'ignore_suspend' is already processed by
kernel in soc-topology, but there is no way of setting it via topology
file like it's the case for other flags. Fix this by adding it to pcm,
dai and link parsing mechanism.
Signed-off-by: Piotr Maziarz <piotrx.maziarz@intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Sam James [Sun, 30 Oct 2022 18:06:37 +0000 (18:06 +0000)]
utils/alsa.m4: include <stdlib.h> for exit()
Clang 16 makes -Wimplicit-function-declaration an error by default
and it's easier to just explicitly include <stdlib.h> rather
than hope the ALSA headers always have it.
Fixes: https://github.com/alsa-project/alsa-lib/pull/278 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
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>
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>
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.
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>
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).
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
Andreas Pape [Tue, 22 Mar 2022 11:45:37 +0000 (12:45 +0100)]
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>
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>
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>
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>
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.