Commit graph

14316 commits

Author SHA1 Message Date
Wim Taymans
f1e1f720bf adapter: fix Start of adapter
Commit cbbf37c3b8 changed the logic of the
Start command. Before this commit, when there was no converter, the
follower would always get the Start command. After the commit, the
follower would only get Start when previously Paused.

This however breaks when we set a format or buffers on the follower
without a converter because those actions might change the state of the
follower to Paused implicitly.

We should simply remove the started check here and always call Start on
the converter and follower, the implementations themselves will keep track
if anything needs to be done.

Fixes #4911
2025-09-24 12:36:13 +02:00
Pauli Virtanen
2e2f7c9f79 alsa: don't fail if 3 periods_min fails
Some drivers (emu10k1) appear to not necessarily support more than 2
periods.

Don't fail start if snd_pcm_hw_params_set_periods_min() fails, then we
just set nearest possible periods and buffer sizes.
2025-09-23 07:21:29 +00:00
lumingzh
f0a5f09420 update Chinese translation 2025-09-23 07:20:19 +00:00
Wim Taymans
3c921acb48 impl-port: rework port properties
Don't update info.props all the time, just once when we create the
properties, the dict will not change after that.

Move the port property check code to a new function. Keep track if we
auto generated path, name or alias and if we explicitly update it or
not.

Listen for node property changes and update the port properties if
necessary. Some of the port properties or feature depend on the node
properties so we want to keep those in sync.
2025-09-22 14:30:09 +02:00
Wim Taymans
ad33ff34f7 doc: fix some spelling, grammar and formatting mistakes 2025-09-22 11:24:23 +02:00
Wim Taymans
0267a5906e doc: add DSP filter tutorial
Add CLAUDE generated tutorial7 based on the audio-dsp-filter
example.
2025-09-22 11:01:52 +02:00
Wim Taymans
6bc451cf6d timer: fix compilation on arm 2025-09-19 16:16:25 +02:00
Wim Taymans
12464ed1bb impl-port: copy node.terminal and node.physical properties
Make 2 new node properties to make all ports of a node terminal or
physical.

Skip the monitor ports for this, though, they can never be terminal or
physical.

This is important for JACK clients that often enumerate physical
terminal ports in order to link to them and with this you can make JACK
clients link to virtual sinks and sources as well.
2025-09-19 15:58:56 +02:00
Wim Taymans
00d983a40d meta: add metadata features
Add a new features property to the metadata param. This should be
of type CHOICE_FEATURES_Int and should contain the extra features
supported by this metadata.

Make a special features metadata type that is a combination of the
metadata type in the upper 16 bits and the features for that type in the
lower 16 bits. Make a function to search if a type has certain feature
bits.

On the server, when negotiating buffers and metadata, check the result
of the features after filtering and if they are not 0, place them as
0 sized extra feature metadata on the buffer.

Add some metadata features for the sync_timeline, one that specifies
that the RELEASE flag is supported. With this in place, a producer can
see if a consumer supports the UNSCHEDULED_RELEASE flag.

See #4885
2025-09-19 14:05:04 +02:00
Wim Taymans
a859c7a651 builder: add support for FEATURE choice
This is the same as the Flags choice but the property (if any) has the
DROP flag set.

This means that when filtering, the property is dropped when one side
is missing the property. Otherwise, the flags are AND-ed together with a
negotiation failure when the result if 0.

This can be used to make sure both sides present compatible feature bits.
The result of the filter is then:

  1. no property (one side didn't present bits). This is likely because
     the other side is old and doesn't know about the feature bits yet.
     Code can take a backwards compatibility codepath.
  2. a negotiation failure, both sides presented bits but the AND is 0,
     they don't have compatible features.
  3. a property with bits (features) that are compatible.

This is different from normal flags in that the flags are not dropped
when the other size is missing the property.
2025-09-19 13:40:52 +02:00
Wim Taymans
b57c6d3729 examples: count the params as we add them
Count the params as we add them to the param arrays and use that to
update the stream params instead of using hardcoded indexes and sizes.

This makes it easier to add params and it also revealed a miscounted
param.
2025-09-19 13:08:22 +02:00
Wim Taymans
83242a5c3c buffers: small cleanup of the buffer allocation
Calculate the min_buffers separately and then use that to ensure we have
enough buffers. This makes it easier to increase the min amount later.
2025-09-19 09:17:47 +02:00
Wim Taymans
1717ff336e impl-port: init some stuff earlier
Initialize the mix_hooks, port_map and latency earlier, before we call
pw_impl_port_set_mix() and update_info, that could potentially expect
this to be initialized.
2025-09-18 15:21:50 +02:00
Wim Taymans
c296c52cae stream: avoid work at the end of the cycle
Driver output streams will start the cycle with a _trigger() operation,
which will call the process function (if necessary) to dequeue/queue a
buffer before starting the graph cycle. At the end of the cycle, the
internal stream process function is called again to recycle any buffers
but we should not try to dequeue a new buffer (if there was any in the
queue) and say that we have data.

Do this by keeping track of when the internal process function was
called because of trigger or because of the end of the cycle. At the end
of the cycle, we can call the trigger_end() but we should not prepare a
new buffer on the output io.
2025-09-18 15:08:24 +02:00
Wim Taymans
06efc8ffb6 pulse-server: clear timer when stream is created
Make a function when the stream is created so that we can clear the
create_tag and the timer.
2025-09-18 14:22:00 +02:00
Wim Taymans
ca713c08ee pulse-server: use the new timer-queue for timeouts
Use the timer queue for scheduling stream and object data timeouts.

This avoids allocating timerfds for these timeouts and the timer queue
can handle many timeouts more efficiently.
2025-09-18 13:55:43 +02:00
Wim Taymans
38cb14d39d timer-queue: add a new timer queue helper
This allows you to schedule timeouts. It keeps a sorted list of
timeouts and uses just 1 timerfd to schedule the head of the timeout
list.
2025-09-18 13:52:51 +02:00
Wim Taymans
361a0de85a pulse-server: make timer function static and fix formatting 2025-09-17 19:18:27 +02:00
Arun Raghavan
cfde4c1b17 pulse: Handle timed out streams
If we don't get a link on a stream, we might never send a create stream
reply. The client handles this fine by timing out after 30s and dropping
the stream, but the server holds on to the pw_stream forever (or until
the client quits).

Let's add a timer to clean up such streams on the server.

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4901
2025-09-17 11:48:27 -04:00
Wim Taymans
d5608c07c3 control: unit test for event sort
After some discussions with CLAUDE it made me this unit test, which
I think is ok and actually tests useful things.
2025-09-17 13:42:12 +02:00
Wim Taymans
707bd256b9 systemd: remove RestrictNamespaces from service file
Wireplumber loads the libcamera nodes into the pipewire server.
We need to remove the RestrictNamespaces option from the service file
to allow libcamera to load sandboxed IPA modules.
2025-09-17 10:21:10 +02:00
Wim Taymans
e6bcd7b611 doc: mention async link latency in latency doc 2025-09-16 14:09:08 +02:00
Wim Taymans
6305eada80 impl-port: add port.exclusive flag
Add a port.exclusive flag and inherit the value from the node.exclusive
flag if not otherwise specified.

Make it so that exclusive ports can only be linked once. This is
important for explicit sync where there can be only one producer and one
consumer in order to signal the timeline objects correctly.
2025-09-16 13:41:11 +02:00
Wim Taymans
83b59d6ebe pod: add SPA_POD_PROP_FLAG_DROP
The property will be dropped from the filtered result when one of the
pods to filter does not have the property.

This can be used as a feature mask. If side A provides a flags property
and B doesn't, the property will be removed from the result. Without the
flag, property A would be added and it would not be possible to see if
filtering happened (when B had compatible flags) or not.
2025-09-16 11:00:04 +02:00
Wim Taymans
03c5f493dc control: fix event compare function
We can only compare UMP when both types are 2 or 4, so it must be
different from 2 *and* 4 to be rejected.

Fixes #4899
2025-09-16 10:47:12 +02:00
Wim Taymans
af6571d0c7 test: fix assigment and compare error
Fixes #4898
2025-09-16 10:42:44 +02:00
Wim Taymans
336b2dbbc2 modules: remove output latency handling in raop sink
pw_stream now handles the other (output) latency for us, it will keep
the param and report it. If we are not interested in upstream latency we
don't have to parse and store it and we can just be concerned with the
latency we report on our input port (input latency).
2025-09-16 09:29:43 +02:00
Pauli Virtanen
9daf499fff ci: build pages only from master branch
The job on master branch builds pages for all versions at the same time.
It should not be run on branches.
2025-09-15 18:03:33 +00:00
Piotr Drąg
6686d5d1e6 Update Polish translation 2025-09-15 18:02:38 +00:00
Philippe Normand
96ac4ae10d pipewiresrc: Fix caps leak
pwsrc->possible_caps wasn't un-reffed before re-assignment.
2025-09-15 18:01:53 +00:00
Wim Taymans
4dccddd564 impl-link: add 1 quantum latency for async links
Update the scheduling doc with some information about how async
scheduling works. Also add something about the latency.

Async links add 1 quantum of latency so take that into account when
aggregating latencies.

Also a source directly linked to an async node does not add latency
(we evaluate the tee before incrementing the cycle so that it effectively
is executed in the previous cycle and consumed immediately by async
nodes). We can do this because the driver source always provides data
before the async node, and never concurrently.

Add a listener to the link for the node driver change as well because
that can now influence the latency for async nodes.
2025-09-15 17:42:03 +02:00
Wim Taymans
f89428d9f8 tools: print async node state in pw-top
Pass the node async state in the profiler and use this in pw-top to draw
the node with = instead of a + in the tree when it's async.
2025-09-15 12:29:57 +02:00
Wim Taymans
09cd7bf783 impl-node: only do unprepare once
There is not reason to do the unprepare logic twice and it might
actually interfere with the actions of the client.

See #4840
Fixes #4893
2025-09-15 10:22:16 +02:00
Wim Taymans
f81bb670c3 Revert "impl-node: improve the node unprepare function"
This reverts commit 2891e579a1.

This seems to cause regresssions with nodes xrun etc.

See #4893
2025-09-15 10:15:07 +02:00
Wim Taymans
9df770eb16 spa: support props flags building and parsing
Add an option to make a property with specific flags. Do this by
changing the parser and builder to see the invalid property as an escape
sequence followed by the property key and the flags.
2025-09-12 16:54:04 +02:00
Wim Taymans
41e6e875e5 spa: clean up the filter code
Use SPA_FLAG_IS_SET() and use the same if/else pattern.
2025-09-12 16:33:48 +02:00
Wim Taymans
818ef4e138 spa: flags just have 1 value 2025-09-12 16:17:26 +02:00
Wim Taymans
2be4c2ba51 meta: add SPA_META_SYNC_TIMELINE_UNSCHEDULED_RELEASE
This flag is set by the producer and should be cleared by the consumer
when it promises to signal the release point.

When a consumer dequeues a buffer with the flag set, it should assume
the client is not going to signal the release point and so it should
reuse the buffer right away. This can only happen when the client
didn't dequeue the buffer at all (killed, timeout, error, ...) or when
it dequeued and queued the buffer without clearing the flag.

See #4885
2025-09-10 13:43:51 +02:00
Wim Taymans
862ac1f7c8 examples: use BGRA as the format
RGB is not supported by videoconvert.
2025-09-09 16:40:42 +02:00
Wim Taymans
2891e579a1 impl-node: improve the node unprepare function
do_node_unprepare runs in both the server and the client when a node is
stopped. On the server size, set the status to FINISHED and trigger any
targets. This ensures the node will not be scheduled in this cycle
anymore. We have to do this because we can't know if the node is still
alive or not.

When the client receives the stop message, it will unprepare and set the
status to INACTIVE. This ensures the driver will no longer trigger the
node. If the server didn't already trigger the targets, do this in the
remote node then.

This avoid a race where both the client and the server are setting the
status and if the INACTIVE state is set by the server, it might stall
processing of the client.

Fixes #4840
2025-09-09 15:14:36 +02:00
Wim Taymans
d6488c5351 stream: decouple the requested size from scheduling
The docs say that a requested size of 0 can be returned and it means
that there is no suggestion for the size.

Make this so by decoupling the requested size value and the triggering
of the process callback. If we have no rate_match and no quantum
(because the driver didn't set it) we still want to schedule with a 0
requested size.
2025-09-09 15:11:45 +02:00
Wim Taymans
1e5a938e43 adapter: disable rate_match for the video adapter
We don't actually implement this for the video adapter. We should
ideally check for the SPA_IO_RateMatch param to decide this..
2025-09-09 15:10:12 +02:00
Wim Taymans
144c3630ea examples: fix texture updates 2025-09-09 14:29:18 +02:00
Barnabás Pőcze
0b08468035 pipewire: mem: pw_memblock_map(): fix pointer when reusing mapping
Previously the pointer was determined as follows:

  mm->this.ptr = SPA_PTROFF(m->ptr, range.start, void);

however, when `pw_map_range` is calculated, `pw_map_range::start` is the offset
from the beginning of the first page, starting at `pw_map_range::offset`.

This works correctly if `memblock_map()` runs because that will map the file
with expected offset, so using `range.start` is correct.

However, when a mapping is reused (i.e. `memblock_find_mapping()`) finds something,
then `range.start` is not necessarily correct. Consider the following example:

  * page size is 10
  * one memblock with size 20 (2 pages)
  * the applications wants to mappings:
    * (offset=5,size=10)
    * (offset=15,size=5)

After the first request from the application, a `mapping` object is created
that covers the first two pages of the memblock: offset=0 and size=20. During
the second request, the calculated `pw_map_range` is as follows:

  { start = 5, offset = 10, size = 10 }

and the only previously created mapping is reused since (0 <= 5) and (10 <= 20). When
the pointer of the mapping is adjusted afterwards it will be incorrect since `m->ptr`
points to byte 0 on page 0 (instead of byte 0 on page 1 -- that is assumed). Thereforce
the two will unexpectedly overlap.

Fix that by using `offset - m->offset` when adjusting the mapping's pointer. Also move
the `range` variable into a smaller scope because it only makes sense there. And add
a test that check the above previously incorrect case.

Fixes: 2caf81c97c ("mem: improve memory handling")
Fixes #4884
2025-09-08 11:38:42 +00:00
Barnabás Pőcze
93774b1d14 pipewire: mem: log page size on creation 2025-09-08 11:38:42 +00:00
Barnabás Pőcze
9d01a26242 pipewire: mem: forward declare spa_hook
This type is used in function arguments, so forward declare it.
2025-09-08 11:38:42 +00:00
Barnabás Pőcze
91b764faac pipewire-v4l2: support choice sizes
Add support for `SPA_CHOICE_{None,Enum,Step,Range}`. They can all
be naturally mapped to `v4l2_frmsizeenum`.
2025-09-08 11:36:24 +00:00
Barnabás Pőcze
cec0ab322e meson.build: set PW_BUILDDIR in devenv
This is needed by `pw-v4l2`.
2025-09-08 11:36:24 +00:00
Pauli Virtanen
589bc4b6f4 bluez5: iso-io: sync to ISO RX clock, align stream RX in group
Align RX of streams in same ISO group:

- Ensure all streams in ISO group have same target latency also for BAP
  Client

- Determine rate matching to ISO group clock from RX times of all
  streams in the group

- Based on this, compute nominal packet RX times, and feed them to
  decode-buffer instead of the real RX time. This is enough for
  sub-sample level sync.

- Customise buffer overrun handling for ISO so that it drops data to
  arrive exactly at the target, for faster convergence at RX start

The ISO clock matching is done based on kernel-provided packet RX times,
so it has unknown offset from the actual ISO clock, probably a few ms.

Current kernels (6.17) do not provide anything better to use for the
clock matching, and doing it properly appears to be controller
vendor-defined (if possible at all).
2025-09-07 18:26:03 +00:00
Pauli Virtanen
94c354c290 bluez5: decode-buffer: sub-sample accurate fill level tracking
Take resampler delay into account when computing the buffer fill level,
including the fractional part.

If decode-buffer is now fed nominal packet reference times in
write_packet(), it converges the total buffer + resampler latency to the
target at sub-sample accuracy.

This is needed for aligning RX of ISO streams in the same group, so that
e.g. stereo pair alignment is achieved even though the streams have
separate resamplers. Resampler phases get aligned via independent rate
matching.
2025-09-07 18:26:03 +00:00