Commit graph

2335 commits

Author SHA1 Message Date
George Kiagiadakis
fbecc50319 lua: api: bind json-utils functions 2023-11-07 16:36:49 +02:00
George Kiagiadakis
89ac416e99 lib: add new json-utils set of functions
The purpose is to wrap some utilities that pipewire provides that use JSON.

Start by wrapping pw_conf_match_rules(), which despite its name, it has nothing
to do with the configuration object. It operates directly on JSON and can be
useful to work with match rules outside the context of configuration files.
2023-11-07 16:36:49 +02:00
George Kiagiadakis
d45c5eb623 s-create-item: add some debug logging 2023-11-07 16:36:49 +02:00
Barnabás Pőcze
5e48a2afc1 meson.build: set WIREPLUMBER_CONFIG_DIR in devenv
This is needed for wireplumber to start up correctly in the meson
devenv when built as a subproject of pipewire. The reason for this
is that the value set for `PIPEWIRE_CONFIG_DIR` in the wireplumber
meson build file will be overriden when the pipewire meson files
set up another devenv with its own `PIPEWIRE_CONFIG_DIR`.
2023-11-03 03:24:23 +01:00
Julian Bouzas
f5a29981aa linking: use si_props for 'target.*' properties
This avoids indexing the Lua table every time the properties are accessed.
2023-11-02 16:09:48 +00:00
Julian Bouzas
8ac96f4a37 linking: handle 'target.linger' property
When set to 'true', the node will remain alive without any error produced if
it cannot be linked to its specified target; in all other cases, an error will
be produced and the node will be destroyed.
2023-11-02 16:09:48 +00:00
Julian Bouzas
970050d3b5 linking: handle 'target.dont-fallback' and 'target.dont-move' properties
Two new properties are available to change the behavior of the linking policy:
 - target.dont-fallback: when set to true, the node shouldn't be allowed to
fallback to another available target other than the one specified in the
target.object property or metadata.
 - target.dont-move: when set to true, wireplumber should ignore the
target.object metadata, so that it isn't possible to dynamically move the node
to another target using metadata.

See #524
2023-11-02 16:09:48 +00:00
Julian Bouzas
a6bacde2c8 link-target: set was_handled flag when link was created
fixes 'node.dont-reconnect' property when the node was linked before.
2023-11-02 16:09:48 +00:00
Julian Bouzas
a2469b5b39 find-defined-target: don't stop processing if defined target is not prepared yet
This is an old hack that was needed before the event dispatcher was implemented,
and therefore is not needed anymore.
2023-11-02 16:09:48 +00:00
Pauli Virtanen
0809a89442 tests: script-tester: fix locking of test-server
Calling functions on test server must lock the thread loop, otherwise
the concurrency causes corruptiont in module-protocol-native and you get
bogus messages etc.
2023-11-01 21:00:55 +02:00
Pauli Virtanen
e0b09e7a76 main: try to connect preferably to the manager socket
Try to connect to the default manager remote, before trying the default
remote.

Check libpipewire version is new enough to support setting arrays.
Bump Pipewire version to have pw_check_library_version.
2023-10-30 20:00:57 +00:00
Barnabás Pőcze
47ebc33de5 internal-comp-loader: fix WpSpaJson memory leak
Previously, the `deps` variable was reused for parsing
the required and wanted dependencies of a component,
which lead to the old value allocated here:

  if (wp_spa_json_object_get (json, "requires", "J", &deps, NULL)) {

being leaked when a bit later

  if (wp_spa_json_object_get (json, "wants", "J", &deps, NULL)) {

succeeded.

Fix that by using two separate variables.
2023-10-30 19:53:55 +00:00
Julian Bouzas
c9dc02d941 rescan: make sure disabled smart filters are unlinked before rescanning
This patch improves the smart filters unlinking logic by only unlinking smart
filters that are disabled, instead of any kind of filters. The patch also
removes redundant filter hooks.
2023-10-26 08:15:09 -04:00
Julian Bouzas
6980f9ff5d filter-utils: always evaluate filters before 'linking/rescan' hook
Fixes smart filters not being linked correctly when starting wireplumber if no
clients are playing/capturing audio.
2023-10-25 10:34:40 -04:00
George Kiagiadakis
dbf8204cf9 Revert "api: module: support loading arguments from file"
This reverts commit 2ae1b3cbd9.

This is not a good API. It was only allowed temporarily in 0.4.15
to get things done. We should approach this properly in 0.5
2023-10-24 11:55:52 +03:00
George Kiagiadakis
22cb31571d Revert "link: add WP_LINK_FEATURE_ESTABLISHED to track when a link is PAUSED/ACTIVE"
This reverts commit 9def3f96d2.

This was never a good idea, as it turns out. It was not used in practice because
it was breaking other things (see 370b692933)
and now it appears to be causing more problems in Lua object managers that don't
install because they are waiting for inactive links to become active.

Fixes: #518
2023-10-24 11:31:45 +03:00
George Kiagiadakis
eb6f569be8 Merge branch 'master' into next 2023-10-24 11:09:52 +03:00
George Kiagiadakis
23ba01970f object-manager: use an idle callback to expose tmp globals instead of pw_core_sync
A core sync is not really necessary here because whatever objects the remote
pipewire daemon has to announce have already been sent to us on a message
and this message is already being processed at this point. This means, we are
not going to be returning to the main loop until all the new objects have been
announced and therefore placed into the tmp globals array. So, we can also use
an idle callback and achieve the same effect of slightly delaying until all
new globals have been announced.

With an idle callback, we can be more agile and add those new objects immediately
after the message has been processed instead of waiting for a pw_core_sync()
reply, which will come in the next message.

This fixes an odd failure of the si-standard-link test after applying the fix
for #517, which was caused by the fact that the test was previously relying on
a delay caused by some unrelated globals being prepared in the object manager
that tries to verify the graph state. After those globals were removed from the
internal preparation queue, the test would fail to detect the link objects
because they were stuck in the tmp_globals array for too long.
2023-10-23 23:14:48 +03:00
George Kiagiadakis
5fc7e68d10 object-manager: reduce the amount of globals that initially match the interest
With the previous check, any global matching either the type or the global
properties of the interest would be considered for inclusion in the object
manager and would be prepared only to fail the same check later.

The correct way to check is (variable & (X|Y) == (X|Y)), which is what
SPA_FLAG_IS_SET() expands to.

Fixes #517
2023-10-23 23:04:02 +03:00
t123yh
b6c1fdb2e1 scripts: Fix typo in autoswitch-bluetooth-profile.lua 2023-10-23 09:50:38 +00:00
Barnabás Pőcze
6d01627cd0 wpctl: use auto cleanup for the WpCtl object
This is already done for `WpDaemon` and `WpExec`, so let's do it
here as well. This prevents some memory leaks in error paths,
which makes it easier to find real issues in the ASan output.
2023-10-22 23:02:35 +02:00
Matt Horan
686048d6fa docs: Provide example for iec958.codecs config 2023-10-19 12:11:36 -04:00
Julian Bouzas
388acb6ff3 scripts: Fix bluetooth profile autoswitch
This patch updates the deprecated policy-bluetooth.lua script so that it works
with the current version. The script has been moved into the device sub-folder,
and renamed to autoswitch-blueooth-profile.lua. The settings-manager is also
used for the configuration, and the actual configuration has been moved from
linkind.conf to bluetooth.conf.
2023-10-19 11:24:42 -04:00
Pauli Virtanen
c91dcaa046 access: set pipewire.access.effective property on clients
Report the resolved access level in pipewire.access.effective property,
so that the final level is visible in pw-dump.
2023-10-17 21:06:31 +03:00
Pauli Virtanen
199671dfa3 access: handle pipewire.client.access and flatpak status
Handle client-requested and flatpak access on the session manager side.

Pipewire daemon doesn't know about the intended permission hierarchy, so
it is better done on the session manager side, where all the rules are.
2023-10-17 21:06:31 +03:00
Pauli Virtanen
7a369b70dc access: support new "default" pipewire.access value
The "default" access is used for normal clients, in the use case where
Pipewire server will not assign permissions itself but leaves it to the
session manager. In this use case only session manager has
"unrestricted".

Make "default" equal to "unrestricted" in the default access
configuration.
2023-10-16 19:54:19 +03:00
Pauli Virtanen
7f495b63eb lua: add new Client.update_properties() API
This allows Lua scripts to update properties of other clients.
2023-10-15 21:27:14 +00:00
Pauli Virtanen
bf082964d4 client: add wp_client_update_properties
Add Wp interface function for pw_client_update_properties.
2023-10-15 21:27:14 +00:00
Pauli Virtanen
b65f8884a5 m-lua-scripting: check argument type is table to avoid crashing
In conf_apply_rules, check input argument is a table before assuming it
is and potentially crashing.

Add check also in wplua_table_to_properties to avoid similar bugs.
2023-10-13 22:47:57 +03:00
George Kiagiadakis
d67b48e595 0.4.15 2023-10-12 19:24:26 +03:00
George Kiagiadakis
ffd6c0dfb9 docs: fix warnings related to recent policy-dsp changes
- remove dsp.rst, since it's empty and not in the toctree
- fix g-i function param annotation
2023-10-12 19:24:26 +03:00
Wim Taymans
69ed77042f config: set priority. keys on midi-bridge
So that it can be used as a fallback driver.

See pipewire#3562
2023-10-12 12:01:05 +02:00
Ronan Pigott
b2bfb1b917 wpctl: add zsh completions 2023-10-10 07:07:16 +00:00
Dmitry Sharshakov
5faab4e8c2 policy-device-profile: set default and best by device.profile 2023-10-02 14:52:45 +00:00
Julian Bouzas
4ad263b16c scripts: add new 'filter.smart' property
This allows users to enable/disable smart filter policy per filter. The property
is considered false by default, meaning that smart filter policy is disabled for
all filters by default.
2023-10-02 10:44:46 -04:00
Julian Bouzas
7044226f66 scripts: use 'filter.smart' prefix for smart filter properties 2023-10-02 10:44:46 -04:00
Julian Bouzas
0b44d9cf84 scripts: change filter.enabled property to filter.disabled
Avoids confusion with default value if the property is not defined.
2023-10-02 10:44:38 -04:00
George Kiagiadakis
1e40108d94 linking-utils: rename unwrap_find_target_event -> unwrap_select_target_event 2023-09-30 12:06:40 +03:00
George Kiagiadakis
c7b00599d7 scripts: remove 'active-features' session item constraints
I don't fully remember where this originates from, but it looks like
some sort of hack to workaround a race condition where the event handler
would try to iterate over items that were just created and were not yet
fully ready to be used.
2023-09-30 11:10:30 +03:00
George Kiagiadakis
6af88b283c linking-utils: cleanup duplicate functions 2023-09-30 11:02:02 +03:00
George Kiagiadakis
43aa2d4952 scripts: don't use 'local' for file-wide scoped variables
Since all scripts run in a sandbox with their own global environment,
it means that they don't interfere with each other's global variables.
Therefore, all file-wide variables can be declared global without
any change in behavior. In my understanding, it is better to do so
because this means that any code accessing those variables is going
to access them directly from the global environment table with a simple
lookup rather than having each variable referenced in the local closure
of each function separately.
2023-09-29 23:13:28 +03:00
George Kiagiadakis
2f89c64b7f docs: add documentation on device, default-nodes and linking scripts 2023-09-29 16:14:08 +03:00
George Kiagiadakis
493be2fae6 event: annotate key in wp_event_get_data 2023-09-26 10:11:36 +03:00
Ashok Sidipotu
d4f3e2bdca tests: replace "policy" with "linking" 2023-09-26 10:09:47 +03:00
Ashok Sidipotu
0dcd28e50f Lua scripts: replace "policy" with "linking" 2023-09-26 10:09:03 +03:00
Ashok Sidipotu
1f92767d4b config: replace "policy" with "linking" 2023-09-26 10:07:57 +03:00
Ashok Sidipotu
70b781ed64 steam.conf: enhance the illustration of the config 2023-09-26 10:06:03 +03:00
Ashok Sidipotu
9aeaf7367e bluetooth.conf: change the syntax for rules from Lua to JSON 2023-09-26 10:03:44 +03:00
Ashok Sidipotu
f4d421988c access.conf: uncomment the rules the way they were before 2023-09-26 10:03:07 +03:00
George Kiagiadakis
6d7232a1fd settings: correct class description 2023-09-26 10:00:43 +03:00