Commit graph

2798 commits

Author SHA1 Message Date
Barnabás Pőcze
05c3f31362 script-tester: wp_script_tester_create_stream(): fix property list leak
The `WpProperties` object containing the properties of the stream
was not released after it was no longer needed. Fix that.
2025-07-29 09:18:46 +03:00
Barnabás Pőcze
83e992b238 lib: settings: iterator: release parent object reference
`wp_settings_new_iterator()` takes a reference to the underlying
`WpSettings` object with `g_object_ref()`, however, it fails to
release it during finalization. Fix that.
2025-07-28 21:23:59 +02:00
George Kiagiadakis
96848883fe lib: spa-type: convert constant to a #define to make it work in switch statements 2025-07-25 22:38:19 +03:00
Demi Marie Obenour
f3625bee61 lua: fix SPA POD array and choice builders
These builders had many bugs:

1. They would longjmp() across the destructor of a g_autoptr() if a Lua
   error was thrown.  This will leak the memory in the g_autoptr()
   unless Lua is compiled with C++ exceptions.
2. They depended on the iteration order of numerical keys in Lua tables.
   Lua explicitly does not specify this order.
3. They would produce nonsensical SPA POD array or choice types with
   strings or bytes as values.  These would cause undefined behavior if
   manipulated by naive C code, or assertion failures if
   spa_pod_is_array() and spa_pod_is_choice() are modified to check that
   the contents of arrays and choices have sensible types.
4. They silently accepted extra arguments, potentially causing confusion
   and making it harder to extend the functions in a
   backwards-compatible way.

Solve the first problem by calling functions that can raise a Lua error
in a protected environment (with lua_pcall).  If there is a Lua error,
rethrow it after the g_autoptr() destructor has run.

Solve the second problem by first obtaining the number of keys in the
table and then iterating over the keys that are expected to be present.
If any of the keys are not contiguious integers starting at 1, the range
[1..number of keys] will include a number that is not a table key.  This
will result in lua_rawgeti pushing a nil onto the Lua stack.  An
explicit check throws a useful error in this case.

Solve the third problem by explicitly checking that the type is
reasonable before building an array or choice.  If it is wrong,
a Lua error is thrown.

Solve the fourth problem by using luaL_checktype (L, 2, LUA_TNONE) to
check that no unwanted values were passed.  The C function called with
lua_pcall is passed every argument passed by Lua, followed by a light
userdata that stores a context pointer.  After the light userdata is
popped from the Lua stack, the Lua stack is identical to what Lua
created when it called the outer C function, so the type-checking
functions in the auxillary library can be used to enforce that only the
correct number and type of arguments were passed.
2025-07-24 12:36:29 +03:00
Demi Marie Obenour
0cba7b9525 lua: Push "_new", not '_' and then "new".
No functional change intended.
2025-07-24 12:36:29 +03:00
Demi Marie Obenour
2ea068de1b _wplua_pcall: avoid Lua stack overflow
C code must ensure that the Lua stack does not overflow.  Ensure there
are enough slots for both the error handler and for the return values.
2025-07-24 12:36:29 +03:00
Demi Marie Obenour
db755a6a19 lua: use Lua extradata to store the reference count
Lua provides "extra data", which is some memory in each Lua state that
the application can use for its own purposes.  Use this to store the
reference count.
2025-07-24 12:36:29 +03:00
Pauli Virtanen
36f809fb50 lib: settings: make settings name optional
The "name" field needs to be optional, to be backward compatible with
old settings spec format.  If it's omitted, make it NULL.
2025-07-24 12:14:33 +03:00
Pauli Virtanen
9e47393643 po: update Finnish translation 2025-07-24 11:44:04 +03:00
Pauli Virtanen
a32e31ffa1 wpctl: localize settings descriptions + show names 2025-07-24 11:44:04 +03:00
Pauli Virtanen
8d26e9f73c wireplumber.conf: provide human-readable names for settings 2025-07-24 11:44:04 +03:00
Pauli Virtanen
3b1acc5474 lib: settings: add wp_settings_spec_get_name() for human-readable name
Extend settings spec with a human-readable name, and add function to get
it.
2025-07-24 11:44:04 +03:00
Pauli Virtanen
a8283001d9 po: extract translatable strings from wireplumber.conf
Add rules to extract translatable strings from wireplumber.conf.

Meson i18n.gettext does not support extracting strings from
autogenerated files. Hence, we must commit conf.pot to repository.

These setting descriptions are meant to be user-facing. Translating them
allows also 3rd party apps to get the translations from 'wireplumber'
domain.
2025-07-24 11:29:44 +03:00
Pauli Virtanen
e070260c5c tools: add utility to extract strings from SPA-JSON for translation
Add utility that extracts strings from SPA-JSON files in POT format.
2025-07-24 11:29:20 +03:00
Pauli Virtanen
f6912ec23c wireplumber.conf: improve settings descriptions
The setting descriptions are in principle user-facing, so try to make
their descriptions more clear.
2025-07-24 11:29:16 +03:00
Pauli Virtanen
fb218fe016 scripts: add mpris-pause.lua to pause media streams when target removed
When current output target of a media player application is removed, it
can be useful if playback is paused (to avoid e.g. music playback to
going to speakers when headset is accidentally unplugged).  Android etc.
implement a policy like this.

Add a policy script that monitors stream target removals. When it
detects a media player application that is linked to a no longer present
output target, it checks whether the stream is associated with a media
player seen in MPRIS. If yes, it sends MPRIS Pause() command to the
media player.

Enable this policy by default.
2025-07-23 10:19:44 +03:00
Pauli Virtanen
bc713acafd m-mpris: add MPRIS plugin
Add a plugin module that can list active MPRIS media players, and send
Pause commands to them.
2025-07-23 10:19:44 +03:00
George Kiagiadakis
6430e747f9 gitlab-ci: s/systemd/libsystemd/ in pipewire's meson command line
See pipewire@f2c878a2
2025-07-23 10:15:06 +03:00
George Kiagiadakis
faf042a82b wpctl: set-profile: set the "save" flag on the selected profile
Fixes: #808
2025-07-01 13:37:02 +03:00
George Kiagiadakis
e9928b4beb default-nodes/README: update documentation regarding the select-default-node event 2025-07-01 13:20:22 +03:00
George Kiagiadakis
754c805061 default-nodes/find-best: skip the hook if a very high priority node is selected
Just to optimize a bit more for performance
2025-07-01 13:13:21 +03:00
George Kiagiadakis
f1c96843ee default-nodes/rescan: remove unused table and access node.properties only once 2025-07-01 12:52:36 +03:00
Julian Bouzas
a433a49e28 default-nodes: Use session and route priorities when finding the default node
Some PCM devices can expose multiple nodes with same session priorities but
different route priorities. This improves the default nodes logic to also check
the route priorities when the session priorities are the same.
2025-07-01 12:52:36 +03:00
Carlos Rafael Giani
e97551818a m-si-audio-adapter: Suspend node before setting Format and avoid redundancy
When a new Format param is set, the node's state is not checked, so this
attempt can even take place when the node is not suspended. Setting that
param will not work if the node isn't suspended though. Add a check for
the state and suspend the node if needed.

Also, do not set the Format param if the new param POD is the same as that
of the existing format to avoid redundant calls.

(This mirrors already existing checks for the PortConfig param.)
2025-06-27 13:08:30 +03:00
Julian Bouzas
84e2fcc050 monitor/alsa: Increase priority for USB devices
We always want the plugged USB ALSA device to have higher priority than the
internal ALSA device.
2025-06-26 14:05:38 -04:00
Richard Acayan
73f52cfb94 monitors/alsa: manage node when bound
If the managed node needs to emit events before it is bound, Wireplumber
treats it as destroyed and ignores the events. Add the node as pending
before it is bound so the node can run set_param on events that happen
before it gets bound.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2025-06-23 08:02:46 +03:00
George Kiagiadakis
f198f39f37 lib: module: clear the impl_module pointer when it is destroyed by itself
Some modules (like module-loopback) may destroy themselves with
pw_impl_module_schedule_destroy() when the pipewire connection closes.
In that case, we need to clear our pointer so that we don't try to
destroy them again (and crash)

Fixes: #812
2025-06-12 07:40:21 +03:00
George Kiagiadakis
7a4d317755 0.5.10 2025-05-21 07:32:15 +03:00
Tiago de Paula
ee42211bc6
fix: nil value in haveAvailableRoutes
Cause from partially renamed variables in af3c520d.

Closes #797
2025-05-21 01:00:59 -03:00
George Kiagiadakis
76b9e509d1 0.5.9 2025-05-19 12:32:21 +02:00
Philipp Jungkamp
404a634b92 docs: fix wrong description of software_dsp example 2025-05-18 15:49:59 +03:00
Julian Bouzas
0251d644a8 default-nodes/rescan: Check available routes using linking-utils
The linking-utils module already implements a way to check for available routes,
this patch uses it in default-nodes/rescan.lua to remove redundant code.
2025-05-18 14:11:53 +02:00
George Kiagiadakis
b8506d0d56 linking-utils: fix missing 'end' 2025-05-18 14:11:53 +02:00
George Kiagiadakis
af3c520d3e linking-utils: improve haveAvailableRoutes
Based on nodeHasAvailableRoutes() from default-nodes/rescan.lua
2025-05-18 13:56:14 +02:00
Julian Bouzas
050cd772be settings: cache setting values locally to avoid syncing issues
This patch caches the settings info to make sure their values are always
updated, even if using the settings API multiple times before pipewire
finishes synchronizing the metadata objects.

Fixes #749
2025-05-17 13:39:12 +03:00
Andrew Sayers
2a5606e437
Add TID and SYSLOG_{IDENTIFIER,FACILITY,PID} to log messages
Systemd journal entries have several common entries:
https://www.freedesktop.org/software/systemd/man/latest/systemd.journal-fields.html

Add "SYSLOG_IDENTIFIER" to make it easier to find wireplumber messages.
Add "SYSLOG_FACILITY" to avoid confusing programs that expect both or neither.
Add "TID" and "SYSLOG_PID" to make debugging a little easier.
2025-04-22 11:24:09 +01:00
David Mandelberg
08d7e51efb test-utils: make it possible to specify a device's props
The test I wrote for
https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/778 uses
this, since it needs a target-loudness to make a loudness filter:

```
tu.createDeviceNode (
  "default-device-node",
  "Audio/Sink",
  { ["device.target-loudness"] = -18 }
)
```
2025-04-11 13:55:24 +00:00
Pauli Virtanen
2d48caa74b monitors/alsa: fix nil table indexing
It's possible that managed_node.properties["node.name"] == nil if the
node is gone.

The removeDevice call above has already cleared the node names, so no
need to do it again.
2025-04-11 13:07:43 +00:00
George Kiagiadakis
9f440d0b50 monitors/libcamera: fix deduplicating devices with the same name 2025-04-11 15:53:44 +03:00
Lukas Riezler
e51e1b6080 v4l2/monitor: scripts: fix for deduplicate devices with the same name 2025-04-08 10:06:45 +02:00
David Mandelberg
a2605a2cdf Change node.dont-remix to stream.dont-remix
I'm guessing this was a typo? I ran `git grep dont-remix` in both
wireplumber's and pipewire's repos, and all the other references were to
stream.dont-remix, including the definition of PW_KEY_STREAM_DONT_REMIX.
2025-04-07 17:28:15 +00:00
Robert Mader
0d356f90ed monitor-utils: Support devices without any device ids
Such as libcameras virtual devices.
2025-04-07 17:04:22 +00:00
Andrew Sayers
1eed9669f1
Avoid spurious warnings when dbus.service stops
wireplumber.service generates the following when dbus.service
stops before it (e.g. when the user logs out):

    m-dbus-connection: <WpDBusConnection:0x556b3c561680> DBus connection closed: Underlying GIOStream returned 0 bytes on an async read
    m-dbus-connection: <WpDBusConnection:0x556b3c561680> Trying to reconnect after core sync

Stop the service before dbus.service exits, to avoid these messages.
2025-04-03 15:38:08 +01:00
Julian Bouzas
ce4f9b08a9 proc-utils: Make sure cgroup length is valid before removing EOF char
This fixes a Coverity Scan defect.
2025-03-05 13:36:04 -05:00
George Kiagiadakis
0f3e005a92 gitlab-ci: update fedora and alpine images 2025-03-05 19:05:12 +02:00
George Kiagiadakis
ff692952c4 docs: software_dsp: fix example config snippet
The wireplumber.profiles section is an object, not an array
2025-03-05 17:50:43 +02:00
Julian Bouzas
0b716118c7 scripts: Add audio-group-utils.lua to group audio streams
This allows grouping audio streams that have a pw-audio-namespace ancestor
process name. The grouping is done by creating a loopback filter for each group
or namespace. Those loopback filters are then linked in between the actual
stream and device nodes. A '--target-object' flag is also supported in the
ancestor process name to define a target for the loopback stream node.
2025-03-05 16:28:34 +02:00
Julian Bouzas
86cdfaccc4 lib: Add new proc-utils API for process utilities 2025-03-05 16:28:34 +02:00
Pauli Virtanen
78f1e34029 autoswitch-bluetooth-profile: use s-device log topic 2025-03-02 15:09:53 +02:00
Hugo
d222b957af Improve documentation for lua scripts
I had a hard time figuring out all the steps relevant for this to work.
Hopefully this brief summary and couple of links will help the next
person writing their own script.

See: #601
2025-02-24 06:48:40 +00:00