Commit Graph

12619 Commits

Author SHA1 Message Date
Wim Taymans
e045ef0e4c impl-node: add compat with old nodes 2024-06-14 12:41:03 +02:00
Wim Taymans
c89a68b0b4 impl-node: handle node <-> driver links with node_peer
Also handle the relation between a node and the driver with pw_node_peer,
like we do with the links.

Because these are refcounted, we only make one peer for a node that is
linked to another node that is also the driver (pw-play -> sink) and we
save some fds as well as some admin stuff and overhead for the refcounts.

This in return then results in less problems getting all the refcounts
right when adding/removing nodes.
2024-06-14 11:52:59 +02:00
Vlad Pruteanu
1466d0ae78 bluez5: bap: Use a string instead of int array to set Broadcast code
Currently, the user sets the Broadcast Code via an array of integers
in the config file. However, the Bluetooth Core Specification indicates
that it should be set via a 16 byte string. This commit replaces the old
implementation with the one required by the spec.

Tested the commit with the example provided in the Core Spec:
Broadcast Code: Børne House
Result from btsnoop log:
< HCI Command: LE Create Broadcast Isochronous Group (0x08|0x0068) plen 31
...
Broadcast Code[16]: 000000006573756f4820656e72b8c342

The result matches the example given in the spec.
2024-06-14 06:05:14 +00:00
Wim Taymans
b7af52e3fb impl-node: partially revert target rework
We can't let a client decrement the required state because if it crashes
or fails to decrement, the graph becomes unschedulable.
2024-06-13 17:40:55 +02:00
Wim Taymans
b421331275 doc: clarify the dither.noise
Fixes #4057
2024-06-13 11:38:26 +02:00
Wim Taymans
0115042adb buffer: add that the mapoffset is page aligned 2024-06-13 10:22:58 +02:00
Wim Taymans
9592b0af2a examples: fix mapoffset in examples
The mapoffset should be using in the mmap call as the offset.

Mapping the whole memory before the offset and then ignoring the part
before it seems like it can work but it actually has some problems:

1. some drivers (v4l2) use the mapoffset to calculate the buffer to map
2. we waste resources for mapped but unused pages.

The problem with the mapoffset is that it needs to be page aligned and
that used to be a problem in the past. Nowadays PipeWire no longer set
the mapoffset for any of the memory that it allocates.
2024-06-13 10:11:29 +02:00
Barnabás Pőcze
eed7eb1556 pw-dump: sync on metadata change so that changes are displayed soon
In order to show metadata changes when monitoring, a sync must be
triggered just like it is done for other objects, to make sure that
`dump_objects()` is called some time later and the changed metadata
objects are shown.

Otherwise metadata changes would never be displayed unless there
was a change to a different type of object, whose event handlers
do trigger a sync.

Fixes #4053
2024-06-13 00:04:11 +02:00
Wim Taymans
d04a28daef impl-node: clean up the configuration of the Position io area
Set the new IO Position after we removed the node from the old driver
and before the new driver is going to schedule the node. This makes
a little more sense.
2024-06-12 09:56:57 +02:00
Wim Taymans
1d0d67da1c jack: queue free of old mem in node_set_io as well
Avoid freeing the old io Position area before the data loop has managed
to get a pointer to it. Queue a free operation that will be executed
from the main loop after the data loop has the io area.

Fixes a crash when stressing jack clients to switch between drivers.
2024-06-12 09:54:12 +02:00
Arun Raghavan
9da01413a1 gst: sink: Disable active state setting when going to PAUSED
On first start, the stream is set to be active when connected. However,
when the element is going to PAUSED and not subsequently to PLAYING,
this is incorrect behaviour.

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4049
2024-06-12 06:58:44 +00:00
Michael Tretter
a9bf5fa24a gst: fix JPEG format
Since commit f400ff2050 ("gst: Check for video/ caps before parsing
for info") JPEG support in the GStreamer elements is broken as JPEG is
not recognized as a video format anymore.

gst_video_info_from_caps is able to handle "video/" and "image/"
formats. Therefore, the check needs to allow "image/" too.

While at it, cleanup the formatting to make the check more readable.
2024-06-12 06:56:03 +00:00
Michael Tretter
3b68b5088b gst: pipewiresrc: move correct brace under HAVE_GSTREAMER_DMA_DRM
The HAVE_GSTREAMER_DMA_DRM belongs to the inner brace, not the outer
brace, since the inner if statement is under HAVE_GSTREAMER_DMA_DRM.

While doesn't make a difference to the compiler, but confuses a reader.

Put the other brace under the HAVE_GSTREAMER_DMA_DRM.
2024-06-12 06:56:03 +00:00
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