Commit graph

3252 commits

Author SHA1 Message Date
Wim Taymans
ee1bb2362d alsa: sync followers from the driver
Keep track or the follower state and do the sync from the driver
wakeup.

This improves sync between devices because the sync no longer
depends on when the node was woken up in the graph and scheduled. We
would have been able to handle this difference by using the htimestamp
but that doesn't seen to work reliably on some hardware.

This is also essential for the interrupt based scheduling.
2023-09-18 14:53:15 +02:00
Wim Taymans
c51f6ccbd7 alsa: rework the state sync code
Make one function to sync the state with the realtime thread.
2023-09-18 14:46:56 +02:00
Wim Taymans
86f1d14b72 alsa: keep states in global list 2023-09-18 09:40:52 +02:00
Barnabás Pőcze
06ba425378 treewide: use spa_assert_not_reached() instead of assert(false) 2023-09-16 17:50:25 +02:00
Barnabás Pőcze
436787d6ba treewide: try to use const char * for string literals 2023-09-16 17:47:35 +02:00
Barnabás Pőcze
fc72208fa0 spa: alsa: mark spa_alsa_silence() static 2023-09-16 17:38:51 +02:00
Wim Taymans
71808454e7 alsa: add and remove sources from data_loop
Add and remove timers and pollfd from the data-loop.
Rework setup_sources.
Start IRQ playback after adding pollfd to make sure we get all events.
2023-09-15 16:31:55 +02:00
Wim Taymans
c6f9cfa220 alsa: IRQ based scheduling wakes up after finishing 1 period
So we need to keep 2 periods of silence to keep 1 period of data inside
the ringbuffer when starting the graph.
2023-09-15 15:36:56 +02:00
Wim Taymans
eac74f6ece alsa: fix warning when compiling without FASTPATH 2023-09-15 15:35:52 +02:00
Wim Taymans
c8db951d61 alsa: some cleanups
Make sure we recycle an old buffer even if we don't have a new buffer to
push.
2023-09-15 13:05:31 +02:00
Wim Taymans
bf5b526464 alsa: small cleanups 2023-09-15 12:40:30 +02:00
Wim Taymans
c6745ed0d0 alsa: refactor read and write functions
Separate the sync logic from the read/write functions so that we can use
it in the wakeup logic as well.
2023-09-15 12:21:18 +02:00
Wim Taymans
cc1d980f0a audioconvert: silence some debug 2023-09-15 12:18:20 +02:00
Wim Taymans
e975cb16d3 alsa: add spa_alsa_prepare()
Split the spa_alsa_start() in a prepare and start function. Prepare
will then also reset state and prefill the playback buffer with silence.

This makes it possible to reuse the prepare function in recover().
2023-09-15 11:15:26 +02:00
Wim Taymans
a5d684af8a alsa: make sure we recalculate config when samplerate changes
The threshold depends on the samplerate and even when the graph rate or
quantum didn't change, the driver could be opened in a different
samplerate, which would cause the timeouts to be wrong and cause xruns.
2023-09-15 11:14:10 +02:00
Wim Taymans
99cf172bc7 alsa: improve debug
Use a new state variable to store the device name and direction so that
we consistently can debug those.
2023-09-15 09:09:04 +02:00
Wim Taymans
3c5da11706 alsa: set_timeout is only called when tsched is enabled.
We don't need to do an extra check.
2023-09-14 17:16:44 +02:00
Wim Taymans
4ffa7860bc alsa: update the clock name when we can
Update the clock name as soon as we get a io_clock. This way we can use
it to compare the clock name against the driver right away.
2023-09-14 17:15:06 +02:00
Wim Taymans
354ee6fd96 alsa: with IRQ we can use avail_update()
It does not need an ioctl because the driver already updated the info
before waking us up from poll.
2023-09-14 16:16:48 +02:00
Wim Taymans
1f1c308c97 aec: support both webrtc versions
Version 1 does not seem to be packaged in many distros and so they would
need to revert the patch or disable AEC. Enabling both allows for things
to move forwards gracefully.
2023-09-14 15:35:40 +02:00
Pauli Virtanen
2804a8f1f6 bluez5: minor BAP broadcast fixups
Don't try to deref NULL if adapter not found. Disable bcast reconnect in
simpler way. Use adapter name as device name. Style fixes.
2023-09-13 15:51:50 +00:00
Pauli Virtanen
186b730c9c bluez5: fix device supported codec checks
Make supported codec checks to use profiles, not "is-a-sink" flag, to
determine which codecs can be used.

Fixes bluez5-device checking only source profiles, even when the local
device is only a sink.
2023-09-13 15:51:50 +00:00
Wim Taymans
b094057b0b handle NULL latency param
Fixes #3504
2023-09-13 11:13:48 +02:00
Wim Taymans
69d431acd4 node: clarify port_set_io and SPA_IO_Buffers
port_set_io with SPA_IO_Buffer can be used to enable/disable a port
when the node is running and so the node should make sure the io update
is synchronized with the processing loop.

Use spa_loop_invoke to make sure the mixers handle the port_io updates
correctly.

Setting buffers or a format also needs the port to be disabled so add
some checks for this in the mixers.
2023-09-11 11:23:25 +02:00
Wim Taymans
9c834427c6 alsa: small cleanup
We always try to write when we have data so we can make this code path
common.
2023-09-08 12:19:52 +02:00
Wim Taymans
016d15e598 ratelimit: missed -> suppressed
To avoid confusing with missed samples.
2023-09-08 12:18:23 +02:00
Wim Taymans
632f532036 audioconvert: don't use -Ofast on alpha
I can crash when using denormalized floats.

Fixes #3489
2023-09-07 17:44:30 +02:00
Wim Taymans
ebeae802ad audioconvert: improve tag and latency handling
Don't just forward the tag and latency events to the follower but let
the audioconvert aggregate and emit the updated tag/latency event
that is then configured on the follower.

When using the DSP mode of the audioconvert, this results in an
accumulated latency/tag from all the DSP ports instead of just
the last DSP port param update.

Put properties with media. prefix in tags in pw-cat.
2023-09-07 15:27:21 +02:00
Wim Taymans
7c7dea890b alsa: redirect dict debug to log 2023-09-07 11:57:43 +02:00
Barnabás Pőcze
3bbccccd05 spa: v4l2: use a separate watch for each device
Instead of watching /dev, use a separate watch for each device.
This is supposed to achieve the same result as the now reverted
88f0dbd6fc ("v4l2: don't set inotify on /dev"):

  Doing inotify on /dev is not a good idea because we will be woken up by
  a lot of unrelated events.

  There is a report of a performance regression on some IO benchmark
  because of lock contention within the fsnotify subsystem due to this.

  Instead, just watch for attribute changes on the /dev/videoX files
  directly. We are only interested in attribute changes, udev should
  notify us when the file is added or removed.

Fixes #3439
2023-09-07 10:17:29 +02:00
Barnabás Pőcze
53ce1ee576 Revert "v4l2: don't set inotify on /dev"
This reverts commit 88f0dbd6fc.
2023-09-07 10:12:35 +02:00
Barnabás Pőcze
1110dbb7c1 Revert "v4l2: handle inotify errors"
This reverts commit 07b8954dc8.
2023-09-07 10:12:30 +02:00
Wim Taymans
805fbd0b34 meson: remove -ffast-math
It can cause crashes in some cases and does not seem to cause much
performance loss on x86.

Fixes #3489
2023-09-06 21:32:48 +02:00
Arun Raghavan
c842ef7071 aec-webrtc: Bump to webrtc-audio-processing-1
Upstream updated drops beamforming, adds a new gain controller and
includes a bunch of updates to the AEC engine (internally AEC3).
2023-09-06 09:31:06 +00:00
Jonas Holmberg
00ca590ff6 node-driver, null-audio-sink: Fix EAGAIN check
spa_system_timerfd_read() returns -EAGAIN.
2023-09-04 13:24:30 +02:00
Carlos Rafael Giani
8e6d070148 alsa-compress-offload: Add device object and udev based autodetection
As part of this, in alsa-udev.c, certain structures and variables referred
to as "device" are renamed to "card". Otherwise, there is ambiguity, since
"device" can mean a udev device, an SPA device, a compress-offload device,
a PCM device etc.

Also, replace "card id" with "card number" to emphasize that these integers
are not actually SPA object IDs.
2023-09-02 08:28:22 +00:00
Carlos Rafael Giani
ae4bff78a3 alsa-pcm-device: Minor logging improvements 2023-09-02 08:28:22 +00:00
Carlos Rafael Giani
61518e71fc alsa: Rename spa_alsa_device_factory to spa_alsa_pcm_device_factory
This makes it clear that this is specifically a factory for PCM nodes.
2023-09-02 08:28:22 +00:00
Wim Taymans
ccc591ae0f alsa: use target_rate from the position
We need to use the target_rate of the clock in the position io area to
get the next rate of the graph.
2023-09-01 10:02:28 +02:00
Wim Taymans
6fb53fc9f1 alsa: round to next power of 2 for max period_size
Prefer to make the period_size bigger rather than smaller because of
rate conversion.
2023-09-01 09:54:58 +02:00
George Kiagiadakis
af020bc425 alsa: report latency in the samplerate domain of the graph 2023-09-01 00:30:14 +03:00
Wim Taymans
21392d898e alsa: improve xrun clock field calculation
We're missing the delay in samples plus all of the extra samples of
silence we use to restart the device. This is in the samplerate of
the device.

Convert this to the time domain of the graph before adding it to xrun.
2023-08-31 14:28:56 +02:00
Wim Taymans
2c2b0f482f bluez: fix port flags
Physical and Terminal should be set for these hardware devices.

Fixes #3418
2023-08-31 13:01:08 +02:00
q66
aa11dbe10c alsa: get rid of non-portable isinf use
The isinf function returns -1 for negative infinity on glibc, but
the standard guarantees no such behavior (e.g. in C++ it always
returns a bool, on musl libc it's a macro that expands to a bool
expression), saying just that it returns a non-zero value.

This was added in pulseaudio around 15 years ago, and was never
fixed; pipewire then got the code from it. However, we can portably
check against -INFINITY instead (from math.h, already included).

Ref 045c1d6
2023-08-31 10:37:22 +00:00
columbarius
8bbc1c1abf vulkan: fix uninitialized writeDescriptor 2023-08-31 10:08:06 +00:00
columbarius
00c475e646 vulkan: download buffer to MemPtr 2023-08-31 10:08:06 +00:00
columbarius
73d6c20225 vulkan: spa_vulkan_use_buffers support datatype MemPtr 2023-08-31 10:08:06 +00:00
columbarius
eea8096b12 vulkan: Track spa_buffers for stream 2023-08-31 10:08:06 +00:00
columbarius
2456d58397 vulkan: Only allocate buffers when DMABUFS are used 2023-08-31 10:08:06 +00:00
columbarius
b8c91f7e54 vulkan: Synchronize in and out buffers 2023-08-31 10:08:06 +00:00