Commit graph

1037 commits

Author SHA1 Message Date
Pauli Virtanen
ab725987d7 scripts: policy-bluetooth: fix headset profile saving
Headset profile saving does not work properly currently (only called on
metadata change; if headset-profile == current-profile, it doesn't get
saved etc.)

Change it to follow the logic:

- Each device has a "normal" and "switched" mode.  The latter becomes
  active if a "communication" input stream exists and the current
  default sink is bluez sink.  The switched mode is exited only when
  there are no "communication" input streams.

- On transition normal->switched, record current profile as the "saved"
  profile. Then switch to "headset" profile.  If no headset profile
  was saved previously, pick profile with input direction & highest
  priority.

- On transition switched->normal, save currently active profile as the
  "headset" profile. Then switch back to "saved" profile.
2022-02-02 10:33:24 +00:00
Pauli Virtanen
c1f5e57047 scripts: policy-bluetooth: fix state_table usage
State saves everything as strings, so the get* routines have to convert
back.
2022-02-02 10:33:24 +00:00
Pauli Virtanen
2b1ee0c5b9 scripts: policy-bluetooth: ignore monitor streams properly
Monitor streams can be identified based on the stream.monitor property.

They should not be identified based on application name, because that
may be localized, and the previous code does not work properly on
non-English locale.
2022-02-02 10:33:24 +00:00
Julian Bouzas
384c5775f8 default-nodes: add option to auto-switch to echo-cancel nodes
This option is enabled by default now.
2022-01-27 14:55:21 -05:00
Julian Bouzas
2ba94f632b policy-node: schedule rescan if device params changed
Allows auto-switching to headphones if echo-cancel module is enabled, and the
audio device has different nodes for speakers and headephones.
2022-01-27 11:25:58 -05:00
Niklas Furtwängler
da023e1834 conf: added ability to disable MIDI functionality entirely 2022-01-27 15:22:33 +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
Pauli Virtanen
2db8c0a288 bluez5: fix initial profile selection
Currently, spa-bluez5 devices start in non-off profile, which causes
m-device-activation logic to set the highest priority profile instead of
the saved one.

Fix this by having spa-bluez5 start devices in off profile, similarly as
spa-alsa does.
2022-01-24 07:32:22 +00:00
Wim Taymans
0c3be71ceb conf: update module-rt usage in bluetooth.conf
We now only use module-rt. Explicitly set the nice.level to -11 instead
of leaving the default (do nothing). Adjust the rt limits to their new
defaults in module-rt (unlimited).
2022-01-19 12:22:58 +01:00
Wim Taymans
9100064446 conf: update module-rt usage
We now only use module-rt. Explicitly set the nice.level to -11 instead
of leaving the default (do nothing). Adjust the rt limits to their
defaults in module-rt.
2022-01-18 13:34:23 +01:00
Sanchayan Maity
ef7504bdc8 scripts: policy-bluetooth: Support saving of user selected headset profile
The "saved headset profile" is taken as the profile that was active when
the headset mode deactivates. So in case the user switches profile during
the time when the Communication input stream is active, the selected
profile is remembered next time.
2022-01-14 16:49:27 +00:00
Sanchayan Maity
99d0fa3196 scripts: Add a bluetooth policy script
Allow switching bluetooth profile based on presence of media.role or
a list of specified applications.
2022-01-14 16:49:27 +00:00
Sanchayan Maity
5fba8af1e6 scripts: intended-roles: Use both device and stream
When a stream gets added, we might have a situation where the device
does not yet exist to actually link on the basis of intended role. For
example this can be observed if no mic sources are present and then the
mic appears after a bluetooth profile switch to HFP.

To fix this, iterate over streams when a device connects in addition to
iterating over devices when a stream connects.
2022-01-14 16:49:27 +00:00
George Kiagiadakis
18bc3d3596 scripts: fallback to empty config table if args were not passed from the config files
Fixes #158
2022-01-13 11:10:03 +02:00
mazunki
bbd23fa3e3 added support for disabling nodes and devices through conf 2022-01-12 13:07:05 +00:00
Julian Bouzas
40b16974cf scripts: monitors: log warning if spa devices were not created successfully
Can happen if the user does not have the specific spa pluging installed.
2022-01-12 10:09:56 +00:00
Ashok Sidipotu
2e23d82779 policy-endpoint-client.lua: fix record with endpoints
The Role traversal of config data to take notice of the
media class as well so that source and sink roles dont
overstep on each other and pick up unexpected endpoints.
2022-01-11 15:31:40 +05:30
Ashok Sidipotu
99dfa7d38a config: update the endpoints config
-Sync endpoints config from AGL.
-Add a capture endpoint.
2022-01-11 15:30:30 +05:30
Julian Bouzas
bee9827ae3 policy-node: find best linkable if default one cannot be linked
Fixes issue with echo cancellation pipewire module.
2022-01-08 15:14:44 +00:00
Julian Bouzas
afe71d7e48 policy-node: schedule a rescan without timeout if defined target is not found
Fixes #146
2022-01-08 06:48:16 +00:00
Julian Bouzas
23fc4d21a9 policy-node: fix typo when finding best target 2022-01-07 10:12:04 -05:00
George Kiagiadakis
3f3c9802d6 create-item: downgrade warning to message
This is expected to be printed if a stream opens and closes
very quickly, like in the case of pipewire-alsa opening the device
for querying formats and then closing it immediately.
2022-01-05 18:13:41 +02:00
Julian Bouzas
6adccbe33d policy-node: always use the default linkable if default nodes module is loaded
If the default nodes module is loaded, and the default node is not found, it
means that there is no valid target for that session item. We only need to
manually find a default target if the default nodes module is not loaded.
2022-01-05 08:57:33 +00:00
Jonas Holmberg
e1602c10c5 policy-node.lua: Fix nil value indexing
Fixes the warning:

[string "policy-node.lua"]:117: attempt to index a nil value (field '?')
stack traceback:
  [string "policy-node.lua"]:117: in function <[string "policy-node.lua"]:109>
2022-01-05 07:04:09 +00:00
George Kiagiadakis
dc50f95910 config: add commented-out "session.suspend-timeout-seconds" option in alsa config
For the sake of discovering this more easily
2022-01-05 08:28:52 +02:00
George Kiagiadakis
03c2a3dfbd suspend-node: use a 5sec timeout by default, to be inline with the docs 2022-01-05 08:28:52 +02:00
Wim Taymans
4896ad0680 json: improve json parsing
spa_json_get_string() will never write more than maxlen.
Use spa_json_parse_stringn() to perform destination length checking.
2022-01-04 16:36:15 +01:00
Wim Taymans
071ad0e43f config: add property for audio.allowed-rates 2022-01-03 16:05:17 +01:00
George Kiagiadakis
64841f5ada config: enable RT on the data thread for bluetooth nodes
Closes #132
2022-01-03 13:36:49 +02:00
Julian Bouzas
a59dc92928 policy: use a scheduleRescan function to avoid unneeded rescans 2021-12-22 16:52:16 +02:00
Julian Bouzas
c6445ed3db create-item: don't register item if failed to activate
Related to #128
2021-12-22 16:27:07 +02:00
Julian Bouzas
22fd4292ab default-routes.lua: reevaluate current profile only for its own routes
Only check the current active profile when some routes changed that are part of
the profile. If some other route changed, just ignore it.
2021-12-07 14:20:31 -05:00
Torkel Niklasson
be7b95cd3c policy-node.lua: Fix si_link activation failure handling
If si_link fails to activate, we got an error saying
"attempt to index a nil value". This fixes the nil value problem
and also changes the warning to an info, since some of our badly
behaved apps can cause this and we don't see any problems resulting
from it.
2021-12-02 15:07:11 +01:00
George Kiagiadakis
69bd1e51ce default-routes: make the default volume configurable 2021-11-30 19:30:25 +02:00
Wim Taymans
703c35cfd4 access-config: add restricted access permissions
When a pulse client connects with TCP, it is given the 'restricted'
access policy. Assign 'rx' permissions for those clients instead of
blocking forever.

See pipewire#1863
2021-11-29 09:25:18 +01:00
George Kiagiadakis
147f235f54 policy-node: don't crash if device.id is not set on a target 2021-11-26 19:57:17 +02:00
Ashok Sidipotu
52980fb770 policy-node: improve default device selection logic
- skip target device if it does not have active/available
routes

Fixes #74
2021-11-26 14:43:04 +00:00
Wim Taymans
efd2458418 alsa: handle the release-requested signal
Handle the release-requested signal by destroying the device and
then calling release.

Fixes pipewire/pipewire#1846
2021-11-23 13:17:29 +01:00
Wim Taymans
c88fbd20e6 Revert "policy-node: Remove direction check"
This reverts commit b6072f4179.

This is not right because when 2 nodes have the same name, there is
no way to know which one to use. It is better to rely on the
PW_KEY_STREAM_CAPTURE_SINK property when capturing from a monitor.
2021-11-23 11:47:08 +01:00
Wim Taymans
83041b0ce2 policy-node: wait for nodes when we become unlinked
If we were linked before but our node is removed, wait until a new node
becomes available instead of failing.

This fixes an issue where there is only 1 sink available and the card
profile is toggeled between pro and stereo. After the profile is
toggled, the sink is removed and the node would be killed with an error
because there is no fallback sink. The fix is similar to the
pipewire-media-session logic.
2021-11-18 15:23:23 +01:00
Peter Hutterer
9208ea051c Fix some typos 2021-11-18 12:09:57 +00:00
Wim Taymans
b6072f4179 policy-node: Remove direction check
Remove the direction check in findDefinedTarget. We already to a
better direction check in canLink().

This fixes the case where a capture stream has the node.target set
to a sink. The directions don't match and the capture stream is not
linked to the monitor ports of the sink. Removing the check triggers
the right logic in canLink() and obs studio can link to monitor
ports again.
2021-11-18 11:46:47 +00:00
Wim Taymans
45fae97036 libcamera: use the new manager object for monitoring 2021-11-15 11:58:14 +01:00
George Kiagiadakis
a743b3f741 policy-node: don't clear peer_id when removing a link that was not for that peer
It's possible that we get multiple links on the same node, ex:

player -> output (output is the selected peer)
player -> pavucontrol

When pavucontrol exits, the peer_id of player must not be cleared,
since the link to the output still exists
2021-11-11 12:08:18 +02:00
George Kiagiadakis
4579488420 policy-node: improve debug messages in findUndefinedTarget() 2021-11-11 11:56:12 +02:00
George Kiagiadakis
eb0500f621 policy-node: fix small issues in last patch (last comment in !253) 2021-11-11 11:42:10 +02:00
Ashok Sidipotu
3122a61761 policy-node: improve target device selection logic
-loop through all the linkable nodes, instead of using default nodes
-implement a priority scheme to pick the appropriate target linkables
-If both nodes support a passthrough format, check the intersection.
 If the intersection is empty and one of the node is passthrough only,
 skip the node as a target
-the logic now closely aligns with the media-session logic

Fixes #75
2021-11-11 09:19:52 +00:00
George Kiagiadakis
07cd52bcb8 policy-node: check target exists before checking if an item is linked to it
Related to #102
2021-11-10 09:26:59 +02:00
George Kiagiadakis
2580b3431b policy-node: grab si.id once in createLink() and reuse it
... and avoid passing a reference to si in the closure
2021-11-09 19:09:39 +02:00