Commit graph

1037 commits

Author SHA1 Message Date
Julian Bouzas
ca7109b37b policy-node: add check to not relink more than 5 times if link with peer fails 2021-11-09 08:18:44 +00:00
Julian Bouzas
d47df77c55 policy-node: lookup the proper peer link when handling linkable
Previously, we were always looking for the first available link on the item,
which could lead to problems if the item had more than 1 link (eg target and
monitor links). Now, we keep the Id of the last target in order to determine if
the item is linked to the proper target when rescanning.
2021-11-09 08:18:44 +00:00
Peter Hutterer
b2a5b6c303 systemd: document the service files for split mode
https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/84#note_1117863
2021-11-09 16:06:12 +10:00
Julian Bouzas
4d5f9591fc policy-node: make sure 'taget.node' property has a valid Id before waiting 2021-11-03 10:37:03 -04:00
George Kiagiadakis
ff9b49064d default-routes.lua: add missing break in best route selection logic
Fixes #86
2021-11-01 12:14:04 +02:00
Julian Bouzas
0ee144a466 scripts: escape semicolon when serializing and parsing array 2021-11-01 10:00:52 +00:00
George Kiagiadakis
51713d309a policy-{node,endpoint-device}: do not hold reference to si_link in closure
This may keep the link alive for longer than expected
2021-10-23 11:02:13 +03:00
Julian Bouzas
04f77a5fbc policy-endpoint-client.lua: refactor based on policy-node.lua 2021-10-21 14:03:15 -04:00
Julian Bouzas
a03995c212 policy-endpoint-device.lua: refactor based on policy-node.lua 2021-10-21 14:03:15 -04:00
George Kiagiadakis
f8ced47a1a policy-node: enforce the direction of the target when linking by node name
When node.target is set to contain a node's name, it is possible to run
into the situation where you have a sink and a source with the same name
(typically the case with module-loopback) and the sink has monitor ports,
so wireplumber may link the stream to the monitor of the sink instead of the
capture ports of the source

With this policy, if a stream really wants to link to the monitor of the sink,
it has to have the "stream.capture.sink" property set or specify the
target by id.
2021-10-19 13:04:58 +03:00
George Kiagiadakis
1bdb8c2fb3 policy-node: don't rescan in the timeout callback if the si was already destroyed 2021-10-18 13:33:07 +03:00
George Kiagiadakis
634f73eb2d policy-node: don't hold a reference to the session item in the timeout callback
... it causes the si to be kept around even after the node is destroyed
2021-10-18 13:30:20 +03:00
George Kiagiadakis
4ab119778a policy-node: when node.target is specified, wait a bit for the target to be available
There is a chance of race condition here in case the client knows which target
it wants to link to, but wireplumber has not yet "seen" this target because
it is getting prepared asynchronously

This may stall for up to 2 seconds clients that start streams with an invalid
node.target property, but then they will be re-routed to the default node
2021-10-15 15:10:41 +03:00
George Kiagiadakis
2a21e005e0 policy-node: avoid searching for existing links if there is no reason
If the item was not already handled or if there is no target,
we don't need to search for existing links... we will not find any

Also, don't remove links or schedule rescan if the node is not eligible
for reconnection... we will delete the node below instead
2021-10-15 15:10:28 +03:00
George Kiagiadakis
b27eccb9f0 policy-node: improve debug messages 2021-10-15 15:06:34 +03:00
George Kiagiadakis
7e0eeb485c restore-stream.lua: do not remove target.node manually
This is now done by the metadata implementation.
Doing this manually causes assertion failures, because then the
target.node is removed before policy-node "unhandles" the associated
session item and it tries to re-link it to the default source/sink
2021-10-15 14:37:49 +03:00
George Kiagiadakis
c444ebaae1 meson: replace deprecated dep.get_pkgconfig_variable() with dep.get_variable() 2021-10-15 12:12:20 +03:00
Peter Hutterer
e308fd56a0 meson: give the wireplumber binary a variable name
This allows it to be accessed from pipewire when WP is built as a
subproject.
2021-10-15 08:14:03 +00:00
Ashok Sidipotu
784c405c31 wp: support loading optional modules
-some modules will not be available during runtime, due to
  external dependencies.
 -these modules can now be marked optional.
 -loading of these optional modules will be attempted and if
  they are not available, wp will recover and will not be
  terminated.
2021-10-14 06:27:53 +00:00
George Kiagiadakis
d26aeeb192 policy-node: accept TRUE as a valid boolean property value
when coming from a gstreamer element's stream-properties property,
the boolean values use capitals:

 gst-launch-1.0 ... ! pipewiresink stream-properties="p,foo=true"
 pw-cli info <node>
   -> "foo" = "TRUE"
2021-10-13 13:17:52 +03:00
George Kiagiadakis
5dcd06c339 policy-node: implement encoded audio passthrough
* also respect node.exclusive
* also send error to clients if a target node was not found
  or if it is not possible to link to it
* also allow dont-reconnect nodes to be handled normally
  the first time they appear, until they are linked once
2021-10-13 12:48:03 +03:00
Julian Bouzas
f7a6aaab61 default-routes: switch to the route when availability changed 2021-10-12 11:41:51 -04:00
Wim Taymans
51e29b1bca policy-node: add support for passive links
When one of the nodes has node.passive, make a passive link.

Make virtual sinks and sources suspend properly when not in use.
2021-10-11 12:40:44 +02:00
George Kiagiadakis
1b48e068ce systemd: alias to pipewire-session-manager.service
See #56 and pipewire/pipewire!970
2021-10-08 15:18:12 +03:00
George Kiagiadakis
0938f9bc84 policy-node: do not try to link monitors in no-dsp mode, as they do not exist
pipewire does not implement monitors in no-dsp mode yet
2021-10-08 11:05:09 +03:00
George Kiagiadakis
914867bd13 policy-node: cleanup target.node metadata when the default sink changes
When the default node changes to become the same as the target.node value
that was set in the metadata, remove this target.node from the metadata
to let the stream follow the default.

Also cleanup the useless target.node == -1 metadata that pipewire-pulse sets
when a stream is moved to the default node

Fixes #65
2021-10-08 01:10:30 +03:00
George Kiagiadakis
8671b495be policy-endpoint-client: decrease log message verbosity 2021-10-08 00:26:41 +03:00
George Kiagiadakis
e76c67c45c policy: refactor/improve policy-node & session items to fix linking to monitors
* populate most session item properties from create-item.lua to keep
  things more compact and readable
* use a standard naming scheme for the session item properties
* use session item properties instead of node properties in policy-node.lua
* improve policy-node's performance by converting the properties dictionary
  less times for each session item
* refactor some policy logic and make things slighly more readable
* change the accepted values for 'context' in wp_si_linkable_get_ports();
  use "input" and "output" to keep things clear, because the previous use
  of NULL and "reverse" were implying that a node has only one "standard"
  direction, but this is complicated for sinks w/ monitors and duplex nodes
* allow using monitors (which are Audio/Sink nodes in fact) as sources
* treat Audio/Duplex nodes as sinks, like p-m-s does
* respect the "stream.capture.sink" property of streams

Fixes #66
2021-10-08 00:26:41 +03:00
Wim Taymans
7907d39aff scripts: add libcamera monitor 2021-10-06 10:22:36 +02:00
Wim Taymans
a13308bac7 implement route-settings metadata and notification volume
Make a module that creates a route-settings metadata and provides
some helper functions to parse the json fields.

Load the route-settings module in the policy.

Move the Notification settings to the metadata. Listen for metadata
updates and update our state table.

Fixes #51
2021-10-05 15:47:46 +00:00
Wim Taymans
8c82265752 restore-stream: don't include the final : in the key name
Just make the key and let the user of the key add a separator when
needed.
2021-10-05 15:47:46 +00:00
Wim Taymans
65d5f6442b restore-stream: stop when we find the first suitable key 2021-10-05 15:47:46 +00:00
Wim Taymans
8e7331a23d default-routes: save and restore iec958Codecs
Similar to the volume and latencyOffset we need parse, save and restore
the configured iec958Codecs on the node.

Pavucontrol will use the device-restore extension to set the configured
iec958Codecs on the Node/Route. This will make the node enumerate
audio/iec958 formats, which can be matched against streams that can
provide this format to configure passthrough.

Fixes #64
2021-10-04 10:11:03 +00:00
George Kiagiadakis
2a99d6a835 default-access: grant full permissions to flatpak "Manager" apps
Fixes: #59
2021-10-04 09:20:53 +03:00
Julian Bouzas
151ba8425e m-si-audio-adapter: add 'disable.dsp' configuration property
If 'disable.dsp' is set to TRUE, the adapter will always be configured in
passthrough mode. Then, if 2 adapters want to be linked with different formats,
the si-standard-link session item will automatically reconfigure one of the
adapters in convert mode so that the format matches.
2021-09-29 14:03:27 -04:00
Pauli Virtanen
e9b7d02b22 config: bluez: update to match current bluez5 spa module
Update 50-bluez-config.lua from media-session.d/bluez-monitor.conf
2021-09-29 19:18:18 +03:00
George Kiagiadakis
2bc999594c main: fail to start with a warning if media-session is also running
Related to #56
2021-09-28 11:45:49 +03:00
George Kiagiadakis
a253aa4c49 modules: implement logind module and integrate with bluez monitor
This copies the logic of media-session's logind module and allows
the bluez monitor to be active in only one user session at a time.
This is especially useful to avoid interference between the gdm
session and the actual user session, which momentarily both have
wireplumber running when logging in/out.

Fixes #54
2021-09-27 18:30:32 +03:00
Julian Bouzas
450a38da50 scripts: handle dbus service restarts if reserve device is enabled
This destroys the ALSA monitor when the DBus connection is closed, and
re-creates again the monitor when the Dbus connection is connected, so that
device reservation is restarted.
2021-09-24 08:53:50 -04:00
Julian Bouzas
9dd5c0c758 systemd: add GIO_USE_VFS=local environment variable
Avoids GIO to connect to the session bus. This prevents wireplumber to receive
a SIGTERM signal when the dbus service is restarted.
2021-09-23 09:40:07 -04:00
Peter Hutterer
841a1055fb main: print the type of signal that stopped us
Unfortunately glib's signal handling doesn't pass the signal type to the
handler but it's easy enough to wrap.

Related to #48
2021-09-23 20:15:51 +10:00
Ashok Sidipotu
33d4e61b97 alsa-monitor: add check for nill monitor 2021-09-20 10:43:33 +05:30
Niklāvs Koļesņikovs
3b41df35a8
v4l: add basic check for nil monitor
If PipeWire is built without V4L support, then

`monitor = SpaDevice("api.v4l2.enum.udev", config.properties or {})`

will result in a nil monitor. This commit adds a basic sanity check
to avoid further using the nil variable.

Thanks-to: Pascal Flöschel (initial bug report)
Thanks-to: George Kiagiadakis <george.kiagiadakis@collabora.com>
Bug: https://bugs.gentoo.org/813043
2021-09-15 13:54:03 +03:00
Niklāvs Koļesņikovs
32d96189b8
bluez: add basic check for nil monitor
If PipeWire is built without Bluetooth support, then

`monitor = SpaDevice("api.bluez5.enum.dbus", monitor_props)`

will result in a nil monitor. This commit adds a basic sanity check
to avoid further using the nil variable.

Thanks-to: Pascal Flöschel (initial bug report)
Thanks-to: George Kiagiadakis <george.kiagiadakis@collabora.com>
Bug: https://bugs.gentoo.org/813043
2021-09-15 13:52:29 +03:00
Julian Bouzas
640b6b217c policy-node: schedule pending rescan if old link is not active
Removing a link before it finished activating can lead to race conditions. If
the link is not active, we should schedule a pending rescan to make sure the
old link is only removed when active. This should fix the proxy activation
failed warnings.
2021-09-14 13:48:22 -04:00
Julian Bouzas
910273cba7 policy-node: don't try to link to the same link-group
Avoids linking streams to a node of the same link-group because that
would be a circular link.
2021-09-14 08:44:10 -04:00
Julian Bouzas
8f19c00b3e policy-node: re-evaluate all nodes when changed
This is needed so that client nodes can be moved to new default device nodes
when they are added if wireplumber is already running.
2021-09-14 08:43:21 -04:00
Björn Daase
f769e2ea36 50-alsa-config.lua: Add missing commas
Be consistent with all other files and add commas at the end of sections.
2021-09-10 08:53:34 +00:00
George Kiagiadakis
8949e98d1f remove wpipc
This component has been split out to form a separate project,
moved to https://git.automotivelinux.org/src/pipewire-ic-ipc/
2021-08-19 16:53:28 +03:00
George Kiagiadakis
c3d48e57d4 systemd: remove AssertPathExists from the templated units
The config files can now be in multiple places, so there is no
good way to check if a file exists before starting wireplumber.
2021-08-19 10:33:55 +03:00