Commit graph

51 commits

Author SHA1 Message Date
George Kiagiadakis
95cfa9e453 wpctl: fix settings --help listing
GOptionEntry arrays need to be NULL terminated, otherwise garbage
will be printed after the last entry...
2024-03-12 16:50:25 +02:00
George Kiagiadakis
3fa5228d22 meson: move the common CFLAGS to project-wide scope 2024-03-09 15:58:01 +02:00
George Kiagiadakis
60382df63f conf: refactor configuration loading
Changes:

- Configuration files are no longer located by libpipewire,
  which allows us to control the paths that are being looked up.
  This is a requirement for installations where pipewire and
  wireplumber are built using different prefixes, in which case
  the configuration files of wireplumber end up being installed in
  a place that libpipewire doesn't look into...

- The location of conf files is now again $prefix/share/wireplumber,
  /etc/wireplumber and $XDG_CONFIG_HOME/wireplumber, instead of using
  the pipewire directories. Also, since the previous commits, we now
  also support $XDG_CONFIG_DIRS/wireplumber (typically /etc/xdg/wireplumber)
  and $XDG_DATA_DIRS/wireplumber for system-wide configuration.

- Since libpipewire doesn't expose the parser, we now also do the
  parsing of sections ourselves. This has the advantage that we can
  optimize it a bit for our use case.

- The WpConf API has changed to not be a singleton and it is a
  property of WpCore instead. The configuration is now expected
  to be opened before the core is created, which allows the caller
  to identify configuration errors in advance. By not being a singleton,
  we can also reuse the WpConf API to open other SPA-JSON files.

- WpConf also now has a lazy loading mechanism. The configuration
  files are mmap'ed and the various sections are located in advance,
  but not parsed until they are actually requested. Also, the sections
  are not copied in memory, unlike what happens in libpipewire. They
  are only copied when merging is needed.

- WpCore now disables loading of a configuration file in pw_context,
  if a WpConf is provided. This is to have complete control here.
  The 'context.spa-libs' and 'context.modules' sections are still
  loaded, but we load them in WpConf and pass them down to pw_context
  for parsing. If a WpConf is not provided, pw_context is left to load
  the default configuration file (client.conf normally).
2024-03-04 07:07:56 +00:00
Julian Bouzas
f18a8c5a35 wpctl: use WpSettings API instead of metadata in 'settings' sub-command
Also adds -r flag to reset settings to their default value.
2024-02-28 10:20:31 -05:00
Julian Bouzas
a23248847a metadata: remove wp_metadata_iterator_item_extract() API
Similar to WpPropertiesItem, this implements a new WpMetadataItem type that is
returned when iterating metadata
2024-02-28 08:15:17 -05:00
Julian Bouzas
bebfc07d84 wpctl: add settings subcomand to show, delete or change settings 2024-02-14 12:04:41 -05:00
Julian Bouzas
b703c01d4c wpctl: show persistent settings and add sub-command to clear them 2024-02-07 11:53:01 -05:00
Julian Bouzas
9bf646aed0 wpctl: show filters in the status output 2024-02-07 11:43:37 -05:00
George Kiagiadakis
994f1c1f4a Merge branch 'master' into next 2024-01-03 10:47:16 +02:00
Ferdinand Bachmann
3a40a8795b wpctl: resolve device id and route device internally 2023-12-27 19:36:56 +01:00
Ferdinand Bachmann
f01177d08a wpctl: add set-route subcommand 2023-12-25 23:06:32 +01:00
Pauli Virtanen
43e190e3b4 wpctl: add set-log-level command
Add command for changing log level for Pipewire or Wireplumber daemons
at runtime.

It can be done with pw-metadata, but make it easier so that the user
doesn't need to look up Wireplumber client ids.
2023-12-24 17:59:59 +02:00
George Kiagiadakis
42b64bfc28 spa-json: rename _from_string() to _wrap_string() and add new "from" variants
The previous naming convention was confusing because it did not make
it explicit that the string is not being copied. We had this wrong already
in the Lua bindings and thanks to some miracle it hasn't backfired so far
(it was using the "wrap" behaviour with a string that doesn't stay alive).

In some places we actually need the "copy" behaviour and in some other
places we need the "wrap" behaviour, so let's have both variants available.
2023-11-14 12:36:10 +02:00
George Kiagiadakis
eb6f569be8 Merge branch 'master' into next 2023-10-24 11:09:52 +03: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
Ronan Pigott
b2bfb1b917 wpctl: add zsh completions 2023-10-10 07:07:16 +00:00
George Kiagiadakis
a0497b4256 Merge branch '0.4' into next 2023-06-21 20:59:04 +03:00
George Kiagiadakis
c7cb193588 core: introduce the notion of provided features on components
Each component can optionally "provide" a feature, which is basically
a string that describes the feature (ex. "support.dbus"). If the
component loads successfully, the feature is marked as provided and
can be tested for its presence with wp_core_test_feature()
2023-06-20 12:39:29 +03:00
George Kiagiadakis
55fc845098 component-loader: make wp_core_load_component_finish() return a boolean
There is no reason to return the component object... all components
are supposed to be long-lived objects that are referenced by the
registry and there is API to find them. The caller is only interested
in the success or failure of the operation.
2023-05-28 21:07:15 +03:00
George Kiagiadakis
843e7ef4dd component-loader: pass core and cancellable parameters in load()
Regarding the core parameter, the case used to be that WpComponentLoader
was a WpPlugin, so it had a reference to the core internally, but since
this is no longer a requirement, we need to pass this explicitly
2023-05-26 13:04:10 +03:00
George Kiagiadakis
5c3032c064 core: change the component arguments to be WpSpaJson instead of GVariant
This allows us to pass entire JSON objects from the config file
down to the modules / scripts without any conversion
2023-05-25 18:29:58 +03:00
George Kiagiadakis
6dc5ac089a wpctl: add status options to display device/node names and nicknames 2023-05-23 11:41:38 +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
c61d1e4245 component-loader: make wp_core_load_component() API asynchronous
This change completely refactors the way components are loaded in wireplumber:
- The module_init() function must return a GObject now. This object is either
a WpPlugin or a WpSiFactory in the current modules.
- When the component loader initializes a module, it automatically registers
the WpPlugin or WpSiFactory with their respective methods. There is no need
to register the WpPlugin or WpSiFactory in the module now.
- The wp_core_load_component() API has been refactored to be asynchronows. This
allows the component loader to automatically activate WpPlugin objects, and
therefore allows the application to directly get the WpPlugin without having
to find it. This simplifies a lot of things.
- The 'ifexists' and 'nofail' component flags now work even if the respective
WpPlugin could not be activated.
- The code that loads components in main.c has also been simplified a lot,
and the option to load dangling components has also been removed.
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
0fadd4f4fd wpexec: Add support for event dispatcher
-Scripts loaded with wpexec will also need 'module-standard-event-source'
 to be able to convert the pipewire signals to wireplumber events.
-Simplify the init transition states.
2023-04-17 07:48:18 -04:00
Jason Nader
b1b5bf2f5f
wpctl: add option to limit set-volume final value 2022-08-16 23:57:20 +09:00
Julian Bouzas
ca16201034 wpctl: accept 0 as ID in clear-default subcommand
Unlike the rest of subcommands, The ID for the clear-default subcommand must be
a setting ID, not a pipewire Object ID. This means we cannot use the parse_id()
and translate_id() helper functions because the setting ID 0 is acceptable, and
the @DEFAULT_AUDIO_SINK@, @DEFAULT_AUDIO_SOURCE@ and @DEFAULT_VIDEO_SOURCE@
strings are not acceptable.
2022-07-28 18:00:11 +00:00
George Kiagiadakis
180ecab04d wpctl: set-volume: improve the code, treat percentage as pactl does
10% should be written as 10%, not as 0.1%
and 0.7 + 10% in pactl translates to the volume becoming 0.8, not 0.77
2022-07-05 15:40:32 +03:00
George Kiagiadakis
d6241f7f0d wpctl: remove unused variables 2022-07-05 14:32:18 +03:00
George Kiagiadakis
e33922ff7b wpctl: remove double % sign printouts, fix the style of the set-volume summary 2022-07-05 14:30:33 +03:00
George Kiagiadakis
6954105589 wpctl: fix inspect for metadata objects
metadata objects do not implement WpPipewireObject
2022-06-28 10:57:09 +03:00
Varnit Singh
f53efaabf1 wpctl: allow modifying volume levels using percentage/step amount. 2022-06-08 09:25:45 +00:00
Varnit Singh
e192deb7bc wpctl: Add get-volume command and functionality 2022-06-08 09:18:34 +00:00
George Kiagiadakis
b345468e82 wpctl: print link states in the status output 2022-05-30 11:06:46 +03:00
Julian Bouzas
70ae393166 wpctl: support changing volume and mute by PID number
The 'set-volume' and 'set-mute' commands have a new --pid flag to allow changing
the volume or mute for all client nodes that are created by a specific process.
2022-05-03 09:36:57 +00:00
George Kiagiadakis
0f3bb516f8 wpexec: fix script activation to work with per-script plugins 2022-05-02 11:01:34 +03:00
Théo Lebrun
7784cfad92 wpctl: support @DEFAULT_{AUDIO,VIDEO}_{SINK,SOURCE}@ as ID 2022-04-26 13:51:32 +00:00
Pauli Virtanen
7e6e0e9ba0 src: setlocale in main() for tools and the daemon
Previously, pw_init calls setlocale(), but this will change in future.
Setting the locale should be done by the main application, and is needed
in wireplumber for e.g. for translated UI elements.

Set the locale in main() for wireplumber daemon and tools, to have the
locale set also with the new pw_init behavior.

Set also LC_NUMERIC to C, to match old pw_init behavior.
2022-03-24 07:11:39 +00:00
George Kiagiadakis
cfee1f0c65 wpctl: ensure that the result of strtol() is < G_MAXUINT32
Fixes overflows on 64-bit architectures

Closes #173
2022-01-26 15:09:55 +02:00
Julian Bouzas
0272e11c53 wpctl: add clear-default option to clear default configured node names
This also improves the status output to display the configured default node
names using the new get-default-configured-node-name API, and refactors
set-default to also use the new set-default-configured-node-name API from
the default-nodes-api module.
2022-01-25 09:57:33 +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
George Kiagiadakis
a57647769a metadata: filter for the "default" metadata object in all places where we use it
there can be more metadata objects around...
2021-06-18 10:39:47 +03:00
George Kiagiadakis
86fde56ddd daemon/wpexec: standardize exit codes based on sysexits.h 2021-06-08 20:39:36 +03:00
George Kiagiadakis
aa618e99cb wpexec: force the log level to be at least 1 and use fprintf() for local errors
pipewire's client.conf sets the default log level to 0, which is not
good for wpexec, as lua runtime errors are reported as warnings currently.

Also, let's use fprintf() for local cli errors to make sure they get printed
even if the log level is 0
2021-06-08 20:39:36 +03:00
George Kiagiadakis
ac23e60267 wpctl: fix iterator cleanup 2021-05-21 20:04:27 +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
b46587393c lua: change the "wireplumber.interactive" property to "wireplumber.daemon"
with inverted semantics
2021-04-22 13:48:06 +03:00
George Kiagiadakis
e13b2bc8ad wpctl: handle endpoints nicely and enable volume controls on them
Instead of adding Props on endpoints again and syncing with the associated
node, it is easier to just use the volume controls of the associated node
2021-04-12 12:46:40 +03:00
George Kiagiadakis
1ba99739c2 tools: split wireplumber script execution mode to a separate wpexec tool
This is mainly for security reasons. This way, we can limit the
permissions of wpexec without limiting wireplumber, for instance
with pipewire's default module-access, which limits apps based on
their executable name
2021-04-12 09:53:30 +03:00