Commit graph

474 commits

Author SHA1 Message Date
George Kiagiadakis
6939d8900a core: use log.level from the pw_context
And don't override PIPEWIRE_DEBUG, unless WIREPLUMBER_DEBUG is set.
This allows pipewire to use log.level as well to set up its logging.

If WIREPLUMBER_DEBUG is set, though, override PIPEWIRE_DEBUG to prevent
log.level from being used.
2021-04-21 19:03:47 +03:00
George Kiagiadakis
61876a97b9 log: factor out the log level configuration into wp_log_level_set()
Initialize the log level with WIREPLUMBER_DEBUG in wp_init()
2021-04-21 13:49:03 +03:00
George Kiagiadakis
44c96b6c49 impl-node: implement WpPipewireObject
This fixes adjusting volume for bluetooth nodes.
Previously, the spa device would request a software volume change
that we did not handle because WpImplNode was not a WpPipewireObject
and there was no way to set the Props param on it.
2021-04-16 20:02:54 +03:00
George Kiagiadakis
9b74fbc6ac device: debug and enhance spa device event handling 2021-04-16 20:01:56 +03:00
George Kiagiadakis
400aaf55ed wplua: store closures only with a weak reference
This allows closures to be properly unrefed when they are no longer
used instead of staying alive until wireplumber exits

Because GClosure has no weak references, we are now sharing the
GPtrArray that holds these references among all the active closures
and each closure is responsible for removing itself from the array
when it is finalized. The lua engine holds a reference to a "store"
object that also has a pointer to the array and when this "store"
is finalized, all closures are invalidated and removed. Even if they
stay alive afterwards, they are only holding a ref to an empty array
2021-04-13 21:14:12 +03:00
George Kiagiadakis
3485befc81 endpoint: remove useless pw_proxy_destroyed handlers 2021-04-05 16:03:55 +03:00
George Kiagiadakis
d264bc460c registry: fix issues with dangling WpGlobal objects causing assertion failures
The main problem observed is when a link that is owned by a WpLink
is removed from the server because one of the linked nodes is gone.
This would cause the APPEARS_ON_REGISTRY flag to go away but the
WpGlobal would still remain in the globals list...

To fix this, forcibly remove the global from the globals list when
it is removed from the registry, even if it is still owned by some
proxy. The proxy at that point is unable to function anyway, because
we make sure to destroy the pw_proxy by removing FEATURE_BOUND when
the global is removed from the registry.

Additionally, ref global->proxy before removing FEATURE_BOUND to
prevent crashing. If the proxy owns the global and the pw-proxy-destroyed
signal causes whoever owns the proxy to drop his reference, _deactivate()
will crash because no-one will be holding a ref to the proxy.
2021-04-05 16:03:55 +03:00
Julian Bouzas
fb1daa0bf2 modules: use dots instead of dashes for session item properties
Keeps consistency with PipeWire
2021-04-02 11:22:22 -04:00
George Kiagiadakis
5f1f96a5da registry: fix odd assertion failures that occured from time to time
The assumption about the global id in wp_registry_prepare_new_global()
was not valid because this function may also be called from the proxy
bound event and this may be before the registry has signalled the
removal of an old global with the same id, for instance

We should instead check this at the point where we expose the global.
If the assertion doesn't hold at that point, we are going to leak an
old WpGlobal, so we must ensure it.
2021-04-01 12:48:57 +03:00
Julian Bouzas
ec30336fcf session-item: add id property
Makes it easier when handling session items in Lua
2021-03-26 16:16:02 -04:00
Julian Bouzas
ebf52adb21 si-interfaces: make WpSiLink work with WpSiPortInfo instead of WpSiEndpoint 2021-03-26 16:16:02 -04:00
Julian Bouzas
64cf2bd644 si-interfaces: rename WpSiEndpointAcquisition to WpSiAcquisition
The get_endpoint_acquisition() vmethod has also been moved to WpSiPortInfo, and
therefore renamed to get_acquisition().
2021-03-26 16:16:02 -04:00
Julian Bouzas
13fc0adb22 m-si-standard-link: use a weak reference for in and out endpoints
Allows checking if the endpoints are still valid before releasing the
acquisition. Sometimes the endpoints are destroyed before the link, and
releasing acquisition is not needed. There is no way to check that with raw
pointers.
2021-03-26 16:15:38 -04:00
George Kiagiadakis
bed43a481a wplua: sort properties after transfering them from lua 2021-03-26 19:07:56 +02:00
George Kiagiadakis
eeccb24017 properties: add wp_properties_sort()
Depends on pipewire!555 to avoid breaking stuff
2021-03-26 19:06:06 +02:00
George Kiagiadakis
c1f1614eb6 object: deactivate only the features that were previously active 2021-03-25 18:13:11 +02:00
Julian Bouzas
17873c3ace object-interest: add support for session item properties 2021-03-18 14:30:11 -04:00
Julian Bouzas
3aef916d51 session-item: add _register and _remove API
Allows using object managers to listen for registered items
2021-03-18 14:30:11 -04:00
Julian Bouzas
120aab04ae session-item: refactor and inherit from WpObject
This adds WP_SESSION_ITEM_FEATURE_ACTIVE and WP_SESSION_ITEM_FEATURE_EXPORTED
features, so _activate and _export APIs have been removed. Modules and unit
tests have also been updated.
2021-03-18 14:30:05 -04:00
Julian Bouzas
5a11510e21 session-bin: remove unused wp_session_bin_new API 2021-03-18 12:10:37 -04:00
Julian Bouzas
5a1dfc02d2 lib: make WpImplEndpoint and WpImplEndpointLink public 2021-03-18 12:10:37 -04:00
Julian Bouzas
12b2c00d0b lib: remove WpEndpointStream API
Add all that goes with it.
2021-03-18 12:10:37 -04:00
George Kiagiadakis
9609a79903 wp_init: set PIPEWIRE_DEBUG
It is inevitable to avoid setting PIPEWIRE_DEBUG, because the
log.level from client.conf will kick in and change the pipewire log
level when the pw_context is created. PIPEWIRE_DEBUG is the only
way to override.
2021-03-16 17:45:30 +02:00
George Kiagiadakis
faff5c644c spa-device: do not assert if the activation transition fails 2021-03-16 16:15:32 +02:00
Julian Bouzas
5e69a82d4b object: add wp_object_activate_closure API 2021-03-13 20:10:30 -05:00
George Kiagiadakis
5a0a4532d7 lib: remove WpConfiguration
it's not used anymore
2021-03-04 19:11:53 +02:00
George Kiagiadakis
7eed2acd76 lib: documentation fixes 2021-03-04 19:10:10 +02:00
George Kiagiadakis
941b0324e5 object-interest: remove type checks
They are not strictly necessary and just make our life harder
2021-03-02 18:25:34 +02:00
George Kiagiadakis
9f50117fa7 lib: remove module.{c,h} 2021-02-25 17:12:04 +02:00
George Kiagiadakis
e2d6e5b992 lua: enable loading scripts with a shebang
* skip the shebang before loading the file in the interpreter,
  as # is not a valid lua comment
* allow loading scripts with a relative path in interactive mode
2021-02-18 13:47:34 +02:00
George Kiagiadakis
7c1fc1c567 wplua: table_to_properties: use luaL_tolstring to do string conversions
The advantage is that luaL_tolstring behaves the same as the native lua
tostring() function, while lua_tostring() does not. In particular, boolean
values are converted properly to "true" and "false" now, while they were
not converted with lua_tostring()

Add a unit test too
2021-02-16 16:53:22 +02:00
Raghavendra
c791ed3a62 m-lua-scripting: add WpPipewireObject api 2021-02-16 20:15:13 +05:30
George Kiagiadakis
e92351b23b wplua: gvariant_to_lua: convert dictionary keys to integers if possible
When we convert from a lua table to a GVariant dictionary, it is not
possible to maintain the hybrid string & integer keys approach that Lua
has for tables, so we convert all keys to strings and a table becomes a{sv}

When we convert back from a{sv} to a table, it is desirable to get back
the integer keys wherever possible.

The use case is to pass "arrays" (i.e. tables with integer keys) from
the configuration files to the lua scripts, without losing the properties
of the "array"
2021-02-15 18:50:56 +02:00
George Kiagiadakis
b3ff7347cd wplua: improve GVariant array conversion
* index array items from 1
* handle any kind of value, not just GVariant basic types
* unit test
2021-02-15 14:43:18 +02:00
George Kiagiadakis
dacf19d9c7 wplua: improve gvariant <-> lua conversion functions
* Add more generic lua -> gvariant conversion
* Cleanup the gvariant -> lua function and rename it
2021-02-15 14:43:18 +02:00
George Kiagiadakis
413ff73bab wplua: remove VARDICT handling in gvariant->lua conversion
G_VARIANT_TYPE_DICTIONARY also catches the VARDICT case
2021-02-15 14:43:18 +02:00
George Kiagiadakis
47b6417bbe object-interest: allow matching against WpProperties objects 2021-02-13 11:55:00 +02:00
Julian Bouzas
cbe90a5c75 wplua: handle more GVariant cases 2021-02-12 14:28:38 -05:00
Julian Bouzas
dc2ad1f25d rename all foo_iterate APIs to foo_new_iterator
Avoids confusion with LUA iterate API
2021-02-05 11:33:23 -05:00
George Kiagiadakis
7b37b31af9 wplua: fix enum <-> lua conversion
Sometimes the GEnumClass is not instantiated, so _peek() doesn't work
We need to acquire a strong ref to make sure it is
2021-02-05 12:00:24 +02:00
George Kiagiadakis
ce66025846 node: change send_command() to take a string
Use the spa type system to locate the enumeration value that corresponds
to that string and send that
2021-02-05 11:05:26 +02:00
Julian Bouzas
a634bf88fd wplua: fix vtables lookup in boxed __index function 2021-02-05 08:47:27 +00:00
George Kiagiadakis
096a9b4c15 proxy: add a method to query the interface type 2021-02-04 16:51:25 +02:00
George Kiagiadakis
e0f1c8710f daemon: add a mode to execute lua scripts from the command line
This can be useful for quick testing of scripts, or to build small
utilities that do something in pipewire utilizing our lua API
2021-02-04 16:44:56 +02:00
George Kiagiadakis
1c0f0b8684 wplua: pass SANDBOX_CONFIG as a script argument
avoids keeping it forever as a global
2021-02-03 17:16:51 +02:00
George Kiagiadakis
460ff6591d wplua: allow exchanging arguments and results with scripts 2021-02-03 17:16:51 +02:00
George Kiagiadakis
81d6f055a0 wplua: add GVariant dictionary conversion functions 2021-02-03 17:16:51 +02:00
George Kiagiadakis
a67116b0b9 wptoml: remove, it's not used anymore
and drop cpptoml dependency as well
2021-02-03 17:16:51 +02:00
George Kiagiadakis
29559b4065 wp: add wp_get_data_dir() 2021-02-03 17:16:51 +02:00
George Kiagiadakis
9fa17e04b4 object-interest: add a NOT_EQUALS verb 2021-02-03 17:16:51 +02:00