Commit graph

716 commits

Author SHA1 Message Date
George Kiagiadakis
9def3f96d2 link: add WP_LINK_FEATURE_ESTABLISHED to track when a link is PAUSED/ACTIVE
This allows to transparently wait until a link is PAUSED before
returning from the activation transition. This way we can also
catch negotiation/allocation errors while activating a link.

PAUSED is used instead of ACTIVE because ACTIVE depends on the
nodes being activated as well. There are cases where a link may not
activate the nodes (ex, a passive link) and the link may remain
PAUSED for a long time.

Related to: #294
2022-07-02 17:10:22 +03:00
George Kiagiadakis
efaaf3b43a lua: add Core.get_vm_type() method 2022-06-28 14:06:48 +03:00
George Kiagiadakis
261ccf9972 si-node: skip control ports from the list of ports to be linked
Related to: #294
2022-06-28 10:52:49 +03:00
George Kiagiadakis
ba30a4fcec si-audio-adapter: skip control ports from the list of ports to be linked
Related to: #294
2022-06-27 17:35:29 +03:00
Julian Bouzas
0996f5a5ca spa-json: add wp_spa_json_to_string() API
Since the string length returned by wp_spa_pod_get_data() does not always match
the size of the actual json object because it is stored in contiguous memory, we
cannot always rely on that API to get the json string data.

The new wp_spa_pod_to_string() always allocates a new string with the same
length as the json size, guaranteeing that the string returned always represents
the json object, regardless of whether it is nested or not. It is always
recommented to use wp_spa_pod_to_string() unless you know what you are doing.
2022-06-27 10:07:16 +00:00
Julian Bouzas
76d87813a1 m-default-nodes: reevaluate nodes when ports changed
Currently, if the default node appears without ports for a short period of time,
the default nodes module will never select it immediately because it does not
listen for port changes. We want to listen for port changes to reevaluate again
the nodes that did not have ports before. This allows switching to the default
node as soon as it has ports if it did not had ports before.
2022-06-27 08:52:36 +00:00
Julian Bouzas
04198820f1 device: add new wp_spa_device_managed_object_new_iterator API 2022-06-27 08:52:36 +00:00
Julian Bouzas
46e7c5c144 m-reserve-device: use WpDbus API 2022-06-02 12:34:16 -04:00
Julian Bouzas
69b559399d modules: move all portal-permissionstore code into one file 2022-06-02 12:34:16 -04:00
Julian Bouzas
2c53486e0d m-portal-permissionstore: use WpDbus API 2022-06-02 12:34:16 -04:00
Michael Olbrich
13b85bd4a2 m-lua-scripting: fix object refcounting
7908b8d7be2a2992c57cd549054eda7ce46e4b44 ("m-lua-scripting: allow
converting GValue holding NULL objects to Lua") accidentally added a second
refcount. As a result, the objects are never freeded.

Remove the second refcount to fix this.
2022-05-24 11:40:35 +02:00
Julian Bouzas
392cce2136 m-default-nodes: don't check if all device nodes are ready when finding default node
This check was originally added to avoid a small audio glitch when changing
default nodes while also changing the device profile (eg Gnome Sound Settings).
The check is removed because it causes issues when disabling alsa nodes. There
are plans to fix the audio glitch issue in the future with the planned
event-dispatcher architecture.

Fixes #279
2022-05-20 13:39:47 +00:00
Julian Bouzas
c2f31bb550 m-lua-scripting: allow converting GValue holding NULL objects to Lua 2022-05-19 07:43:12 -04:00
George Kiagiadakis
2eed279c9d i18n: remove the module and embed the gettext calls into the lua api
There is no need to have this as an optional module, since libintl
is a hard dependency of both PipeWire and GLib. This way we can keep
things a bit simpler and faster (no string copies and plugin lookups)

Bump meson dependency to 0.59 to benefit of the libintl lookup that
is now built into meson's dependency() function.
2022-05-10 15:16:09 +03:00
Julian Bouzas
07179452e2 m-lua-scripting: add WpSiAdapter APIs 2022-05-05 08:09:21 +00:00
Julian Bouzas
1675b37617 si-adapter: add ports state change signal 2022-05-05 08:09:21 +00:00
Krisztian Kovacs
8af6f3df1c modules/logind: be more specific when creating the login monitor
We're only interested in notifications for user state changes, so we should
better be more specific about it when creating the systemd login monitor.

This avoids issues with sd_login_monitor_new() returning EINVAL if
systemd-machined is not running (and thus /run/systemd/machines does
not exist).
2022-05-02 08:27:43 +00:00
George Kiagiadakis
7b8e3e8088 m-mixer-api: fix channelVolumes array iteration in set-volume
Fixes: #250
2022-05-02 11:02:40 +03:00
George Kiagiadakis
81af8c2069 lua: sandbox: remove all traces of the minimal_std flag, as it's no longer used 2022-04-23 20:14:59 +03:00
George Kiagiadakis
ecb6100b77 m-lua-scripting: wrap every script in a WpPlugin and expose async activation api
This allows scripts to declare when they have finished their loading,
so we can now also know when wireplumber is done loading and ready to
handle clients

Related to !313
2022-04-23 20:14:59 +03:00
George Kiagiadakis
031bc65c20 lua: sandbox: relax the sandbox to allow more functionality in scripts
This enables the debug and coroutine libraries and some more functions
that are not really so risky to have around

Related to #121
2022-04-23 20:14:59 +03:00
George Kiagiadakis
9387ce0d95 wplua: implement reference counting of the lua_State 2022-04-23 20:14:59 +03:00
George Kiagiadakis
9c22f6076a wplua: enable the use of require() to load lua libraries from scripts/lib 2022-04-23 20:14:59 +03:00
George Kiagiadakis
e1d0240bc9 wplua: split the functionality of the load functions into smaller functions
The load functions used to do 3 things:
- push the sandbox function on the stack
- load the file and push it as a function on the stack
- call the sandbox (or the file)

Now there are separate functions to do these 3:
- wplua_push_sandbox
- wplua_load_*
- wplua_pcall
2022-04-23 20:14:59 +03:00
Pauli Virtanen
bbe9ac00f3 modules: add m-i18n
Add simple gettext i18n module.

Add Lua script API functions I18n.gettext, I18n.ngettext.
2022-04-11 19:20:43 +03:00
George Kiagiadakis
17a257ddbe wplua: move under modules/module-lua-scripting
It's unlikely that wplua will ever be useful outside the context
of module-lua-scripting, so let's move it to keep all the code in one place
2022-03-24 09:47:59 +02:00
Wim Taymans
afbc0ce57a si-audio-adapter: relax format parsing
Some nodes can omit the format/rate/channels to indicate that they can
deal with all possibilities and adapt to what they are linked to.

See pipewire#876
2022-02-25 16:47:09 +00:00
Julian Bouzas
b3446efa16 config: port device-activation module to policy-device.profile.lua
Because all wireplumber policies are in Lua.
2022-02-16 13:37:40 -05:00
George Kiagiadakis
ca906362cd lua-scripting: expose WpImplMetadata on the API 2022-02-03 13:04:55 +02:00
Julian Bouzas
b1b603443f restore-stream: use the new Json API and remove route-settings-api module 2022-02-02 18:37:39 +00:00
Julian Bouzas
384c5775f8 default-nodes: add option to auto-switch to echo-cancel nodes
This option is enabled by default now.
2022-01-27 14:55:21 -05:00
Julian Bouzas
b0ddd6f890 m-lua-scripting: add Json.Raw constructor 2022-01-26 09:53:24 -05:00
Julian Bouzas
46ab414a04 spa-json: fix coverity scan issues 2022-01-25 21:18:16 -05:00
Julian Bouzas
5bef0f240f default-nodes: use WpSpaJson API 2022-01-25 07:40:59 -05:00
Julian Bouzas
20187e07b5 m-lua-scripting: add WpSpaJson API 2022-01-25 07:20:35 -05:00
Julian Bouzas
95e7c4abe8 m-default-nodes-api: add API to get and set default configured node name 2022-01-25 09:57:33 +00:00
Julian Bouzas
10531e95b5 default-nodes: reevaluate when device params changed
Some devices have different nodes for speakers and headphones. In that scenario,
this change notifies the policy to re-link all clients to the new default node
when the user plugs and unplugs the headset.
2022-01-24 16:18:31 -05:00
George Kiagiadakis
93d3051966 Revert "default-nodes: increase priority if node has available routes"
This reverts commit ad80faaa8d.

The same issue is fixed by the intermediate commit by Wim. Let's revert
this to keep the logic in-sync with policy-node.lua and media-session.
2022-01-14 17:55:24 +02:00
Wim Taymans
211f1e6b6c default-nodes: handle nodes without Routes
When a node has not part of any EnumRoute, we must assume it is
available.

Fixes selection of Pro Audio nodes as default nodes.
2022-01-14 16:32:04 +01:00
Julian Bouzas
ad80faaa8d default-nodes: increase priority if node has available routes
Fixes #163
2022-01-14 09:15:08 -05:00
Julian Bouzas
8844cfb074 device-activation: show device name in logs 2022-01-12 19:27:17 -05:00
Julian Bouzas
b4245d64c5 default-nodes: add more logs 2022-01-12 19:26:49 -05:00
Julian Bouzas
75281d8681 default-nodes: check if default node has available route
Fixes #145
2022-01-12 07:16:08 -05:00
Julian Bouzas
07a0a5b404 default-nodes: check if the ports exist in rescan_om
Ports might not be ready in the node's port object manager yet.

Fixes #153 and #150
2022-01-12 09:48:36 +00:00
Julian Bouzas
0d008dce75 m-default-nodes-api: don't return stream node if default node name matches
Stream nodes can never be default nodes, so we skip them in case they have the
same name as the actual default node.

Fixes #130
2022-01-06 06:50:32 +00:00
Julian Bouzas
a1423a4b1f m-device-activation: reset iterator when finding best and default profiles
Avoids possible issue when finding best profile when default is not found.
2022-01-05 08:54:12 -05:00
Corentin Noël
b6dd422dd2 si-audio-adapter: Reference WpTransition before passing it as callback data
Make sure to always have a valid WpTransition when used in the finish callback.

Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
2022-01-05 10:28:33 +01:00
Julian Bouzas
f7dfb90db6 module-default-nodes-api: sync with core before emitting changed signal
This makes sure pipewire is not doing anything while emitting changed signal.
2022-01-05 08:57:33 +00:00
Julian Bouzas
8bbbba23ff m-default-nodes: don't reevaluate nodes if they are not ready
This makes sure nodes are ready before finding the default node, avoiding audio
glitch in wrong device if profile was also changed while changing the default
node (can happen with Gnome Sound Settings).

Since nodes are destroyed and recreated again when a device profile changes, the
only way to make sure device nodes are ready is to check the profile classes
structure, which tell us how many total nodes the device has, and then check
that those nodes exist for that device. A rescan is triggered whenever devices,
nodes or ports changed.

This patch also improves the logic when finding default nodes, allowing virtual
sources to be set as default sources.

Fixes #85 and #130
2022-01-05 08:57:33 +00:00
Julian Bouzas
76a61e43a5 m-default-nodes: set effective node metadata to NULL if node is not found
There might not be any node at all, so we need to clear the efective node
metadata.
2022-01-05 08:57:33 +00:00