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.
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.
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.
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.
Takashi Iwai [Thu, 10 Mar 2022 08:24:12 +0000 (09:24 +0100)]
pcm: direct: Check xrun/suspend before the slave hwptr update
The xrun/suspend may happen at any time and we should check it right
after the slave hwptr update (but before the actual sync_ptr update in
direct pcm side). Otherwise the hwptr value may be screwed and get
unexpected large read/write.
Reported-by: S.J. Wang <shengjiu.wang@nxp.com> Acked-by: Shengjiu Wang <shengjiu.wang@nxp.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Fri, 4 Mar 2022 09:31:08 +0000 (10:31 +0100)]
pcm: direct: Move slave PCM state checks into XRUN check helper
The check of slave PCM state is always done before the client's
recoveries count check, so let's merge them to the common helper.
Also rename the helper function to snd_pcm_direct_check_xrun() as it's
checking both slave and client states now.
Takashi Iwai [Thu, 3 Mar 2022 14:09:19 +0000 (15:09 +0100)]
pcm: direct: Improved suspend/resume support
The current resume handling in PCM direct plugins don't treat multiple
clients properly: once after the slave PCM gets resumed by one
client, the access from others at a later point is seen as already
running although the internal state isn't updated and becomes
inconsistent. This may end up a negative size, which eventually hangs
up.
This patch is an attempt to improve the handling for resume. Now the
suspended state is treated similarly like XRUN; namely, we keep the
slave PCM "recoveries" count that is modified at each time the slave
PCM XRUN happens, so that we can check the inconsistency against the
client's state. As a differentiation to XRUN, we set the highest bit
of recoveries count when the slave stream hits SUSPENDED state. This
bit is referred at comparing with clients, and the client's state is
updated to either XRUN or SUSPENDED depending on this bit.
Along with this change, the actual resume is done in
snd_pcm_direct_slave_recover(), and snd_pcm_direct_resume() rather
calls this internally.
Takashi Iwai [Thu, 3 Mar 2022 14:04:09 +0000 (15:04 +0100)]
pcm: direct: Propagate error code from snd_pcm_direct_client_chk_xrun()
Change the snd_pcm_direct_client_chk_xrun() function to return the
current XRUN state via an error code instead of the state change.
This allows the caller more straightforwardly returning its error, and
also covers the case where XRUN has been set but the function gets
called twice.
Alan Young [Wed, 23 Feb 2022 09:37:40 +0000 (09:37 +0000)]
pcm: rate: fix drain of partial period at end of buffer
In the case that:
* the buffer size is not an integer multiple of the period size, and
* drain must flush a partial period located before the end of the buffer
but without a full period available, where
* these conditions may pertain to the source or slave pcm buffer, and
* because rate conversion is always done on a full period,
it is necessary to check that both a full source period is available
before source pcm buffer wrap and a full slave period is available
before slave pcm buffer wrap in order to use the simple, single-commit
implementation in snd_pcm_rate_commit_area().
The alternative fix would be to change snd_pcm_rate_write_areas1() to
take size and slave_size parameters. This would be more disruptive to
the code base, tricky to get right, and is unnecessary given that
snd_pcm_mmap_commit() only commits the partial period of actually valid
converted samples.
Fixes: 3047f8fa5a3d ("Fix possible problems of playback drain with rate plugin") Signed-off-by: Alan Young <consult.awy@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jaroslav Kysela [Sat, 1 Jan 2022 18:18:25 +0000 (19:18 +0100)]
conf: fix the export of safe_strto* functions from libasound
Only one library should define the safe_strto function. Export it
correctly and add _snd_ prefix to avoid possible clashes with the other
application code.
Fixes: 47252054 ("src/topology/parser.c: drop duplicate safe_strtol_base") Fixes: https://github.com/alsa-project/alsa-lib/pull/208 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/topology/parser.c: drop duplicate safe_strtol_base
The safe_strtol_base() function is defined twice since f547b2e3 ("conf: introduce safe_strtol_base()") and 5fab157a ("topology: do not call strtol directly")
resulting in the following build failure when alsa-utils is built
statically because safe_strtol_base is defined twice.
Jaroslav Kysela [Mon, 29 Nov 2021 13:57:29 +0000 (14:57 +0100)]
conf: add possibility to evaluate simple integer math expressions
It is useful to use the math expressions for the values in configuration.
This patch adds a simple expression evaluation routines (integer only).
The syntax is simplified unix shell (bash) style.
Examples:
$[1 + 1]
$[$[2 + 2] / $var1]
$[0xa0 | 0x05]
As a bonus, the variable substitutions were more abstracted.
The function snd_config_expand_custom() was introduced to be used
for example in the topology pre-precessor.
It seems that we have have some users for this very specific function.
Mark it deprecated and keep the softvol implementation separate,
so we can remove this function easily in future.
Fixes: https://github.com/alsa-project/alsa-lib/issues/186 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav Kysela [Thu, 28 Oct 2021 09:48:54 +0000 (11:48 +0200)]
ucm: suppress the no device (no UCM card) errors on request
It seems that users are confused when the UCM configuration
is not ready for the particular hardware. Actually, we don't
allow a fine grained message classification in alsa-lib and
UCM API. Allow suppression of this specific type of messages
on the application request (typically alsactl).
Jaroslav Kysela [Wed, 22 Sep 2021 09:05:23 +0000 (11:05 +0200)]
rawmidi: rename enum snd_rawmidi_framing to snd_rawmidi_read_mode
We hide the internal data transfers using the data frames. Rename
the snd_rawmidi_framing enum to snd_rawmidi_read_mode to make
API more straight and understandable.
Jaroslav Kysela [Tue, 24 Aug 2021 09:36:30 +0000 (11:36 +0200)]
rawmidi: define more abstract API for the timestamp reads
The frame structure is a bit internal thing for the kernel
data transfer implementation. Introduce snd_rawmidi_tread()
function which is straight for the application usage and hides
the framing data transfers (kernel space API).
The current code implements the read cache and does the merging
of the frame reads with the similar timestamps (opposite
to the kernel data split for big chunks).
If the application wants to use super-duper-lighting-fast reads,
the snd_rawmidi_read() may be used, but the structure must be
defined on it's own, because this mechanism is not preferred
and unsupported.
Sava Jakovljev [Mon, 5 Jul 2021 18:28:34 +0000 (20:28 +0200)]
pcm: multi plugin - adjust appl_ptr on rewind/forward operations
When doing rewind or forward operations, application pointer needs to
be properly adjusted, in the same way when doing commit/write
operations.
Fixes: https://github.com/alsa-project/alsa-lib/pull/161 Signed-off-by: Sava Jakovljev <sava.jakovljev@teufel.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Henrik Enquist [Wed, 7 Jul 2021 19:10:16 +0000 (21:10 +0200)]
pcm: add a note about return values of snd_pcm_state()
Fixes: https://github.com/alsa-project/alsa-lib/pull/162 Signed-off-by: Henrik Enquist <henrik.enquist@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>