Commit graph

561 commits

Author SHA1 Message Date
George Kiagiadakis
3cd9384805 wp: make wp_get_xdg_state_dir() private
It's not used elsewhere, so there is no good reason yet to expose it.
Besides, I expect that GLib will likely add a method in the future
to return the XDG_STATE_HOME (which is relatively new in the xdg spec)
2021-08-19 10:06:37 +03:00
George Kiagiadakis
27ed36c2da wp: make the config file lookup methods more generic
* Make the flags public and give them nicer names
* Pass down the flags from the caller, so the caller can now explicitly
  ask for looking into specific directories
* Rename the methods
* Remove and inline the wp_get_xdg_config_dir() method, since it's only
  used internally
* Refactor the lookup dirs ordering to get both WIREPLUMBER_*_DIR env
  variables to replace all the other directories. Previously, we were looking
  for scripts in WIREPLUMBER_DATA_DIR, but we were also looking in /etc at
  the same time (with precedence, even), which could result in unexpected
  behaviour. Now, if a WIREPLUMBER environment variable is specified,
  we only look in there.
2021-08-19 10:06:37 +03:00
Julian Bouzas
7abd3728e7 build: fix volatile compatible-pointer-types warnings
Happens when compiling with GCC 11
2021-08-18 09:17:05 -04:00
George Kiagiadakis
b9b722c125 properties: adjust documentation for the recent WpPropertiesItem changes 2021-08-11 20:25:16 +03:00
Arun Raghavan
032aa8edf2 wp: Add a WpImplModule for loading modules in WirePlumber context 2021-08-10 11:33:01 -04:00
George Kiagiadakis
9ebea2976d wp: refactor and rename wp_iter_conf_files() to use WpIterator
This also corrects the logic of loading config files in m-lua-scripting.
Previously, if an error occured within the iteration function,
the error was not properly propagated to the caller because -EINVAL
was being added to nfiles instead of checked.
2021-07-20 14:42:42 +03:00
George Kiagiadakis
edd8ea7297 wp: polish documentation and add annotations for the config-related functions 2021-07-20 14:42:42 +03:00
George Kiagiadakis
3ff53f19e4 lib: s/G_GNUC_DEPRECATED/G_DEPRECATED/
This one is more portable
2021-07-20 14:42:42 +03:00
George Kiagiadakis
0830362807 lib: explicitly ignore the return value of g_strlcpy() to silence coverity 2021-07-20 14:42:42 +03:00
Peter Hutterer
ece8f7a78d lib: deprecate the functions to fetch the config directory
Both have been replaced by functions that directly find configuration files
in a hierarchy of paths.
2021-07-15 15:17:01 +00:00
Peter Hutterer
d38c3fb4cc lib: add functions to search in configuration/data directories
The previous approach to loading config files was to ask WP for the
directory and then search those for the config files. This patch changes the
approach - a caller now asks WP to search for a specific config file or
iterate over a config file directory.

This allows us to implement a directory lookup order, i.e.
"wireplumber.conf" may be in XDG_CONFIG_DIR, /etc/,
/usr/share and the first one found is used.

For configuration directories, the new method iterates over all matching
entries (files + directories) and invokes a callback for each entry.

This enables distributions to ship default files in /usr/share/wireplumber
but have admins and users override them on a local basis. For lua scripts in
particular, overriding a distribution-provided file with an empty file
effectively disables it, adding a file adds it in the right sort order.
2021-07-15 15:17:01 +00:00
Peter Hutterer
153e84c8b8 lib: always return the full path from wp_get_config/data_dir
Remove the need for the caller to check if the returned path is absolute or
relative.
2021-07-15 15:17:01 +00:00
Peter Hutterer
2e88a115d1 lib: add a function to return the XDG_CONFIG_DIR 2021-07-15 15:17:01 +00:00
Julian Bouzas
2792cecbcf properties: use a boxed WpPropertiesItem type when iterating
Needed for JavaScript bindings
2021-07-15 08:55:00 -04:00
Peter Hutterer
be1a077eaf state: store our WpState files in $XDG_STATE_HOME/wireplumber 2021-07-14 14:44:11 +10:00
Peter Hutterer
ab62af1748 lib: add a function to get the xdg state dir
Added recently to the XDG spec, XDG_STATE_HOME ($HOME/.local/state/) is for
files that are neither configuration/data files nor runtime/cache files.
2021-07-14 13:18:49 +10:00
Julian Bouzas
0c51cf9a7b session-item: fix reference leak when getting properties 2021-07-02 11:59:42 -04:00
Julian Bouzas
2900dc1c23 object-manager: remove old global when exposing new global with same id
Sometimes, especially when running the wireplumber daemon with valgrind, a new
global with the same Id as another old global owned by a proxy wants to be
exposed before the old proxy is destroyed. If this happens, instead of returning
with an assertion error, we remove the old global and we export the new one.
2021-07-01 14:49:28 -04:00
Julian Bouzas
4275d91675 global-proxy: add extra checks to make sure binding is successful
Globals can be removed by the object manager when their associated proxy is
currently being bound. Adding extra checks in wp_global_proxy_bin() to return
a transition error avoids binding the proxy when that happens.
2021-07-01 14:37:42 -04:00
George Kiagiadakis
888d6e5033 lua: add Port.get_direction() + documentation for it 2021-06-30 19:51:21 +03:00
George Kiagiadakis
7fedb5e9e1 wplua: expose functions to convert enums to strings for lua and vice versa 2021-06-30 19:51:21 +03:00
Julian Bouzas
ee190411f4 state: escape invalid key file characters 2021-06-30 08:48:57 -04:00
Julian Bouzas
6b8ea83404 wpipc: sender: disconnect and clear all pending tasks if connection was lost
If we don't remove the socket from epoll when the connection is lost, we risk
having the lost callback triggered more than once by epoll, creating race
condition in the unit test because more than 1 event happened. The epoll thread
and socket will be re-created again when re-connecting.

Note that we cannot destroy the epoll thread before triggering the lost
connection callback because we are running the callback in the epoll thread,
which is why removing the socket from epoll is the only way to make sure the
lost connection callback is only triggered once.
2021-06-28 11:38:37 -04:00
Julian Bouzas
313f872570 wpipc: receiver: also emit sender disconnected when failed to read 2021-06-28 11:38:37 -04:00
Julian Bouzas
f4a4f8bcc7 wpipc: protocol: make sure buffer is initialized to 0 before building reply/request
Fixes valgrind errors
2021-06-28 11:38:37 -04:00
Julian Bouzas
8a5a8fc015 wpipc: change epoll thread func type name to be more consistent 2021-06-28 11:38:37 -04:00
George Kiagiadakis
c41d042dd0 wplua: remove handling of LUA_ERRGCMM, which is removed in lua 5.4 2021-06-27 07:57:06 +00:00
Julian Bouzas
5b4b360b1c wp: log warning if PIPEWIRE_DEBUG env variable could not be set 2021-06-25 08:50:08 -04:00
Julian Bouzas
892b0dada6 lib: Use #define instead of 'static const' for constants
Fixes build errors when using GCC older than v8.1
2021-06-24 09:24:16 -04:00
George Kiagiadakis
1075d23fab lib: fix some issues found by coverity 2021-06-15 17:43:22 +03:00
George Kiagiadakis
801ac7aa1a wplua: add a wplua_checkclosure() helper function 2021-06-10 14:53:08 +03:00
George Kiagiadakis
7355215cf1 pipewire-object: change params-changed signal to take a string param name
To be consistent with the rest of the API where strings are used
to identify param types
2021-06-09 13:29:34 +03:00
George Kiagiadakis
f9767d19a6 lib: add struct paddings to be able to maintain ABI compatibility
Aim for 8 pointers on each struct, wich exceptions:
- 12 pointers for already crowded/important ones
- 4 pointers for empty ones that are used for proxies; we are
  unlikely to add any virtual methods on these classes ever
2021-06-08 17:38:14 +03:00
Julian Bouzas
83e50396ee pw-object-mixin: ignore set param on already destroyed objects 2021-06-08 09:08:13 -04:00
Julian Bouzas
21e73141c6 proxy: destroy pw_proxy if bind_error is called 2021-06-08 09:08:13 -04:00
Julian Bouzas
7d28027f9b wplua: fix memleak when converting GVariant to Lua 2021-06-07 11:33:21 -04:00
Julian Bouzas
fc8cc09654 global-proxy: fix leak when getting global properties 2021-06-07 11:33:21 -04:00
Julian Bouzas
a12c41aca1 spa-pod: check if pod is valid before _parser_can_collect
Spotted with clang-tidy, avoids possible segfault if pod is NULL.
2021-06-07 11:33:21 -04:00
George Kiagiadakis
ac5c2ebbba object-interest: remove unused _copy() method
object-interest is now ref-counted, so we can use _ref()
2021-06-07 17:56:32 +03:00
George Kiagiadakis
450deabb40 object-manager: small doc fix 2021-06-07 17:47:42 +03:00
George Kiagiadakis
1ca67abc66 object-manager: support declaring interest on all properties of globals
Until now, object manager could only match pw global properties on
pw global objects, because this is the only available properties set
at the time the registry creates the global.

With this change, the object manager will now bind the proxy
if the type and the pw global properties have matched and will wait
until the proxy is available with all of its properties and tries
the check again.
2021-06-07 17:47:42 +03:00
George Kiagiadakis
997bdb65cd object-interest: enrich _matches_full() to be able to check all constraints 2021-06-07 17:47:42 +03:00
George Kiagiadakis
38f7483793 state: remove support for groups and propagate save errors
There is no real use for groups in our API. Just use the name of
the file as the default group and be done with it...
Storing multiple groups with this API is problematic because it
forces flushing the file to disk multiple times, one for each group,
and it's just more performant if we use a prefix in the keys
to implement some form of logical separation.

This commit also makes the GKeyFile a temporary object. As we
always load the file from the file system in _load()
and we always replace its contents with a new dictionary in _save(),
there is no point in keeping the keyfile's internal data structures
stored in memory.

Save errors are now also propagated to adhere to the programming
practices of GObject
2021-06-04 18:36:19 +03:00
George Kiagiadakis
4948f6f2f6 state: don't stat() before creating the dir or removing the state file
there is no point
2021-06-04 18:36:19 +03:00
Julian Bouzas
cde38daabf pipewire-object: fix memory leaks when getting properties 2021-06-03 14:53:00 -04:00
Julian Bouzas
214c7a444a endpoint: free media_class when disposing WpImplEndpoint 2021-06-03 14:53:00 -04:00
Julian Bouzas
3fbcf05c9b pipewire-object: take ownership of param argument
The wp_pipewire_object_set_param API must take ownership of the param argument
as described by the documentation.
2021-06-03 14:53:00 -04:00
Julian Bouzas
d28f1241cc object: advance pending transitions if activation fails 2021-06-03 09:38:19 -04:00
Jason Francis
1b5df6096a docs: include wp.h in gir sources 2021-06-02 17:38:34 +00:00
Jason Francis
ed8346e77d docs: Add brief descriptions to all functions
This ensures all of these functions are picked up by g-ir-scanner.
2021-06-02 17:38:34 +00:00