Commit graph

4507 commits

Author SHA1 Message Date
Wim Taymans
567b484386 filter-chain: move the filter-graph to plugins 2024-11-13 11:12:06 +01:00
Wim Taymans
b2dd733520 v4l2: Add mmap fallback when USERPTR is not supported
When we don't support EXPBUF according to the probe, the host will
allocate memory for us. We will then try to use USERPTR to import the
memory into v4l2.

If this is not supported, try to fall back to MMAP support, mmap the
buffers and memcpy the MMAP buffer to the host allocated buffers.
2024-11-07 15:55:38 +01:00
Wim Taymans
c4df4a0371 v4l2: improve debug a little 2024-11-07 15:55:38 +01:00
Wim Taymans
b9df297e2a v4l2: use a separate flag to skip the first buffer
The buf.sequence value might stay to 0 (v4l2loopback)
2024-11-07 15:55:38 +01:00
Wim Taymans
877c262e78 v4l2: probe number of buffers as well
Instead of just probing with 2 buffers, probe with the MAX_BUFFERS and
remember how many buffers we received.

Some drivers (v4l2loopback) work with less than MAX_BUFFERS (8) and we
need to set the max number of buffers in the Buffers param.
2024-11-07 15:55:33 +01:00
Wim Taymans
71f6d269db v4l2: first probe and then update port flags
The probe is to decide it we can use EXPBUF or not and this is used to
decide on the flags.

This got broken with 842ac9e110
2024-11-07 11:17:33 +01:00
Wim Taymans
9c49bffc22 keys: add lazy scheduling flags and docs 2024-11-06 12:57:48 +01:00
Wim Taymans
68877dcee7 audioconvert: only output when there is something to output
Or else we get 0 sized output buffers.
2024-11-06 09:28:09 +01:00
Wim Taymans
c0fcc9b83f videoconvert: add more ffmpeg format mappings 2024-11-05 10:40:14 +01:00
Pauli Virtanen
1b5c244ee0 bluez5: clean up route/profile building
Clean up route/profile building a bit so that it is easier to add new
device profiles.

Use names instead of magic numbers for the routes.

Fix marking BAP set input route unavailable by error due to magic number
off by one.
2024-11-04 21:54:29 +02:00
Pauli Virtanen
8504e58120 bluez5: reduce quirks logspam
There's no need to log quirks every time they are used, it's enough to
log them once when a device connects.
2024-11-04 21:41:24 +02:00
George Kiagiadakis
726234c82f audioconvert: always push out data when the out_offset reaches max_out
No matter if the input data (n_samples) is > 0, the code here should
flush out existing data if the output buffer is full
2024-11-04 20:36:12 +02:00
Elliot Chen
d5e2a0df6c libcamera: update buffers datas information according to plane info 2024-11-04 17:00:18 +00:00
Wim Taymans
9c19284f7f support: make the loop queue handling lockfree
Don't use TSS to store per-thread queues but keep a lockfree stack of
queues. We can then pick off a queue and write to that one and place it
back after use.

We need to keep the queues indexed by id in the stack because otherwise
we would need to compare-and-swap 128 bits (pointer + tag), which is
more problematic.

Because we keep the queues in an array and no queue is ever removed and
the array can only grow, we can quite easily just iterate the array
without a lock. Without the lock we also fix one of the potential
problems with ardour where the queue_flush thread is canceled while
flushing and the queue_mutex remains locked.

Because we end up with all queues in the array now, we can overflow the
fixed max amount of queues we can manage. When that happens, sleep for a
while and try again. This is a case where more than QUEUES_MAX (128) threads
are invoking at the same time and is rather unlikely.

There is also the queue overflow case which we now also must handle with
a retry. This potentially uses more eventfds but again this should be
unlikely and cause no further problems.

See #4356
2024-11-04 17:41:14 +01:00
Pauli Virtanen
c9acdd2f1f bluez5: backend-native: update HFP SDP records
Advertise SWB since we implement it.  Update HFP version to 1.9
accordingly.
2024-10-31 08:18:45 +00:00
Elliot
d67882fa10 libcamera: allocate memory according to the number of discontiguous memory 2024-10-30 15:20:21 +00:00
Wim Taymans
fb2b314660 audioconvert: interchange the resampler loops
Iterate the channels in the inner loop instead of the outer loop. This
makes it handle with 0 channels better but also does the more
complicated phase increment code only once for all channels. Also the
filters might stay in the cache for each channel now.
2024-10-30 13:31:24 +01:00
Iulia Tanasescu
b2a70f5933 bluez5: Add support for Broadcast links
This adds support for BAP Broadcast transport links.

Unlike unicast, broadcast links are used by a BAP Broadcast Sink
device to link together multiple transports in the same BIG that
the user wants to start receiving audio from. Each transport is
associated with a different BIS, so each one has a different fd.
Thus, each link needs to be acquired and released separately.
2024-10-28 17:57:44 +00:00
Wim Taymans
7906dc854a json: improve infinite checks
Avoid compiler errors like this:

 /usr/include/spa-0.2/spa/utils/json-core.h:417:25: error: comparing floating-point with '==' or '!=' is unsafe [-Werror=float-equal]
|   417 |                 if (val == INFINITY)
|       |                         ^~
2024-10-23 15:37:07 +02:00
Arun Raghavan
f0b81a4628 spa: audiotestsrc: Validate loop and system before using them
Makes sure we don't crash if those are not available (like with
DataSystem under spa-inspect).

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4365
2024-10-23 08:25:30 -04:00
Wim Taymans
2c132be626 audioconvert: align some buffers
so that we can use aligned read and writes in SSE.
2024-10-23 12:54:23 +02:00
Wim Taymans
662bf68122 audioconvert: handle odd writes in delay
Add some padding to the delay buffer. If we wrap around, copy the
spilled samples to the front of the buffer. This makes it possible to
use the more optimized sse delay function in more cases.
2024-10-23 12:34:04 +02:00
Wim Taymans
3309e0b244 audioconvert: don't unroll when unaligned write pointer
We require the write pointer to be a multiple of 4 for our unrolled SSE
loop to work, so enforce this to avoid segfaults.
2024-10-23 11:40:34 +02:00
Wim Taymans
da86026b7a latency: handle negative latency correctly
In our current world, it is possible to have a negative delay. This
means that the stream should be delayed to sync with other streams.

The pulse-server sets negative delay and the Latency message can hold
those negative values so make sure we handle them in the helper
functions as well.

Do the delay calculations in pw_stream and JACK with signed values to
correctly handle negative values. Clamp JACK latency range to 0 because
negative latency is not supported in JACK.

We should also probably make sure we never end up with negative
latency, mostly in ALSA when we set a Latency offset, but that is
another detail.
2024-10-23 10:47:58 +02:00
Wim Taymans
22c45af7e0 loop: refcount the queues
The loop in the TSS gets an extra refcount and is unreffed when the TSS
destroy is called.

We can then also ref the queue during the function callback. When the
queue (thread) was destroyed during the callback, ignore the result and
continue with the next queues.

See #4356
2024-10-21 17:47:31 +02:00
Wim Taymans
bb53aa08ad loop: warn when some queues are still in TSS
When we clear we need to have all our queues removed from the TSS when
we delete the tss key or else they are leaked, check an warn about this
using a refcount of queued in the TSS.

See #4356
2024-10-21 17:08:10 +02:00
Wim Taymans
c4fece74a5 loop: fix race in shutdown
Make it possible to call loop_queue_destroy() from both the TSS destroy
and impl_clear() without races. We make sure that only one can remove
the queue from the queue list and cleanup. We also store the IN_TSS flag
in the flags so that we can see them before the queue is added to the
queue list. Only free the IN_TSS queue when the TSS destroy is called.

See #4356
2024-10-21 16:45:17 +02:00
Wim Taymans
6549e313ef alsa: clean up followers and our driver link in _clear
When we are going to be freed, make sure we remove ourself from the
driver list and also remove all the followers that we might still have.

Fixes #4355
2024-10-21 15:47:21 +02:00
Pauli Virtanen
cd82c7259b bluez5: don't exit if system DBus goes down
Similarly as in spa_dbus, don't exit if bus goes down.  Neither the
audio or midi Bluetooth backend reconnects to DBus, but they shouldn't
exit the process.
2024-10-16 23:55:17 +03:00
Wim Taymans
2c0ce6afc2 audioconvert: SSE optimize delay and convolver 2024-10-15 16:10:25 +02:00
Wim Taymans
33fb2f04c7 audioconvert: use MAX_TAPS constant 2024-10-15 12:49:16 +02:00
Wim Taymans
ad84c45c0c audioconvert: optimize lr4 handling
Make an SSE optimized LR4 function and one that handles 2 LR4s in
parallel.
2024-10-15 12:20:04 +02:00
Wim Taymans
fec3730489 audioconvert: avoid a memcpy when we can 2024-10-15 12:19:17 +02:00
Wim Taymans
a57f2f25b6 delay: improve delay performance
Use a wrap around delay ringbuffer. We can then avoid some modulo
arithmetic and read more efficiently.

Also handle the delay convolver case better by reversing the taps and
reading the taps and delay buffer without extra overhead.
2024-10-15 12:14:57 +02:00
Pauli Virtanen
34bca4a007 bluez5: add quirk for Phonak hearing aids 2024-10-13 11:50:04 +03:00
Pauli Virtanen
f89d42b8bc bluez5: fix crash with broadcast sinks 2024-10-12 11:03:21 +00:00
Wim Taymans
fa1ec61cf0 profiler: add followerClock block
Add a new followerClock block in the profiler info. This is only set
when the follower could be a driver and it contains the clock info used
for following the driver, mostly the rate difference and delay.

Dump this info in pw-profiler -J

Make sure we always set the info in the clock, especially also when we
are following.
2024-10-09 11:31:54 +02:00
Wim Taymans
8cd3fc6922 adapter: increase max-retry to 64
When the follower doesn't produce enough data for this many attempts,
bail and cause an xrun to avoid an infinite loop.

The limit of 8 cause real-life problems and should be larger. It should
probably depend on the expected size per cycle (node.latency) and the
current quantum but we don't always have this information.

See #4334
2024-10-07 09:28:39 +02:00
Wim Taymans
0db2171cd9 alsa: dynamically adjust the DLL bandwidth
Keep a running average and variance of the error. Use this to
periodically update the DLL bandwidth. When the variance gets smaller,
we update the DLL more slowly to stay closer to the ideal rate.

This seems to improve the rate stability.
2024-10-04 10:47:47 +02:00
Arun Raghavan
e6bcc415fc acp: Trim trailing whitespace in monitor name from HDMI ELD
The ELD ends with a \n and spaces to pad the length, but most drivers
except NVidia trim that out while presenting to userspace. While this is
being tracked upstream [1], let's deal with this locally.

[1] https://github.com/NVIDIA/open-gpu-kernel-modules/pull/715

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4332
2024-10-02 17:02:11 +00:00
Wim Taymans
5db02df08c spa: fix event pod type 2024-10-02 16:11:02 +02:00
Wim Taymans
dca11e6c41 loop: remove extra allocation
We don't actually need the extra allocation for the tss. We can just
mark the queue as being in the tss. When a queue is destroyed, mark it
as destroyed but when it is still in the tss, don't free the structure
yet. We free the structure when we destroy the tss.

We can also free the overflow queues of a queue when it is destroyed
immediately.
2024-10-02 09:40:54 +02:00
Wim Taymans
5d3aac313d loop: free tss from the thread calling impl::clear
The thread that calls the impl_clear method might be the main thread and
is certainly not going to call the invoke function anymore so free the
tss if there is any.

Fixes a leak in the unit test.
2024-10-02 09:21:00 +02:00
Barnabás Pőcze
1a549c02a5 acp: do not overwrite properties of PCM with that of the card
The properties of the card might overwrite those of the PCM.
For example, the cards's `alsa.id` will be set on the PCM too
since 37a51533e0 ("acp: add more properties for the card").

To avoid that, call `pa_alsa_init_proplist_card()` first
in `pa_alsa_init_proplist_pcm_info()` instead of last.

See #4135
2024-10-01 22:50:12 +02:00
Wim Taymans
82585b7475 loop: improve tss cleanup
Store a pointer to a pointer to a queue in the tss and point to it from
the queue.

When we destroy the queue when we _clear the support, we can clear the
pointer in the tss as well. This way, when the thread is later
destroyed, it will see the NULL pointer and not try to free the queue
again.
2024-10-01 13:25:15 +02:00
Wim Taymans
0ca64277b3 spa: initialize all fields explicitly
Patch by Petar Popovic

Fixes #4325
2024-09-30 10:06:30 +02:00
sunyuechi
245adda985 fmt-ops: add RVV optimizations for s32_to_f32d 2024-09-29 11:17:42 +08:00
sunyuechi
79d41e183e fmt-ops: add RVV optimizations for f32d_to_s32 2024-09-26 00:55:49 +08:00
sunyuechi
74832445ba fmt-ops: add RVV optimizations for s16_to_f32d 2024-09-25 10:50:05 +00:00
sunyuechi
588f2bcb69 RISCV: Improve scalar computation of f32d_to_s16 2024-09-25 10:50:05 +00:00