Commit graph

12556 commits

Author SHA1 Message Date
Wim Taymans
b0ce5d0dd8 jack: don't call free_link from the data thread
We are not allowed to call free_link from the data thread because it
does free() and some pw_mem calls which should only be called from the
main thread.

To solve this, pause the core, queue a free_link operation on the data
thread, which will be scheduled after the previous remove_link operation
completes, free the link and then resume the core. Blocking and resuming
the core is necessary because we can't block for completion of the
invoke calls (the jack method is not allowed to block) and we must
ensure that nothing can happen with the memory (like reuse the mem_id)
before we have cleaned it up.

Fixes a crash in jack with create/destroy link stress.
2024-06-11 17:17:32 +02:00
Wim Taymans
cdfe95c091 pw-link: avoid crash when proxy was already destroyed
When a link already exists, the link will fail and the proxy will be
destroyed and the pointer set to NULL. Avoid doing things with the NULL
pointer when cleaning up.
2024-06-11 15:57:44 +02:00
Wim Taymans
c48c444566 pw-link: avoid memleak when proxy create fails 2024-06-11 15:57:21 +02:00
George Kiagiadakis
8da35df0bf gst: use G_DECLARE_FINAL_TYPE for all classes 2024-06-11 12:51:51 +00:00
George Kiagiadakis
0bde0ebad8 gst: reference the GstPipeWireStream from the pool & the clock 2024-06-11 12:51:51 +00:00
George Kiagiadakis
0c40c01477 gst: factor out the stream management and some common variables in a new class
Construct this new class from both the src and sink to be able to share code

Consolidate the previous mess of open/close/start/stop into a single pair
of open/close functions in the new stream class
2024-06-11 12:51:51 +00:00
Wim Taymans
fe5a29ac2a v4l2: improve logging a little
Add the device to the error log lines.
2024-06-11 12:15:05 +02:00
Vlad Pruteanu
34b17a6269 bluez5: bap: Enable control of Broadcast Encryption
Add "encryption" parameter to bluez5.bcast_source.config entry in
the configuration file. This allows the user to control the use of
Broadcast encryption.
2024-06-11 07:17:17 +00:00
Eli Schwartz
acd5bf60b9 meson: fix webrtc-audio-processing dependency ignoring configure args
Most dependencies use meson "feature" options for optional
functionality. This allows people to disable them, if they don't want
them, through the power of tristate decision-making.

This particular dependency does something a bit more complicated than
can be described by simply passing feature options to the required
kwarg. It:

- tries to look for two different names of the dependency
- selects different version ranges, depending on the dependency name
- has a hole in the middle of the versions

Unfortunately, `required: false` for the first dependency isn't
equivalent to a tristate decision-making process. We have to manually
code the logic ourselves.

The problem is that when we look up the first name, we cannot pass the
feature option in because if the option is force enabled, then the
dependency lookup fails and configuration never tries to find the older
version instead.

But also, we can't just say it *isn't* required, because if the option
is force *disabled* but it is installed on the system, we still find it
and build against it.

One solution would be using meson 0.60's support for multiple dependency
names:

```
dependency('webrtc-audio-processing-1', 'webrtc-audio-processing',
    version : ['>= 0.2'],
    required: get_option('echo-cancel-webrtc'),
)
```

Unfortunately, this too doesn't work since we could end up detecting 1.1
(the hole in the middle) which is invalid.

Instead, we do a bit of checking for tristate values before deciding to
invoke `dependency()`. This lets us guarantee that disabled dependencies
are well and truly disabled.

Bug: https://bugs.gentoo.org/933218
Fixes: #3678
2024-06-11 07:16:30 +00:00
Wim Taymans
c85e7cadf1 impl-node: async driver nodes need to activate targets
When a driver is async it still needs to activate the targets or else no
targets will ever be triggered.

Fixes #4046
2024-06-10 16:32:13 +02:00
Wim Taymans
0d9a959ab6 Revert "context: add loader.rules"
This reverts commit cfeb937443.

Let's remove this for now, the node.rules and device.rules are mostly
used for this. We can add this later when there is a need for it.
2024-06-10 10:34:07 +02:00
Wim Taymans
9856500a13 module-spa: evaluate node and device rules
Before loading the node or device spa plugin, evaluate the node and
device rules so that we can use them to configure the plugin properties
when it is loaded.
2024-06-10 10:26:06 +02:00
Wim Taymans
74e340507a JACK: remove useless io_data member 2024-06-10 10:26:06 +02:00
Wim Taymans
b144aa24fa JACK: check the io of the right cycle
The port->io always points to a 2 item ptrarray of buffers so check
if there is actually a buffer for the current cycle instead.

Avoids a crash.
2024-06-10 10:26:06 +02:00
Wim Taymans
cfeb937443 context: add loader.rules
Add loader.rules that are executed right before the loader tries to load
the plugin with the info. This can be used to add or change properties
for the plugin.

One example would be to pass extra properties to the alsa or v4l2
plugin, even when this plugin is loaded by another process like
wireplumber.
2024-06-10 10:26:06 +02:00
Alexandre Rossi
d6c17681da
add alsa plugin profiles for HDMI/AC3 (Fix #3832) 2024-06-07 11:20:01 +02:00
Wim Taymans
4d7c81bd90 v4l2: support meta_videotransform on buffers
Advertise support for the videotransform metadata.
Make a new meta.videotransform.transform property to configure the
desired video transformation in the metadata.

This makes it possible for a session manager or other rules to set
a custom transformation on the source.

See #4034
2024-06-07 10:54:46 +02:00
Wim Taymans
6bb1d0476d spa: add enum type info for transformation 2024-06-07 10:54:46 +02:00
Stefan Ursella
898f854ca7 alsa-pcm: check if bound ctls are valid before using it.
When bound_ctl info cannot be read this array elem info
is set to NULL in 'fetch_bind_ctl'. So when we iterate
the bound_ctl array we always have to check this.
2024-06-07 07:21:45 +00:00
Benjamin Cook
45758ecb68 Fixed two small typoes in documentation: conneced -> connected. 2024-06-07 07:21:09 +00:00
Wim Taymans
1d9a00a66f v4l2: fix string size
vendor_id and product_id are encoded as 0xHHHH and so it needs 7 chars
with the 0.

See #4034
2024-06-06 16:25:24 +02:00
Wim Taymans
961134dc72 impl-node: improve xrun debug
We can now also detect xruns in the async nodes when we try to make them
NOT_TRIGGERED. Rework the debug of graph, sync and node xruns.
2024-06-05 15:37:15 +02:00
Wim Taymans
722e646f90 impl-node: add backwards compat for old clients
Bump the client-node version to 6. Older clients expect the server to
prepare the activation counters so make a flag to do that.
2024-06-05 15:37:15 +02:00
Wim Taymans
46f71b1cd2 Rework how targets are managed
Manage them like we do on the client and reuse logic. Make a node
function to safely add and remove a target.

Activate the targets from the process loop when we can be sure that we
can resume them. This avoids incrementing the pending state when we are
not going to be able to resume the nodes (like when the cycle is ongoing
and we have already been scheduled) and avoids glitches and xruns.

When a node is added to the poll loop, it can activate its own targets.
This is mostly for driver so that they have something to schedule and
can then activate the other targets.

Try to resume the target when it is removed and we are supposed to be
scheduled.

Also add targets to the target_list when the node is remote to make sure
the profiler can see the targets as well.

Keep the node in the INACTIVE state as long as the eventfd of the node
is not added to the loop. Skip nodes in the INACTIVE state from going to
the NOT_TRIGGERED status, which avoids scheduling the node.

Make sure we remove any local targets we have in a node when we export
it, we will receive new targets from the server.

This should eliminate any glitches when adding and removing nodes from
the graph.

See #4026, #2468
2024-06-05 15:37:15 +02:00
Tristan Cacqueray
ce985def73 loop: clarify the pw_main_loop_run returned value 2024-06-04 15:34:59 +00:00
Wim Taymans
05abc4e41f jack: rename a function
Add/remove_link is more what this function does.
2024-06-04 17:15:54 +02:00
Wim Taymans
fa154955af jack: update the eventfd from the data loop
Also update the variables we use from the data loop.
2024-06-04 17:14:02 +02:00
Wim Taymans
1e9a557c06 module-ffado: keep track of transfered data
When for some reason we don't manage to transfer data from the source
or to the sink (timeout, scheduling problems..), try to do it when we
get a timeout to avoid xruns.
2024-06-04 16:53:56 +02:00
Jonas Holmberg
1deffe757c profiler: Decrease memory usage
Make flush buffer initially smaller and increase it when needed.
2024-05-31 07:29:47 +00:00
Silviu Florian Barbulescu
e4432190f7 Add broadcast sink support for multiple BISes 2024-05-30 13:37:27 +00:00
George Kiagiadakis
d1a6b8f23f ci: bump fedora version to 40 and alpine to 3.20
Latest alpine has gstreamer 1.24, which we should be compiling against because
the DMA_DRM code paths are not compiled with older versions. Unfortunately,
this is yet not in fedora 40.

Latest fedora is bumped just because. We should always test against latest
fedora and the previous ubuntu LTS, to make sure we support a relatively wide
range of system versions.
2024-05-30 13:31:34 +00:00
Robert Mader
e6f2aa6ce0 gst: src: Improve DMA_DRM caps selection
The translation between Pipewire parameters and Gstreamer caps is,
for compatibility reasons, ambiguous. Formats with linear modifier
are translated both in the legacy way as `format`, as well as
`drm-format`.

When finishing negotiation and setting caps, ensure that we:
1. set caps that the peer actually supports in order to prevent
   negotiation errors.
2. fixate caps to DMA_DRM if both options are supported, using the newly
   introduced helper, in order to prevent hangs.

While on it, add some small clean-ups that hopefully make the code
easier to follow, notably that `pwsrc->caps` and `pwsrc->possible_caps`
are only used during negotiation.
2024-05-29 19:29:02 +02:00
Robert Mader
05b1c9d0c8 gst: Add helper to fixate DMA_DRM caps
When support for modifier-aware DMA_DRM formats was added in f1b75fc6,
the translation between Pipewire parameters and Gstreamer caps was kept
compatible with the] non-DMA_DRM/legacy API by reporting format/modifier
combinations with linear or invalid modifier both as `format` and
`drm-format`.

In cases when a linear modifier ends up being negotiated, this, however,
resurts in non-fixated caps, preventing the negotiation to succeed.

Add a helper that allows to fixate such caps.
2024-05-29 19:05:53 +02:00
Robert Mader
adead74e8c gst: src: Indentation fix
Fixes: f400ff205 (gst: Check for video/ caps before parsing for info)
2024-05-29 18:52:06 +02:00
George Kiagiadakis
68711290bd gst: sink: post an element error when all buffers are removed abruptly
When the link on the pipewire side is destroyed, on video streams, buffers
are removed abruptly and there is no way this pipeline can be revived,
so let's post an element error to stop it.

On a normal shutdown, the pool is first set to flushing in change_state(),
so checking for the flushing state is a good indicator to know if this
is a normal shutdown or not.

See #1980
2024-05-29 10:39:31 +03:00
George Kiagiadakis
ef5f5d4c3c gst: pool: remove unused variable of unknown type 2024-05-29 10:39:31 +03:00
George Kiagiadakis
0b7a62ae02 gst: sink: improve debug messages related to buffer management 2024-05-29 10:39:31 +03:00
George Kiagiadakis
1e2618f314 gst: pool: add explicit remove_buffer method
This is for readability and better control.
Make sure we clear out all pointers to anything related to the released
pw_buffer, including all the memories.
2024-05-29 10:39:31 +03:00
George Kiagiadakis
40fd2553ea gst: pipewirepool: remove dead code 2024-05-29 10:39:31 +03:00
Vlad Pruteanu
0b5f716526 bluez5: bap: Support Mono Channel Allocation
The Bluetooth SIG Assigned Numbers Document has been updated and a
value of 0 for the Channel Allocation is now allowed, with the
meaning of "Mono".
2024-05-28 16:42:08 +03:00
Wim Taymans
eaa3d04bcc impl-node: update required state atomically
We might be updating the required state from multiple threads in the
future.
2024-05-28 13:11:15 +02:00
Arun Raghavan
315dc7cdad gst: sink: Fix some object-less debug messages
We have the object, so there's no reason to skip that in the logs.
2024-05-28 13:47:30 +03:00
Arun Raghavan
1e3797512a gst/src: Check for 0 framerate before setting duration
This is possible if the source doesn't provide the framerate (as is the
case for libcamera), or if the framerate is variable (0/1).
2024-05-28 13:47:30 +03:00
Arun Raghavan
169e5ecd4b stream: Fix reference to pw_time.now in pw_stream_get_nsec() docs 2024-05-28 11:47:17 +03:00
Arun Raghavan
3cc5ca5a91 gst/src: Set buffer duration
We compute this from the clock quantum for audio and the negotiated
framerate for video.

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1438
2024-05-28 08:18:47 +00:00
Arun Raghavan
2f9a5e0694 alsa: Use hw:X for accessing card ctl
In ACP mode, we might be accessing front:0 as the PCM, and using that
string to generate the ctl device name does not make sense. In
PulseAudio, we used the card index to generate a hw:X string, and we
replicate that here.

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4028
2024-05-28 10:39:24 +03:00
Silviu Florian Barbulescu
5be2f5e096 Resolve problems found on review 2024-05-27 16:08:36 +00:00
Barnabás Pőcze
625c0f5784 Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Barnabás Pőcze <pobrn@protonmail.com>
2024-05-27 16:08:36 +00:00
Silviu Florian Barbulescu
1259829ac3 Remove device and transport for broadcast source on interfaces_removed 2024-05-27 16:08:36 +00:00
Silviu Florian Barbulescu
ab87eba149 Add support for the broadcast source multiple BIS implementation in BlueZ. 2024-05-27 16:08:36 +00:00