Commit graph

802 commits

Author SHA1 Message Date
Wim Taymans
1bf1497855 spa: mode dll to utils 2022-03-30 17:22:26 +02:00
Wim Taymans
2f5bba112f spa: Improve PropInfo fields
The PropInfo either has a registered id (and then also a name from the
type-info) or a custom name as a string.
In all cases, the description contains a free form text that clarifies
the property.

Use the description in the stream controls name.
2022-03-30 17:09:08 +02:00
Wim Taymans
cec8898740 tests: add some options
Use S16_LE as the sampleformat, add option for S32_LE
Add support for setting samplerate and channels.
2022-03-13 15:08:22 +01:00
Wim Taymans
1647c169b2 alsa: improve latency update 2022-03-04 17:21:17 +01:00
Wim Taymans
bcdd1ea811 alsa: set better ranges on properties 2022-03-04 17:21:14 +01:00
Wim Taymans
99f9f729ff handle open_memstream errors
Fixes #2182
2022-03-02 11:48:31 +01:00
Wim Taymans
e28b613404 alsa: don't read more than available samples
Keep the original available samples and use them to avoid reading
a chunk when there is not enough data.
2022-02-16 21:30:54 +01:00
Wim Taymans
56c03c11f8 alsa: resync when quantum changes 2022-02-16 21:30:35 +01:00
Wim Taymans
798228a906 alsa: remove useless code
The resync check can be done in check_position_config.
2022-02-16 21:29:55 +01:00
Wim Taymans
4246961070 alsa: use rewind to remove excess delay
When the delay is too big, rewind a little to reduce it when resync.
2022-02-16 21:10:03 +01:00
Wim Taymans
761199be70 alsa: improve resync
Use the max error to do a resync. Don't reset the dll, there is no
reason for that.
Don't use _rewind, but instead limit the amount of samples we read and
write
Should keep more stable sync in most cases.
2022-02-15 16:32:00 +01:00
Wim Taymans
87f4726164 alsa: protect against impossible timeouts
Check if the new timeout is larger than 1sec in the past or future
and reprogram a timeout with a saner timeout.
2022-02-15 15:35:40 +01:00
Wim Taymans
8b899dbc55 alsa: make sure we always trigger a timeout
If we get an error from get_status() make sure program the timer
for one period or else we would just end up with silence.
2022-02-15 15:32:09 +01:00
Wim Taymans
dc76ab2291 alsa: don't use dll when not rate matching
Only use the DLL when we are driver or rate matching with
another driver.
2022-02-15 15:29:40 +01:00
Pauli Virtanen
bae2cc0a6e spa/alsa-udev: ignore all errors in card busy check
If card busy check fails due to error, just log info message and
consider the card not busy.

For kernels with CONFIG_SND_PROCFS=n, /proc/asound is not present, and
we have to handle that.  It's also better to fail open here, rather than
end up with missing devices.
2022-02-14 20:50:53 +02:00
Wim Taymans
0bca352241 alsa: fill with silence when underrun
Also try to resync when the follower buffer is running empty.
Fill the buffer with silence instead of doing _pcm_forward.
2022-02-12 12:09:25 +01:00
Wim Taymans
9855e2b303 alsa: tweak capture follower
If the follower does not have enough data to capture, skip a cycle
instead of trying to capture and get an XRUN.

Tweak some limits a little.
2022-02-11 18:07:44 +01:00
Julian Bouzas
e34d9d209a alsa: try to resume after suspend before recovering
Fixes no audio after suspending with some audio drivers.

See #2001
2022-02-10 16:57:58 -05:00
Wim Taymans
f636603844 alsa: pass current_time around in get_status()
Pass the current time around in various functions.
Make a higher precission htimestamp based get_delay() function. Seems to
work fine for playback but not for capturee.
2022-02-10 15:31:29 +01:00
Luis Correia
3cba294b65 Update texas-instruments-pcm2902.conf, add info about Behringer U-Phoria UM2 2022-02-09 20:58:20 +00:00
Wim Taymans
14d252ec9d alsa: try to resync on commit error
When we get a commit error, try to resync our pointers. This fixes a
problem of endless commit errors after a quantum change because it never
manages to resync properly.
2022-02-08 18:31:42 +01:00
Pauli Virtanen
97a5fe80c1 spa/alsa-udev: fix /proc/asound handling without CONFIG_SND_VERBOSE_PROCFS
For kernels compiled with CONFIG_SND_VERBOSE_PROCFS=n, the pcmXX
/proc/asound entries do not exist.  In that case, the "device busy"
check cannot be done, but we should still check existence of PCM devices
correctly.

Count the number of PCM devices from /dev/snd, which should work also
without /proc/asound or /sysfs/class/sound.
2022-02-03 18:28:25 +00:00
Wim Taymans
76417fd2a6 alsa: use MONOTONIC clock for tstamp 2022-02-03 16:22:09 +01:00
Wim Taymans
7480d09589 alsa: update test-timer
Remove the bandwidth reduce, we don't do that.
Clamp large errors.
Add htimestamp mode, which seems more stable.
2022-02-03 16:22:09 +01:00
Pauli Virtanen
b369401c8e spa/alsa-udev: retry busy devices on inotify close event, not timeout
Alsa device acp probe results to missing profiles if some PCM devices
are busy. Currently, we retry based on a timeout and give up after some
retries. However, exposing cards with missing profiles is never
useful.

Never expose cards if some PCM devices are busy. Instead, retry adding
device on inotify fd close events, which arrive when some process has
closed a PCM device.

When probing for devices in alsa-udev, check via /proc to avoid inotify
busy loop.
2022-02-02 16:43:54 +00:00
Wim Taymans
f2906a26f1 alsa: sync TI2902 conf with pulseaudio
Adn reenable it to see if it improves things again.
2022-01-27 11:10:24 +01:00
Wim Taymans
4660e16d5b meson: enable some more warnings
Fix some warnings
2022-01-27 11:07:17 +01:00
Wim Taymans
8d37451fb8 alsa: ensure period_size is not 0 2022-01-24 12:44:16 +01:00
Pauli Virtanen
e1bc1c4569 alsa-udev: postpone emitting if pcm devices are busy, retry later
There is a race condition on udev permission changes (e.g. switching
VTs), when pipewire from one user closes devices, and the other process
from second user tries to open them.  The close/open are not ordered, so
opening a device may fail in alsa-acp-device.c resulting to missing
devices/profiles.

Address this by trying to open devices already in alsa-udev.c. If some
devices are busy, do not emit the device info yet, but retry after a
timeout.  If it still fails, go ahead emitting the device, even if some
profiles may be missing.  The retry with delay should be enough to solve
the race almost always.
2022-01-23 12:33:57 +00:00
Wim Taymans
5b3bc4e80e alsa: first start monitor then enumerate devices
So that we can catch the SOUND_INITIALIZED update between enumerating
devices and starting the monitor.This fixes a races in detecting devices.

Thanks to Matthias Fend for finding this.

Fixes #2046
2022-01-21 10:50:13 +01:00
Wim Taymans
cb077975bc alsa: remove TI 2902 rule, it seems to break things 2022-01-19 20:31:09 +01:00
Wim Taymans
5010125452 alsa: make internal latency configurable with params 2022-01-18 11:46:08 +01:00
Wim Taymans
d8c867b515 alsa: improve rate selection
Make sure we don't select an invalid rate when the default is set or
when the card is already opened in some unsupported rate.

See #1975
2022-01-17 14:56:45 +01:00
Wim Taymans
c8d4cef2d2 alsa: remove unused properties and hardcoded values 2022-01-12 17:51:49 +01:00
Wim Taymans
776b52749f Use configured quantum_limit instead of hardcoded value
Parse the quantum_limit parameters and use this to scale the buffers so
that they can contain the maximum allowed samples instead of the
hardcoded 8192 value.

See #1931
2022-01-12 17:50:12 +01:00
Wim Taymans
50ce9a794f alsa: relax the max latency requiremen
Our max latency is based on the buffer_size / 2, one part is playing and
another part is filling.
2022-01-12 17:20:42 +01:00
Wim Taymans
39716cdd44 alsa: limit batch period size to default
We take half of the current quantum as the period size for batch
devices. Limit this to the default quantum to ensure we don't end up
with too much headroom.
2022-01-11 16:33:19 +01:00
Nazar Mokrynskyi
dc4cf163ef Remove separate profile set for Behringer UMC22 that is covered by Texas Instruments PCM2902 profile set 2022-01-09 15:37:44 +00:00
Pauli Virtanen
d33779cd11 alsa/acp: make pa_ato* functions behave as PA ones
The pulseaudio pa_ato* functions set errno and return -1, when the
number cannot be parsed.

Some parts of parsing the profile files (e.g. parse_eld_device) rely on
these functions returning errors when the input is not a number.
2022-01-08 16:26:07 +02:00
Wim Taymans
b63a6a1b66 acp: sync with pulseaudio 2022-01-03 17:21:28 +01:00
Wim Taymans
03f069c35b alsa: handle extra propinfo in all cases
When we don't have iec codecs, increment the result.index to iterate
the remaining properties.
2022-01-03 16:16:16 +01:00
Wim Taymans
67dc97fa43 alsa: add audio.allowed-rates param
Add a construct and runtime param to limit the amount of allowed
samplerates used by the node.

Fixes #1932
2022-01-03 16:03:23 +01:00
Wim Taymans
35cbe4e939 buffers: make alignment optional
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
2022-01-03 12:32:26 +01:00
Wim Taymans
21d07dba26 alsa: add TI PCM2902 mapping
Fixes #1136
2022-01-03 09:47:34 +01:00
Barnabás Pőcze
2b110af366 treewide: meson.build: use dependency variable for SPA
Use `spa_dep` everywhere instead of `spa_inc`,
and remove `spa_inc` altogether.
2021-12-28 18:34:06 +01:00
Barnabás Pőcze
b04b52ecf8 spa: alsa: do not look up the card again when releasing
Currently, `release_card()` uses `find_card()` to find the card
by the index stored in the state object. However, `find_card()`
increments the reference count of the object, therefore
`release_card()` will drop the reference that it has just
created by calling `find_card()` and not the "calling scope's"
reference. This prevents the card objects from being
freed when the SPA handle is cleared.

Fix it by having `release_card()` take a pointer to the card
and not its index.
2021-12-20 19:50:57 +01:00
Barnabás Pőcze
ee0963b68e spa: alsa: change index type
The `card` structure uses `uint32_t` for its index member,
on the other hand, the `state` structure uses `int`. No code
depends on it being `int`, therefore change it to `uint32_t`
for consistency.
2021-12-20 19:50:57 +01:00
Wim Taymans
f8cdc05720 alsa: allow multi-rate by default
We don't enable multiple rates by default and kernel 5.16 will fix
most issues so allow multiple rates per card.

See #1916
2021-12-18 08:33:34 +01:00
Wim Taymans
b476d6b503 alsa: add api.alsa.period-num param
To configure the amount of periods. By default we use as many as
possible but it is now possible to force a value.

See #1473
2021-12-17 16:09:52 +01:00
Wim Taymans
8630b8846c alsa: use position duration as period size
Use half of the configured quantum as the period size in batch mode.
This gives lower latency for USB devices depending on the quantum.
2021-12-17 16:08:08 +01:00