Commit graph

1739 commits

Author SHA1 Message Date
George Kiagiadakis
031bc65c20 lua: sandbox: relax the sandbox to allow more functionality in scripts
This enables the debug and coroutine libraries and some more functions
that are not really so risky to have around

Related to #121
2022-04-23 20:14:59 +03:00
George Kiagiadakis
9387ce0d95 wplua: implement reference counting of the lua_State 2022-04-23 20:14:59 +03:00
George Kiagiadakis
9c22f6076a wplua: enable the use of require() to load lua libraries from scripts/lib 2022-04-23 20:14:59 +03:00
George Kiagiadakis
e1d0240bc9 wplua: split the functionality of the load functions into smaller functions
The load functions used to do 3 things:
- push the sandbox function on the stack
- load the file and push it as a function on the stack
- call the sandbox (or the file)

Now there are separate functions to do these 3:
- wplua_push_sandbox
- wplua_load_*
- wplua_pcall
2022-04-23 20:14:59 +03:00
msizanoen1
a2472542a9 scripts: access-portal: Fix incorrect bitmask checking for media roles
In Lua, `0` is a truthy value, which means `not 0` is `false`. Compare
the resulting value from bitwise AND with 0 instead of checking it with
`if not` to ensure correctness.
2022-04-15 13:23:19 +07:00
Pauli Virtanen
018ccb9ce6 po: Add translations from pipewire
The messages currently used in Wireplumber are also found in pipewire,
so merge translations from there.
2022-04-11 19:20:43 +03:00
Pauli Virtanen
6feecab74e scripts: translate user-visible strings in alsa.lua 2022-04-11 19:20:43 +03:00
Pauli Virtanen
bbe9ac00f3 modules: add m-i18n
Add simple gettext i18n module.

Add Lua script API functions I18n.gettext, I18n.ngettext.
2022-04-11 19:20:43 +03:00
Dennis D
f8e7b39c25 Update 10-default-policy.lua
Added "telegram-desktop", which is the name used by later versions of Telegram.
(tested on Telegram version 3.6.1)
2022-04-09 14:31:31 +00:00
Joker 234
f7c01d2475 Add Linphone to "media-role.applications"
Linphone (4.2.5) doesn't set any media.role → linphone should be in this predefined list as well.
2022-04-08 09:49:14 +00:00
Torkel Niklasson
d1f20e22d6 systemd: Allow systemd system services to use module-rt 2022-04-05 06:07:17 +00:00
Frédéric Danis
57769c2071 scripts: Add script to create fallback sink
This script, base on PipeWire module fallback-sink will create a fallback
sink node if there's no other sink available except the endpoints created
by WirePlumber.
2022-04-04 13:18:34 +00:00
George Kiagiadakis
0da29f3818 config: document which options need to be turned off to use wp without D-Bus
and actually implement an option for the logind module

Related to: #237
2022-04-04 14:38:28 +03:00
Pauli Virtanen
da5d25acbe scripts: policy-device-profile: clear tables when devices removed
When device ids are invalidated, clear all local tables about them,
because the id may be reused by different object, or the same object
reappearing.
2022-04-04 09:44:43 +00:00
George Kiagiadakis
8738955723 suspend-node: trigger idle timeout also if a node goes into "error" state
This is what media-session does as well and allows recovering from
errors without having to restart wireplumber
2022-04-04 11:31:37 +03:00
Pauli Virtanen
812fc9b6b1 scripts: policy-node: filter-like streams should not follow default
Filter-like streams (e.g. output stream from filter-chain) should not
start following default sink, as usually the user intends their routing
to remain static, and not change unless explicitly requested.
Pulseaudio has special handling for streams associated with filter
sinks/sources, and does not make such streams follow default.

Use presence of node.link-group to determine which streams are
associated with filter sinks/sources, and don't make them to follow
default.
2022-03-27 15:12:20 +03:00
Julian Bouzas
d173eeab88 main: don't use struct spa_json 2022-03-24 04:37:00 -04:00
Julian Bouzas
e9be326954 spa-json: add _new_from_stringn() API 2022-03-24 04:35:12 -04:00
George Kiagiadakis
17a257ddbe wplua: move under modules/module-lua-scripting
It's unlikely that wplua will ever be useful outside the context
of module-lua-scripting, so let's move it to keep all the code in one place
2022-03-24 09:47:59 +02:00
Julian Bouzas
2f186c10e7 main: use WpSpaJson when loading components 2022-03-24 07:21:25 +00:00
Julian Bouzas
a68a7cec0e spa-json: allow parsing unquoted keys when getting object properties
Unquoted strings are used in wireplumber and pipewire configuration files.
2022-03-24 07:21:25 +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
Ashok Sidipotu
f032ac00cf properties: Add get count API
This API returns the count of the number of properties or items.
2022-03-24 06:59:39 +00:00
George Kiagiadakis
8b97b40c44 release 0.4.9 2022-03-22 13:38:58 +02:00
Wim Taymans
f46a801edb tests: use GNU_SOURCE for compiling tests as well
So that strtod_l is found.
2022-03-21 12:01:00 +01:00
George Kiagiadakis
44a09a1050 tests: spa-json: add a test to verify that we can parse the spa-json format
The spa-json parser allows some interesting things to happen, which
are not valid JSON, but we use them for readability in config files...

- The separator may be = or just a space instead of :
- Strings may be unquoted
- Commas may be omitted
2022-03-16 21:25:07 +02:00
George Kiagiadakis
8d4fe81ebd spa-json: allocate enough space for parsing strings without looping
The string size is always less or equal to the size of the token (len),
so by allocating len+1 bytes we have enough space to write the whole
token and the null byte, if needed.
2022-03-16 21:11:09 +02:00
Ashok Sidipotu
2248b8ec1f spa-json: Parse unquoted string literals
- pipewire supports parsing unquoted strings and they are used
  extensively in JSON .conf files.
- Extend this support into wireplumber, as it wants to use the pipewire
  like syntax in its JSON .conf files.
2022-03-16 20:51:49 +02:00
Dennis D
538976b54a Add Telegram Desktop to the list of programs to enable bluetooth autoswitching.
Resolves: https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/215
2022-03-08 13:43:30 +00:00
Bart Ribbers
b495d5cdf9 ci: add Alpine target to test Musl builds 2022-03-08 11:09:50 +00:00
Wim Taymans
0747d34e44 alsa: fixup node.nick
Some devices (Mostly USB devices) have a generic pcm name (USB Audio)
that is quite useless. Filter this out and fall back to the device nick
in that case.
2022-03-08 11:03:24 +00:00
Ashok Sidipotu
72f4f19cbf policy-endpoint-device: Fix endpoints not connected with devices
-if device linkables are created ahead of the endpoints,
 endpoints are not connected with the devices.

-rescan the endpoints on an endpoint creation.
2022-03-08 10:08:55 +00:00
Pauli Virtanen
03c6fb0a86 scripts: bluez: set icon name for bluez devices 2022-03-08 09:56:28 +00:00
Pauli Virtanen
398bcca00d scripts: restore-stream: handle target.object 2022-03-08 09:49:55 +00:00
Pauli Virtanen
5872dc9408 policy-node: handle nodes-follow-default in handleLinkable
Since nodes may have a target specified in their props, the logic in
cleanupTargetNodeMetadata does not work correctly.

Instead, emulate what Pulseaudio does: if we see a reconnectable node
with target defined by node props, but not by metadata, which is linked
to the default sink, then make the stream follow the default from that
point on.
2022-03-08 09:49:55 +00:00
Pauli Virtanen
e4325bc41d policy-node: support target.object key
Setting node target by id is not safe due to id reuse, and so
target.object which specifies the target by its object.serial was
introduced, and is used e.g. by pipewire-pulse.

Use target.object specifications in policy-node if they are present.
2022-03-08 09:49:55 +00:00
Pauli Virtanen
0a605f666c wp: fix behavior of transitions before advanced for first time
wp_transition_get_completed incorrectly returns TRUE for transitions
that have not been advanced at least once, and hence are obviously not
completed.  This is because transitions start at STEP_NONE, and
completed transition is also indicated by STEP_NONE.

Fix this by adding a private flag to track whether transition was
started.

Fixes object managers sometimes missing object-changed events. How that
happens is the following:

- object activation transitions are advanced in idle callback
- they are aborted on registry global removal events
- registry global removal event can arrive before the idle callback
- wp_object_abort_activation uses wp_transition_get_completed to
  determine whether transition was completed, but it returned bogus
  values on transitions that hadn't been started.
2022-03-05 23:43:02 +02:00
George Kiagiadakis
b95da3393c alsa: also try the profile description if the pcm name is empty, for node.nick 2022-03-01 12:11:25 +02:00
George Kiagiadakis
4e5af26382 alsa: use the pcm name to populate the node.nick
This avoids using device.nick, which is the card name, on all nodes
of a card. Useful on UCM, where analog, hdmi, etc are all exposed
as nodes on a single profile.
2022-03-01 11:35:55 +02:00
Wim Taymans
afbc0ce57a si-audio-adapter: relax format parsing
Some nodes can omit the format/rate/channels to indicate that they can
deal with all possibilities and adapt to what they are linked to.

See pipewire#876
2022-02-25 16:47:09 +00:00
Julian Bouzas
33d105c2b6 conf: add property to disable dummy AVRCP player in bluetooth.conf 2022-02-25 16:41:49 +00:00
Pauli Virtanen
2c58de2cc5 scripts: policy-node: don't use fallback for dont-reconnect w/ target
Connecting dont-reconnect nodes that have a defined target to fallback
probably does not make sense.

They will be linked to a target that the client likely did not intend,
and the link will not be changed later on.

In Pulseaudio, if the defined target is not found, streams are not
connected to the fallback but instead fail. This happens also with
streams that don't have DONT_MOVE specified.

Pipewire-media-session also did not link dont-reconnect streams with a
defined target to the fallbacks.
2022-02-25 16:39:12 +00:00
Pauli Virtanen
d303534cba policy-node: don't move already linked dont-reconnect nodes
Dont-reconnect streams should not be moved to a new target, even though
other streams would move.

Pulseaudio DONT_MOVE works like this, and also pipewire-media-session
worked like this.
2022-02-25 16:33:46 +00:00
Pauli Virtanen
54894eabb7 scripts: policy-node: handle device linkable removal
When device nodes go away, we should remove links and peer_id references
concerning them, so that we don't leave behind stale links and stale id
entries in the peer_id tables.

Also fix bug in si_flags[out_id] handling in unhandleLinkable.
2022-02-25 16:33:46 +00:00
Julian Bouzas
6133d85392 policy-device-profile: Don't restore if active profile is persistent and default
Fixes #204
2022-02-25 16:11:40 +00:00
Julian Bouzas
8f4a848223 object: abort queued transitions if current transition failed. 2022-02-21 09:37:44 -05:00
Marko Gobin
b8b3f17181 config: add more chromium based browsers to media-role.applications 2022-02-21 07:42:11 +00:00
Pauli Virtanen
c6aa44ca26 policy-node/create-item: fix handling of linkables pending activation
Policies need to know if there are session items that are pending
activation. Linkables are not activated in the same order as nodes
appear, which causes problems for e.g. resolving target nodes, if some
of the linkables are pending.

Register linkables in create-items before they are activated.  When
activation completes, remove those that did not activate successfully.
Policies can filter out inactive items by tracking active-features
flags.

If there are existing linkables that are not ready, suspend policy-node
processing, and continue it only after all linkables are ready.
2022-02-20 21:59:39 +02:00
Julian Bouzas
edf0dc69d1 config: rename default-routes.lua to policy-device-routes.lua
This makes the configuration more consistent. The storing of the default routes
logic needs to be implemented eventually in a C module-default-routes, similar
to module-default-profile.
2022-02-16 13:37:40 -05:00
Julian Bouzas
2d303cf6a9 policy-device-profile: add option to set persistent profiles
Persistent profiles will never change. This can be useful if we want to keep
a specific device profile even if a new one with higher priority becomes
available. For example, keep the 'off' profile instead of switching to best
profile when monitor screens is resumed.

See #138
2022-02-16 13:37:40 -05:00