Commit graph

1037 commits

Author SHA1 Message Date
Julian Bouzas
7080e9961c policy-node: forward filter stream's format to filter device
Currently, when using filter nodes such as echo-cancel or filer-chain, the
ports format of the virtual stream node might not always match the format of its
associated virtual device node. This can happen if the virtual stream node is
linked with a real device node configured with many channels, such as surround
profile. In that case, the channel configuration is not forwarded to the virtual
device node, making the application not being aware of a surround setup.

This change listens for port format changes in the virtual stream nodes, and
reconfigures the virtual device node ports everytime the virtual stream node's
port format changes.

This behavior is experimental and optional, so it is disabled by default.
2022-05-05 08:09:21 +00: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
George Kiagiadakis
ecb6100b77 m-lua-scripting: wrap every script in a WpPlugin and expose async activation api
This allows scripts to declare when they have finished their loading,
so we can now also know when wireplumber is done loading and ready to
handle clients

Related to !313
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
6feecab74e scripts: translate user-visible strings in alsa.lua 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
2f186c10e7 main: use WpSpaJson when loading components 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
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
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
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
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
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
Julian Bouzas
b3446efa16 config: port device-activation module to policy-device.profile.lua
Because all wireplumber policies are in Lua.
2022-02-16 13:37:40 -05:00
George Kiagiadakis
c4c5ca8e22 policy-bluetooth: fix string.find crash with nil string
Fixes #193
2022-02-14 10:38:51 +02:00
George Kiagiadakis
5f96f69218 restore-stream: do not crash if config.properties is nil
Fixes #190
2022-02-09 13:35:13 +02:00
Julian Bouzas
c4335afc51 policy-node: find best linkable if default node passthrough is not compatible
Fixes #178
2022-02-07 09:52:43 -05:00
Wim Taymans
13034fad75 main: use pw_context_conf_section_for_each()
So that we can let the config system load fragments from multiple
places later.
2022-02-03 12:53:56 +00:00
George Kiagiadakis
2ece785e85 restore-stream: export the route-settings metadata again 2022-02-03 13:05:20 +02:00
George Kiagiadakis
5028737032 restore-stream: add rules matching to allow overriding things per stream
You can now override:
* Whether to store/restore properties like volume
* Whether to store/restore the target.node
* Things like media.name/application.name/etc which affect which
  entry is going to be used in the state file

Related to #169
2022-02-03 12:07:00 +02:00
Julian Bouzas
5f2da84d51 config: move restore-stream.lua configuration in its own file
Also makes restoring the stream properties and target optional.
2022-02-02 18:37:39 +00:00
Julian Bouzas
b1b603443f restore-stream: use the new Json API and remove route-settings-api module 2022-02-02 18:37:39 +00:00
Julian Bouzas
e495d4920d policy-endpint: add support for stream audio nodes without media.role
If a stream audio node does not have the 'media.role' property set, the policy
will asign the 'Default' media role name to it. In addition to this, if the
'Default' endpoint can not be found, the policy will link the stream audio node
with the lowest priority endpoint.

Video nodes will always be handled by policy-node.lua, and they will never be
handled by policy-endpoint-client.lua

This allows users to assign a particular endpoint for streams that don't have
the 'media.role' property set.
2022-02-02 11:37:00 -05:00
Pauli Virtanen
453a7e9325 scripts: policy-bluetooth: don't switch if already have input route
If the current profile has input route, don't switch to a different
profile. Instead, consider the current profile as the new headset
profile.
2022-02-02 10:33:24 +00:00
Pauli Virtanen
5a108a7c3f scripts: policy-bluetooth: save only necessary state on disk
Only the configured headset profile needs to be persistent, the switched
status and saved profile should not persist over wireplumber restart.

When devices appear initially, they should not appear as switched,
but recheck switch status.
2022-02-02 10:33:24 +00:00
Pauli Virtanen
4dbf4f2b82 scripts: policy-bluetooth: monitor whether streams are running
Monitor whether streams are running or suspended. When they are
suspended, switch to normal mode.

This is required e.g. for programs such as Teams, which keep recording
streams open but inactive for their whole runtime.

Profile restore also needs to be done with a timeout, to avoid switching
rapidly when streams are moved between sources.

Use Lua tables properly as maps.
2022-02-02 10:33:24 +00:00
Pauli Virtanen
1fa65bf5b7 scripts: policy-bluetooth: save profiles by name, not index
The profile index may change, if the set of profiles on the device
changes, and is better to not use it for saving long-term.
2022-02-02 10:33:24 +00:00