48 Commits

Author SHA1 Message Date
George Kiagiadakis
a873f47d2e base-dirs: tidy up the build-time base dirs and honor the SUBDIR_WIREPLUMBER flag
Add a new private header file, wpbuildbasedirs.h, that contains the
build-time base directories passed directly from meson, without
the "wireplumber" suffix.

Use this to set the WP_BASE_DIRS_BUILD_* and adjust the code to honor
the SUBDIR_WIREPLUMBER flag.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
f76f45124e base-dirs: add support for finding modules and remove wp_get_module_dir()
This makes things more consistent and allows us also to add more
search paths in the future if necessary.

Also, stop using g_module_build_path() because it's deprecated and
build the path manually. This obviously is not portable to Windows/Mac
or other exotic platforms, but portability is not important at this
point. PipeWire is also not portable beyond Linux & BSD.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
6ae8c254a0 base-dirs: move file lookup utils out of wp.{c,h} and into base-dirs.{c,h} 2024-03-04 07:07:56 +00:00
George Kiagiadakis
3dc837c370 WpLookupDirs: remove the flag for looking into G_TEST_SRCDIR
Instead, make it so that WIREPLUMBER_*_DIR environment variables can
contain a list of directories to look into. This is safer and,
as a bonus, allows for more control over the lookup directories.
Using the G_TEST_SRCDIR variable can cause problems for tests of other
projects that use libwireplumber and may also lead to unexpected
behavior by not being obvious that this causes wireplumber to skip
looking in its standard directories...

This also brings back WIREPLUMBER_CONFIG_DIR, which is going to be
needed again for the upcoming WpConf changes.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
770028aad5 wp_new_files_iterator: refactor to behave like pipewire
Previously files would be sorted across all configuration dirs
so their filename was all that mattered, not the priority of the directory.

Ex. you could get:

- /etc/wireplumber/10-foo.conf
- /usr/share/wireplumber/20-bar.conf
- $XDG_CONFIG_HOME/wireplumber/30-baz.conf
- /usr/share/wireplumber/40-zzz.conf

This commit changes that so that it follows the hirerachy of the directories
first and then the order of the filenames, starting from the lowest priority
directory. So now for the same files you get:

- /usr/share/wireplumber/20-bar.conf
- /usr/share/wireplumber/40-zzz.conf
- /etc/wireplumber/10-foo.conf
- $XDG_CONFIG_HOME/wireplumber/30-baz.conf

In addition, the hash table is avoided, making things a bit more efficient
and the files are checked for G_FILE_TEST_IS_REGULAR

Shadowing of files still works the same, so in the above example
if /etc/wireplumber/30-baz.conf also exists, it is not returned
in the list, because it's shadowed by $XDG_CONFIG_HOME/wireplumber/30-baz.conf
2024-03-04 07:07:56 +00:00
George Kiagiadakis
28f9716eff wp_find_file: s/char/gchar/ in suffix argument 2024-03-04 07:07:56 +00:00
George Kiagiadakis
67f9f63520 Merge branch '0.4' into next 2023-09-01 19:12:20 +03:00
Tom A. Wagner
6e81dc7a66 docs: Add missing '\since' attributes to types and functions that have been added in versions later than 0.4.0 2023-08-30 11:20:06 +02:00
George Kiagiadakis
dc548a3259 log: improve the initialization process
* initialize all log-related features in a new wp_log_init() function
* remove the ability to change the log patterns later, as the log
  topics are not referenced by the log system and there is no way to
  re-initialize them with different levels (we can still implement this
  in the future, if necessary, though)
* introduce the notion of a "global log level", referenced by all topics,
  and make the topics know if they have a custom level or not, like in
  pipewire; this is necessary to be able to set the level in the config
  file, which is read later by pw_context / WpCore.
2023-05-18 12:50:52 +03:00
George Kiagiadakis
4736d56557 log: implement a log topics system, like pipewire
The intention is to make checks for enabled log topics faster.

Every topic has its own structure that is statically defined in the file
where the logs are printed from. The structure is initialized transparently
when it is first used and it contains all the log level flags for the levels
that this topic should print messages. It is then checked on the wp_log()
macro before printing the message.

Topics from SPA/PipeWire are also handled natively, so messages are printed
directly without checking if the topic is enabled, since the PipeWire and SPA
macros do the checking themselves.

Messages coming from GLib are checked inside the handler.

An internal WpLogFields object is used to manage the state of each log
message, populating all the fields appropriately from the place they
are coming from (wp_log, spa_log, glib log), formatting the message and
then printing it. For printing to the journald, we still use the glib
message handler, converting all the needed fields to GLogField on demand.
That message handler does not do any checks for the topic or the level, so
we can just call it to send the message.
2023-05-16 20:42:28 +03:00
Julian Bouzas
310232b810 meson: install scripts in /usr/share/wireplumber
Since the wireplumber configuration has been moved to /usr/share/pipewire, it
does not makes sense to have a different path for the WIREPLUMBER_CONFIG_DIR
environment variable. Therefore, the WIREPLUMBER_CONFIG_DIR environment variable
has been changed to just be an alias of PIPEWIRE_CONFIG_DIR. Finally, Lua
scripts are now installed under /usr/share/wireplumber/scripts instead of
/usr/share/pipewire/scripts as they are a wireplumber feature only.
2023-04-17 07:48:18 -04:00
Torge Matthies
ab6a3393e6 lib/wp: Fix lookup_dirs with WP_LOOKUP_DIR_ENV_DATA or WP_LOOKUP_DIR_ENV_TEST_SRCDIR
Fixes: aa2f7e9f308f ("lib/wp: add a new search folder to locate the Lua Test scripts")
2023-04-17 07:48:18 -04:00
Julian Bouzas
9004362cda lib: remove WpEndpoint and WpSiEndpoint APIs 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
fcfae4eeb3 lib/wp: add a new search folder to locate the Lua Test scripts 2023-04-17 07:48:18 -04:00
Julian Bouzas
102792527a lib: remove deprecated APIs 2023-04-17 07:48:18 -04:00
Julian Bouzas
5dcb4f0037 config: use the pipewire directory 2023-04-17 07:48:18 -04:00
Julian Bouzas
ccf1630f39 main: add --version flag to show current version
Fixes #317
2022-07-29 12:37:44 +00: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
Peter Hutterer
ee5f3f2f19 lib: don't read hidden files from the config directory
Fixes #104
2021-11-21 07:48:07 +00:00
Ashok Sidipotu
e2e3c5a69c wp-factory: enumerate pw_factory objects
pw_factory objects allow permissions to be set on its clients,
wp-factory exposes this funtionality to wireplumber clients.
2021-10-19 05:46:46 +00:00
Pauli Virtanen
24882f37a7 wp: fix pw_log_set usage
pw_log_set resets the log level of the logger to the Pipewire's current
level.  Here, it's instead expected that the level is retained, so call
pw_log_set_level first.

It used to be that pw_init set the log level based on PIPEWIRE_DEBUG
value, but this is now done only when using Pipewire's default logger.
2021-10-04 07:00:28 +00:00
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
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
0830362807 lib: explicitly ignore the return value of g_strlcpy() to silence coverity 2021-07-20 14:42:42 +03: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
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
5b4b360b1c wp: log warning if PIPEWIRE_DEBUG env variable could not be set 2021-06-25 08:50:08 -04: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
George Kiagiadakis
b812e912d2 docs: fix C API documentation to work nicely with doxygen & sphinx 2021-05-25 14:19:53 +03:00
Raghavendra
d692f06f0d docs: api: Replace hotdoc specific commands with Doxygen specific commands 2021-05-25 14:19:53 +03:00
George Kiagiadakis
ac9e1e89c4 wp: remove WpSession and WpEndpointLink
We have ended up not using them, so let's not carry them
in the ABI of 0.4

We can always revert that, but let's first decide how
these objects should be used
2021-05-21 19:57:31 +03:00
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
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
29559b4065 wp: add wp_get_data_dir() 2021-02-03 17:16:51 +02:00
George Kiagiadakis
cb228637d6 wp: export functions to get the module & config dirs 2021-02-03 17:16:51 +02:00
George Kiagiadakis
3762388831 spa-type: refactor
* Use a more complete API to introspect SPA types
* Avoid the need for the Tables enumeration; the tables
  are now registered with a string
* Avoid the need for initialization, work directly on spa_types
  and other static data
* Allow working with Object pods that are not Params;
  the PARAMS table was previously hardcoded in the pod implementation
* Add a different dynamic type registration system, closer to
  how spa type works. The only regression is that we can no longer
  register additional custom object fields (custom SPA_PROP_* for example),
  but this feature can be re-added later
2021-01-15 16:30:01 +02:00
Julian Bouzas
2ec43ea885 wp: remove initialization of wireplumber types 2021-01-05 08:43:03 -05:00
raghu447
65b4562fa0 Implement PW_TYPE_INTERFACE_Metadata 2020-07-30 21:30:14 +05:30
George Kiagiadakis
c8b11fad42 lib: add a version header 2020-06-02 18:26:40 +03:00
George Kiagiadakis
a2b84e27d1 session: rename the default source/sink controls to have shorter names
+ use a more correct naming scheme to match the one from Spa
+ remove the default video source, since we now use a different
 session for video
2020-05-14 17:31:24 +03:00
George Kiagiadakis
bfe76bf1d1 debug: honor WIREPLUMBER_DEBUG and ignore PIPEWIRE_DEBUG in pw_log
And also provide a way to disable this integration at runtime to
get pipewire's log back, with WIREPLUMBER_NO_PW_LOG=1
2020-05-12 18:16:55 +03:00
George Kiagiadakis
66a0bf6093 lib: implement a wp_init() function 2020-05-11 15:45:09 +03:00