Commit graph

6266 commits

Author SHA1 Message Date
Wim Taymans
aef99f840f Revert "gstpipewiresrc: break out of wait_started() also on STATE_UNCONNECTED"
This reverts commit 7465175ad0.

wait_started() is called before the stream is connecting and so
exits with an error immediately, which then makes the stream start
too early and block.
2023-11-16 09:51:11 +01:00
Jonas Holmberg
0ecc7ca5f5 module-rt: Remove RLIMIT_RTTIME while trying rt policy
Trying rt scheduling policy while RLIMIT_RTTIME is set could result in
SIGXCPU if the limit is exceeded. Set an infinite limit temporarily
while checking if rt policy is allowed.
2023-11-15 17:11:19 +01:00
Wim Taymans
0278695e7d modules: add tunnel.may-pause option for pipe-tunnel
To override the default may-pause behaviour of streams.
2023-11-15 13:02:08 +01:00
Wim Taymans
63385cedd0 modules: add pause support for pipe-tunnel
Streams are allowed to pause/resume when the pipe xruns.
Wait for IO_IN or IO_OUT when the ringbuffer xruns to resume playback or
capture.

Fixes #3197
2023-11-15 12:52:10 +01:00
Wim Taymans
142b660e7b modules: make better media.name for RAOP sink
Use the destination in the media.name so that it becomes unique and the
volumes can be restored per destination.

Fixes #3801
2023-11-14 15:06:42 +01:00
WalkerGriggs
03b1d9589b
modules: Check for opus custom functions in addition to headers 2023-11-10 09:57:53 -08:00
George Kiagiadakis
7465175ad0 gstpipewiresrc: break out of wait_started() also on STATE_UNCONNECTED
When the session manager sends an error to the client, it typically
also destroys the node after the error, which causes the stream to go
to STATE_UNCONNECTED via proxy_removed(). In that case, make sure
we exit the loop early, otherwise it will take 30 seconds to unblock
gst_element_set_state()
2023-11-09 20:59:40 +00:00
George Kiagiadakis
a852b979b6 gst: avoid reporting error twice
First, make the error permanent by calling pw_stream_set_error()
and when this emits an error state again, report that to GStreamer.

Do the same in pipewiresink, which didn't even have the
pw_stream_set_error() call before, so the stream wasn't really going
into an error state at all.
2023-11-09 20:59:40 +00:00
Pauli Virtanen
72c9fba6d2 module-protocol-native: emit error on bad concurrency
Emit error if message construction is not holding appropriate locks or
runs from wrong thread, so that the flush may be running concurrently.

This generally causes corrputed messages to be sent silently, and can be
fairly hard to debug otherwise in client applications.
2023-11-07 18:07:32 +00:00
Barnabás Pőcze
b832a94f5d pipewire: utils: make pw_strv_find() take a const char *
There is no reason to take just a `char *` as the string only ever read.
2023-11-06 19:01:20 +01:00
Jonas Holmberg
0163d4d440 systemd: Limit system manager socket permissions
Remove group permission on the system manager socket so that restricted
clients cannot use it to get unrestricted access. It is assumed that the
session manager system service (wireplumber) is running as pipewire user
and will get access to the manager socket, while other clients are
members of the pipewire group and will only get access to the normal
socket.
2023-11-06 15:02:10 +00:00
Wim Taymans
35b115fd6c context: stop scanning on feedback links
If we have a feedback link around a driver, stop scanning for
runnable nodes or else we will be looping forever.

Fixes #3621
2023-11-06 15:56:36 +01:00
James Calligeros
70d2b0eeb4
module-rt: enable setting UCLAMP_MIN and UCLAMP_MAX values
Modern heterogenous multiprocessor systems rely increasingly on
scheduler hinting for efficiency gains and system optimisation.
This is especially true on embedded systems, where background
tasks such as audio daemons should be consigned to the most
power-efficient core in the system. Left to its own devices, the
Linux Completely Fair Scheduler tends to migrate Pipewire to
more performant cores, even when this is unnecessary.

Luckily, CFS can be told by a task to clamp its utilisation values.
Coupled with energy-aware scheduling, this allows the scheduler to
make better informed decisions about where tasks should be placed,
and what pstate to set for the CPU it is running on.

Enable the user to configure UCLAMP_MIN and UCLAMP_MAX values via
arguments to libpipewire-module-rt.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2023-11-06 18:43:46 +10:00
Pauli Virtanen
33db334765 doc: link \page and \group by \see 2023-11-04 15:22:18 +02:00
Wim Taymans
90e4ee94ec context: limit recursion in run_nodes
Limit the amount of recursion in run_nodes() for now until we find out
why it keeps on recursing.

See #3621
2023-11-03 15:40:41 +01:00
jdavidsson
baac9aa549 impl-link: reset state to INIT if not destroyed
If the link isn't destroyed, don't allow changing state to
PAUSED for states < PAUSED. For example, if the deactivation
is called during the link being in NEGOTIATING it could then
jump directly to PAUSED and believe it is prepared.

Fixes #3619
2023-11-03 10:01:48 +01:00
Théo Lebrun
38157a8937 pw-top: fix version constant used for pw_node_events
This changes the value declared (3 currently versus 0 following this
patch). I have not seen code checking this version number.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2023-11-02 12:42:50 +01:00
Wim Taymans
bdb7f3adc8 gst: don't stop streaming when paused
We pause when we are unlinked, don't stop the streaming thread because
then we won't be able to resume when we are linked again.

Fixes #3620
2023-11-02 10:06:03 +01:00
Wim Taymans
353efbd790 context: fix indentation 2023-10-31 11:33:23 +01:00
Wim Taymans
98d44d9757 impl-node: support multiple link-group and group
Support an array for the node.group and node.link-group properties.
This makes it possible to make a node member of multiple groups and
link-groups.

See #3612
2023-10-31 10:58:49 +01:00
Wim Taymans
72fa74ff57 utils: add some utility functions for working with strv
Add function to parse strv from relaxed json syntax.
Add some functions to find a string or the first common string.
2023-10-31 10:57:25 +01:00
Wim Taymans
2ff62641b9 context: when forcing rate/quantum don't limit latency
Usually, the max-latency is calculated by the device when it is
configured based on the maximum buffer size and limits the latency
change that can be done.

When we are forcing a rate/quantum and we are going to reconfigure the
device, this limit should not apply because the current buffer settings
and latency are going to change because of the reconfigure.

See #3613
2023-10-30 11:18:55 +01:00
Michael Tretter
e4def0ce18 pipewiresink: use maximum size of buffers to configure pool
For encoded formats, buffer size is the size of the actual data in the
buffer and may change for each frame depending on the content. Thus,
configuring the buffer pool of the pipewiresrc with the size of the
first buffer may be insufficient for later buffers.

Configure the buffer pool to the maximum size of the first upstream
buffer and assume that the following buffers will be allocated with the
same size as the first buffer.
2023-10-27 18:01:37 +02:00
Michael Tretter
efa08e9892 gst: update buffer size only if format defines a size
For encoded formats, p->video_info.size will be 0. If the pipewiresrc
handles an encoded format, the bufferpool will be configured to allocate
buffers of size 0. This will cause errors later when trying to copy the
frames into the pipewire buffers.

Update the bufferpool size only if video_info defines an actual buffer
size.
2023-10-27 18:01:37 +02:00
Michael Tretter
bd15e5275b pipewiresink: copy metadata into pipewirepool buffers
If the pipewiresink needs to copy the GStreamer buffers to the PipeWire
buffers, because the upstream element didn't use the pipewirepool, the
metadata must be copied, too. Otherwise the pipewire datas will be
filled with the metadata from the buffer during the initialization and
not the currently used buffer.

For example, without copying the metadata the buffer timestamp will be
missing on the pipewire buffers.
2023-10-27 18:00:51 +02:00
Michael Tretter
9a72766ae8 pipewiresink: fix type of SPA_META
The SPA_PARAM_META_type must be configured as a SPA_POD_Id, not as
SPA_POD_Int. Otherwise, PipeWire won't allocate the metas.
2023-10-27 17:44:32 +02:00
Michael Tretter
109567ed3d conf: fix videotestsrc example configuration
In JSON, the colon actually is used for assignment, but in spa_type_info
the colon is used as a separator. To properly parse and pass the
properties to the videotestsrc, the key has to be enclosed by quotation
marks to prevent splitting by the JSON parser.
2023-10-26 16:35:30 +02:00
Michael Tretter
63865307d9 conf: set description for test nodes
Commit 9b29bcd4e8 ("conf: set description for test nodes") set the
description only for the minimal.conf and pipewire.conf and skipped the
pipewire-vulkan.conf.

Set the description for pipewire-vulkan.conf, too.
2023-10-26 16:33:49 +02:00
Arun Raghavan
5617fa0501 module-rtp-sap/sink: try to bind sockets to an explicit interface 2023-10-24 07:17:21 +00:00
Pauli Virtanen
963ea1f57c tools: make pw-dump/mon/top try to connect to the default manager socket
These tools are used for debugging, and should default to connecting to
the manager socket if present.
2023-10-24 07:08:07 +00:00
Pauli Virtanen
9eaf1184c2 module-protocol-native: multiple names to try in PW_KEY_REMOTE_NAME
Allow PIPEWIRE_REMOTE / PW_KEY_REMOTE_NAME to contain a JSON array of
sockets to try to connect to, in order, instead of just one name.

JSON is restricted to utf-8 encoding. Also, this forces using JSON
syntax for paths that start with '['. This probably will not usually
cause much problem.
2023-10-24 07:08:07 +00:00
Wim Taymans
970a837670 filter-chain: add mult and sine plugin
mult is to multiple samples, sine to generate a sine wave. This can be
used to make a tremolo effect.
2023-10-23 11:14:51 +02:00
t123yh
7fa64a8b71 example: fix invalid free() operation in bluez-session
obj->handle should not be directly freed; instead, it should be
freed using "pw_unload_spa_handle", otherwise there will be
segmentation fault.
2023-10-22 14:48:44 +00:00
t123yh
8848923d82 examples: add props to bluez-session to prevent quirk parse error
In bluez5-dbus.c:impl_init, the info is passed to spa_bt_quirks_create,
which expects info to be non-null. But in this example, info is null, so
it will cause quirk table parse failure. Add an empty dict here to prevent
this error.
2023-10-22 14:48:44 +00:00
Wim Taymans
69134f8d3e filter-chain: add linear operation to dsp 2023-10-22 10:50:03 +02:00
Wim Taymans
1b09c4a2cc filter-chain: add more math functions
Add clamp, recip, exp, log
2023-10-22 09:41:05 +02:00
Wim Taymans
3eed0fbe9b gst: mark streams async
From the process callback we signal a cond and don't dequeue/queue
a buffer directly.
2023-10-21 09:42:15 +02:00
Wim Taymans
93d5848031 module-echo-cancel: playback and source are async
The playback and source streams don't dequeue/queue buffers from
the process function and so need to be marked async.

Fixes #3593
2023-10-21 09:27:43 +02:00
Wim Taymans
0ff4844d87 filter-chain: remove some debug 2023-10-20 20:39:06 +02:00
Wim Taymans
8a9a4723f2 filter-chain: add linear transform filter
Transforms samples or control with v * mult + add
2023-10-20 20:37:50 +02:00
Wim Taymans
07696d5d57 filter-chain: also handle notify ports as dependencies
The links from the notify ports to other nodes decrement the
dependencies.

See #3596
2023-10-20 17:29:55 +02:00
Wim Taymans
80afa3a296 impl-link: fix log 2023-10-20 16:18:41 +02:00
Wim Taymans
81437f7a77 impl-link: refactor function to update busy_count
This also makes sure the busy_count of a previous busy_id is undone when
setting a new id.

Also logs an error when the busy count goes negative.
2023-10-20 15:11:46 +02:00
Wim Taymans
5a93d77acf impl-link: ensure busy_count and busy_id stay in sync
We can only increment or decrement the busy_count with a valid busy_id.

In complete_ready and complete_paused, the id can be INVALID and if
there was no pending busy_id, it would decrement the busy_count below 0.

This would block the link from progressing its state change.

See #3547
2023-10-20 12:26:41 +02:00
Wim Taymans
3d8c7c40b5 stream: improve queued_buffers reporting
Also add the queued buffers in the converter to the pw_time.queued_buffers
field. This means that queued_buffers + avail_buffers always equal the
total amount of allocated buffers, which makes more sense.

Fixes #3592
2023-10-20 09:57:52 +02:00
Wim Taymans
cb26ea2dfa conf: add missing =
Fixes #3589
2023-10-20 07:52:21 +02:00
Wim Taymans
42418bece5 impl: destroy node and device in global free
Destroy the node and device in the global free event. This way, the
global resources are already destroyed and we have removed their ref to
the spa node before we destroy that.

Fixes #3588
2023-10-18 18:51:48 +02:00
George Kiagiadakis
8735d07c0a combine-stream: add support for "on-demand" streams
Instead of just following static target match rules to create output streams,
this feature allows the user to dynamically create more output streams
with custom targets using metadata.
2023-10-17 19:38:03 +03:00
Pauli Virtanen
f89757e1f6 module-access: add access.socket option + legacy mode, remove other options
Add access.socket option, which sets PW_KEY_ACCESS based only on which
socket the client connected from.

Remove the executable-based permissions and all old options.  Add
access.legacy=true option that enables the old default behavior.  The
legacy mode cannot be used together with the socket-based access.

Emit warnings if any of the removed old options have been set.

Set pipewire.sec.flatpak=true for Flatpak applications.

The socket-based access ignores PW_KEY_CLIENT_ACCESS and the Flatpak
status when setting PW_KEY_ACCESS.  Dealing with them becomes
responsibility of the session manager (or equivalent) which processes
the permission rules.

Make the default access.socket value compatible with the
module-protocol-native default two-socket configuration.

However, if neither access.socket or access.legacy is specified, we will
for now use the legacy mode for backward compatibility.
2023-10-16 22:17:44 +03:00
Pauli Virtanen
3d32291711 module-protocol-native: use two-socket server by default
If no socket configuration specified for a server, create two sockets,
"CORENAME" and "CORENAME-manager" where CORENAME is the value computed
by get_server_name.
2023-10-16 22:17:44 +03:00