Commit Graph

12409 Commits

Author SHA1 Message Date
Wim Taymans 40b8ff187b stream: log a warning when media.class and direction mismatch
Fixes #2493
2024-04-17 09:53:54 +02:00
Jonas Holmberg 09088b376f rtp_stream: Use the log topic of the module
Set log topic to the topic of the module linked with stream instead of
logging with "default" topic.
2024-04-17 07:13:53 +00:00
Wim Taymans 24478b9128 module-loopback: only enable delay with valid rate and channels
Or else we can't calculate the required delay buffer size and we might
even end up with a double free.

Fixes #3748
2024-04-16 11:16:00 +02:00
Wim Taymans 0e45836c36 properties: only count valid property updates
Log warnings when some property update failed. Only add valid property
updates to the total update count.
2024-04-16 11:05:39 +02:00
Jonas Holmberg 64d75b6b2e module-rtp-sink: Send all remaining packets when stopping
Don't close rtp_fd until all packets have been sent by the timer, if
the timer is running when the stream is stopped.
2024-04-16 07:50:33 +00:00
Barnabás Pőcze 4cea8eb01f pulse-server: use `memcpy()` to write string into message
The length of the string is already known, so use `memcpy()`
instead of `strcpy()` to copy the string into the message buffer.
2024-04-16 07:37:12 +00:00
Barnabás Pőcze 150211a3f8 pulse-server: message_dump(): fix `format_info` memory leak 2024-04-16 07:37:12 +00:00
Barnabás Pőcze 3fa92bbd15 pulse-server: ignore unsaveable values when deserializing property list
PulseAudio's property list can store arbitrary data, but
pw_properties can only store null-terminated strings.
So for the time being, ignore those values that don't
have null-terminators or have zero bytes inside.
2024-04-16 07:37:12 +00:00
Barnabás Pőcze 12bddf6521 pulse-server: stricter length checking when deserializing property list
The length of the value for each value in a property list is serialized
twice. Both the reference implementation and pipewire-pulse send
the same length, so be stricter and only accept a property list
if both lengths are the same.
2024-04-16 07:37:12 +00:00
Wim Taymans 2b11efdf3b alsa: fix race when updating the eventfd
The eventfd is read/written from/to the data thread and the main thread
concurrently with the update_active() function.

Use an atomic compare and swap to make this update atomic and avoid an
inconsistency between the active boolean and the eventfd. This could
result in the eventfd being unsignaled while the active flag was true
and the application receiving a timeout and XRun in its poll loop.

Fixes #3711
2024-04-16 09:30:23 +02:00
Wim Taymans 232f4f01e4 protocol-native: fail when security context init fails 2024-04-15 16:43:46 +02:00
Wim Taymans 6499b8572e tests: don't crash when security context is not available
Fixes #3952
2024-04-15 16:41:03 +02:00
Wim Taymans b97c6e2eac audioconvert: also clamp monitor volume to min/max
When we set a min/max value, also clamp the monitor volume to it.

Fixes #3962
2024-04-15 16:28:24 +02:00
Wim Taymans 2379e83283 pipewire: document and improve -v option
Take the log level after we init pipewire to get the default level. Then
let the -v option increase it.

Fixes #3963
2024-04-15 15:39:50 +02:00
Wim Taymans b9fad5b89c doc: add -P option to docs 2024-04-15 15:39:13 +02:00
Pauli Virtanen bff252ce60 combine-stream: actually make use of resample.disable
resample.disable was made to default to true, but copying it to stream
properties was forgotten so it didn't have any effect. Make sure to copy
it.

This will also prevent different input/output streams from negotiating
to different rates, which would result to broken audio since we are just
passing sample data through.
2024-04-14 18:58:45 +03:00
Pauli Virtanen e1849a0650 combine-stream: check module arguments for syntax errors
Refuse to create module if the arguments were not properly parsed.
2024-04-14 16:24:16 +03:00
Pauli Virtanen cd166ac899 bluez5: don't use spa_invoke from data loop to main loop
spa_loop_invoke from data loop to main loop is not OK, as Wireplumber
currently runs its main loop with "pw_loop_enter(); pw_loop_iterate();
pw_loop_leave();" which causes the loop to be entered only when it is
processing an event.

In this case, part of the time the loop impl->thread==0, and calling
spa_loop_invoke() at such time causes the callback to be run from the
current thread, ie. in this case data loop which must not happen here.

Fix this by using eventfd instead, which is safe as the callback always
runs from the main loop.

Eventfd is also slightly more natural here, as multiple events will
group to the same mainloop cycle.
2024-04-13 15:54:22 +03:00
Wim Taymans 37a8dd5cb3 bluez: initialize variable to avoid warning 2024-04-12 18:14:54 +02:00
Pauli Virtanen a6dcdfae0c bluez5: iso-io: track and apply corrections to tx latency
Use TX timestamps to get accurate reading of queue length and latency on
kernel + controller side.

This is new kernel BT feature, so requires kernel with the necessary
patches, available currently only in bluetooth-next/master branch.
Enabling Poll Errqueue kernel experimental Bluetooth feature is also
required for this.

Use the latency information to mitigate controller issues where ISO
streams are desynchronized due to tx problems or spontaneously when some
packets that should have been sent are left sitting in the queue, and
transmission is off by a multiple of the ISO interval.  This state is
visible in the latency information, so if we see streams in a group have
persistently different latencies, drop packets to resynchronize them.

Also make corrections if the kernel/controller queues get too long, so
that we don't have too big latency there.

Since BlueZ watches the same socket for errors, and TX timestamps arrive
via the socket error queue, we need to set BT_POLL_ERRQUEUE in addition
to SO_TIMESTAMPING so that BlueZ doesn't think TX timestamps are errors.

Link: https://github.com/bluez/bluez/issues/515
Link: https://lore.kernel.org/linux-bluetooth/cover.1710440392.git.pav@iki.fi/
Link: https://lore.kernel.org/linux-bluetooth/f57e065bb571d633f811610d273711c7047af335.1712499936.git.pav@iki.fi/
2024-04-12 18:50:15 +03:00
Pauli Virtanen 9165291c43 bluez5: iso-io: drop RX data when source is not running
When media-source is not running, we need to drop any RX data so that
there is room in the socket buffer for the latency reporting.
2024-04-12 18:31:26 +03:00
Pauli Virtanen 4f91f0bcb0 bluez5: move spa_bt_ptp to rate-control.h 2024-04-12 18:31:26 +03:00
Pauli Virtanen cfb29af672 bluez5: bap: use priority from conf table in PAC selection 2024-04-12 18:31:26 +03:00
Wim Taymans 66ba147bfc filter: fix -UFASTPATH compilation 2024-04-10 18:28:18 +02:00
Wim Taymans 6aa690fa8d pipewire: add a -P option to set context properties
Add a -P (--properties) option to create the context with custom
properties. This can be used to control the modules that are loaded, for
example when they have conditions.
2024-04-10 18:13:01 +02:00
Wim Taymans 18ce166735 protocol-native: cleanup when starting a server fails 2024-04-10 18:12:14 +02:00
Wim Taymans d672e8fbf2 stream: use the pw_impl_node implementation details
We can use the position/clock and driving variables from the
pw_impl_node instead of keeping another copy around.
2024-04-10 17:33:30 +02:00
Wim Taymans 06905cd53b impl-node: improve set_io some more
Make sure we first set up our own state before calling into the
implementation. That way, the implementation can look at the new state.
2024-04-10 17:22:34 +02:00
Wim Taymans a683049986 impl-node: only become driving when we are a driver
We don't just need to check the clock and position clock id, we also
need to be able to become a driver before we can be driving.
2024-04-10 16:45:18 +02:00
Wim Taymans 39ca1bb9ed mem: MAPPABLE -> UNMAPPABLE
Change the flag from MAPPABLE to UNMAPPABLE to ease compatibility.

Older servers with newer client will not set the flag and so memory is
mappable for the client.
Newer server will set the flag but the client will ignore it and act
like before.
2024-04-10 13:11:54 +02:00
Wim Taymans 8115bf3eeb protocol-native: send debug to right topic 2024-04-10 13:11:17 +02:00
Robert Rosengren 95127d8a18 gst/src: fix crash when current_caps is NULL
gst_pad_get_current_caps may return NULL and passing that into
gst_caps_is_equal may result in fatal critical log due to the
"g_return_val_if_fail (GST_IS_CAPS (caps1)" check. Fix by checking for
NULL to avoid this.
2024-04-10 09:17:14 +00:00
Wim Taymans c534acac46 spa: handle empty values better
Make sure the properties are not empty before trying to access them.
2024-04-10 11:08:40 +02:00
Wim Taymans 61af61a4b3 v4l2: handle empty properties gracefully
When a property is not found or is empty, go on to the next format
instead of failing.

See #3959
2024-04-10 11:06:44 +02:00
Wim Taymans 51c2b02e9e client-node: pass the right object to functions
These functions are not really used so not currently a problem.
2024-04-10 10:44:03 +02:00
Wim Taymans 7007ffcae1 impl-node: keep some state consistent
The target.id might be needed to find existing targets.
Update the properties after setting the initial state for the node, it
is a driver for itself and the properties can make it a driving node
when the driver property is set.
2024-04-10 10:26:00 +02:00
columbarius c223e02d9b vulkan: Complete vulkan_pass
vulkan_pass now contains everything required for a single blit pass.
2024-04-09 09:05:03 +00:00
columbarius 11ff1471e9 vulkan: Cache buffer_type
All buffers should have the same type.
2024-04-09 09:05:03 +00:00
columbarius f935a191ad vulkan: Move vulkan_pass handling to filter
The current buffers are directly tracked by vulkan_pass.
2024-04-09 09:05:03 +00:00
columbarius 75daa140f3 vulkan: Split buffer import into CPU and GPU part 2024-04-09 09:05:03 +00:00
columbarius 3f47825082 vulkan: Introduce vulkan_pass for blit operations 2024-04-09 09:05:03 +00:00
columbarius 522546e8d3 vulkan: Sync buffers on in and export in blit 2024-04-09 09:05:03 +00:00
columbarius f10e8d2717 vulkan: Export functions to handle implicit_fd 2024-04-09 09:05:03 +00:00
Martin Geier 5c8799a480 alsa-pcm: set threshold to final value before set_swparams is called
This patch fixes use case, when disable_tsched is set and
api.alsa.period-size is set to value different from default quantum size.

In a such configuration, threshold needs to be set to a final value
before snd_pcm_sw_params_set_avail_min is called to get IRQs with
right timing.

Avail minimum is calculated from a threshold set in the check_position_config.
The method returned different value for threshold right before playback
started and after the playback started. Therefore threshold used in
the snd_pcm_sw_params_set_avail_min was incorrect.

Force the check_position_config to use configured values when called
from spa_alsa_prepare as this method is called when starting new playback
and the state->period_frames and the state->rate are already known.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2024-04-09 09:03:49 +00:00
Martin Geier 4c11a2aa9a alsa-pcm: start playback immediately if there is start delay set
Without this change, playback_ready or capture_ready was called
immediately after spa_alsa_start even tho start-delay was set.
Ready function was called with not precise "nsec" value, as "nsec"
plus latency should return time when the next buffer should be played
which wasn't true as start-delay was not included.

Now the playback is started immediately when the start_delay is set.
The alsa_do_wakeup_work is still called immediately but two things can
happened. Either start-delay is smaller then max_error and *_ready
function is called immediately, or start-delay is bigger then max_error
and state->next_time will be updated to correct value.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2024-04-09 09:03:49 +00:00
Martin Geier 1e6dad14d3 alsa-pcm: use headroom to calculate minimum available frames for non time scheduling
Alsa needs to call handler soon enough to have headroom plus threshold
frames in the buffer and not only threshold left.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2024-04-09 09:03:49 +00:00
Martin Geier b4ed8dcf14 alsa-pcm: do not allow headroom plus threshold be bigger then the alsa buffer
Headroom are extra samples available in alsa buffer on top of a threshold.
Its use to prefill alsa buffer with silence before the playback starts
and later its use to calculate target number of a frames in the alsa buffer
when get_status is called. Target is calculated as headroom plus
threshold, which should be smaller then buffer size to make sense.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
2024-04-09 09:03:49 +00:00
Carlos Rafael Giani 695f236f5f alsa-compress-offload-device: notify observers when profile changes
Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
2024-04-09 09:03:49 +00:00
Martin Geier d6184bd9bb alsa-pcm-device: notify observers when profile changes
Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2024-04-09 09:03:49 +00:00
columbarius 7206980023 vulkan: Sync renderer for blit filters
A spa_node has callback both on the main and data thread, which can
modify the internal state of vulkan_blit_state. Especially critical are
functions, which might drop buffers currently in use. To mitigate this
a read-write lock is used. The data thread shall try to aquire a read
lock before accessing the buffers, while the main thread has to aquire
exclusive access via a write lock before modifying the buffers.
2024-04-08 20:24:30 +00:00