Commit graph

4532 commits

Author SHA1 Message Date
Jaroslav Kysela
90e25887d2 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.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 14:00:57 +02:00
Jaroslav Kysela
dd9cb31a90 pcm: hw: add drain_silence configuration keyword
# Add silence in drain (-1 = auto /default/, 0 = off, > 0 milliseconds)
  [drain_silence INT]

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 13:56:19 +02:00
Jaroslav Kysela
2115cdb4dc 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>
2023-05-03 13:50:56 +02:00
Maxython
b40fcda7fb compilation: fix ANDROID -> __ANDROID__ define detection
Fixes: https://github.com/alsa-project/alsa-lib/pull/301/
Signed-off-by: Maxython <mixython@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-02 14:52:27 +02:00
Jaroslav Kysela
a8afb0449c pcm: avoid endless loop in snd_pcm_sw_params_default()
BugLink: https://lore.kernel.org/alsa-devel/167734349294.22.1388671545195719262@mailman-web.alsa-project.org/
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-25 18:03:46 +01:00
SASANO Takayoshi
44705e3a20 test: BSD-like fixes
- 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>
2023-02-03 13:22:04 +01:00
SASANO Takayoshi
3b4cdbdf19 type_compat.h: use ESPIPE instead of EPIPE when ESTRPIPE not defined
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>
2023-02-03 13:21:54 +01:00
SASANO Takayoshi
fea9fc2298 configure: avoid libdl detecion on *BSD
NetBSD and OpenBSD has no libdl
FreeBSD and DragonFlyBSD has libdl but dummy

These OSes are no need to use -ldl to use dlopen()

Fixes: https://github.com/alsa-project/alsa-lib/pull/290
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 19:00:59 +01:00
Gunnar Dibbern
2f9bbefb8d pcm: hw - fix return code checking in snd_pcm_hw_hw_refine
The isse was introduced in commit 7f2d6c3

Fixes: 7f2d6c3a ("pcm: hw: change rate range syntax")
Fixes: https://github.com/alsa-project/alsa-lib/issues/271
Fixes: https://github.com/alsa-project/alsa-lib/pull/293
Signed-off-by: Gunnar Dibbern <gunnar.dibbern@lht.dlh.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 18:58:51 +01:00
Amadeusz Sławiński
e11ea20645 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>
2023-01-29 18:55:53 +01:00
Amadeusz Sławiński
e824f70d62 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>
2023-01-29 18:55:29 +01:00
Cezary Rojewski
d72da154a3 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>
2023-01-29 18:55:29 +01:00
Sam James
1fc1c1b7dc 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>
2023-01-29 18:51:54 +01:00
Jaroslav Kysela
496c4e031b 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>
2023-01-15 18:57:56 +01:00
Jaroslav Kysela
c083417b72 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>
2023-01-15 18:37:40 +01:00
Curtis Malainey
436cd5b6d0 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>
2023-01-15 17:57:13 +01:00
Jaroslav Kysela
d25ddafaa7 ucm: fix possible memory leak in execute_sysw()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-05 15:42:31 +01:00
Alan Young
2e82060ebc 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: 467d69c5bc ("Fix CPU hog with combination of rate plugin")
Fixes: 29041c5220 ("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>
2022-12-30 20:12:42 +01:00
Jaroslav Kysela
9f2c68cef7 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>
2022-12-13 10:31:35 +01:00
Jaroslav Kysela
13e31fb1ec alsa-lib: conf - fix possible use-after-free in get_char_skip_comments
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-12-07 14:54:30 +01:00
Jaroslav Kysela
e29413a220 ucm: execute_sysw - fix possible use-after-free
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-12-07 14:51:32 +01:00
Jaroslav Kysela
d28e8cb294 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>
2022-11-29 19:43:52 +01:00
Jaroslav Kysela
75f8e2e73e test: latency - --policy option - allow using SCHED_OTHER
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-24 10:55:32 +01:00
Jaroslav Kysela
ea0850f3f3 test: latency - add --policy option to allow using SCHED_FIFO
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-24 08:33:47 +01:00
Jaroslav Kysela
536c93928b test: latency - usleep should not be used in the block mode
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-23 19:45:15 +01:00
Jaroslav Kysela
f0f054517c test: latency - add -y option (I/O usleep)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-23 17:56:20 +01:00
Jaroslav Kysela
9649b64c6f ucm: handle empty string also for ${env:} substitution
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-22 09:59:04 +01:00
Jaroslav Kysela
8b64f22459 ucm: clarify set_defaults calls
- do full reset in snd_use_case_mgr_reload

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-15 17:28:39 +01:00
Jaroslav Kysela
a0836e2af1 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>
2022-11-14 21:27:09 +01:00
Jaroslav Kysela
3e4aeba25b 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>
2022-11-14 20:47:59 +01:00
Jaroslav Kysela
425e4d1fbe 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>
2022-11-14 14:39:26 +01:00
Jaroslav Kysela
78b20e3caa 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>
2022-11-14 12:36:07 +01:00
Jaroslav Kysela
152983f01b 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>
2022-11-09 15:18:43 +01:00
Jaroslav Kysela
161f47da5f 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>
2022-11-09 15:03:09 +01:00
Jaroslav Kysela
39060852d8 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>
2022-11-09 09:35:05 +01:00
Jaroslav Kysela
aa4f56c3c9 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>
2022-11-09 08:18:06 +01:00
Jaroslav Kysela
1b436862ed 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>
2022-11-02 15:01:58 +01:00
Jaroslav Kysela
9447e57d7c Release v1.2.8
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-10-24 10:17:27 +02:00
Jaroslav Kysela
7e678d70c2 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>
2022-10-24 10:02:54 +02:00
Jaroslav Kysela
3bb9c44375 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>
2022-10-20 19:56:50 +02:00
Jaroslav Kysela
4633d35171 control: eld - skip trailing spaces
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-10-18 15:53:52 +02:00
Jaroslav Kysela
9253f08fb7 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>
2022-10-17 13:58:41 +02:00
Swapnil Devesh
dac9059524 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>
2022-10-17 13:13:51 +02:00
SASANO Takayoshi
60c1430b43 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>
2022-10-17 13:11:47 +02:00
SASANO Takayoshi
f89245ee66 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>
2022-10-17 13:11:34 +02:00
SASANO Takayoshi
b33ef3f73d 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>
2022-10-17 13:11:29 +02:00
Jaroslav Kysela
e288ca7c29 doc: ucm - more volume notes
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-10-17 13:08:11 +02:00
Jaroslav Kysela
595115758b doc: ucm - add sequence graphs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-09-16 19:02:16 +02:00
Jaroslav Kysela
0222f45d11 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>
2022-08-18 11:23:45 +02:00
Jaroslav Kysela
8033ff9996 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>
2022-08-16 17:22:36 +02:00