Commit graph

1669 commits

Author SHA1 Message Date
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
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
585ad72c7c spa-json: add null character when finishing building json 2022-02-01 16:07:12 +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
Julian Bouzas
b0ddd6f890 m-lua-scripting: add Json.Raw constructor 2022-01-26 09:53:24 -05: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
46ab414a04 spa-json: fix coverity scan issues 2022-01-25 21:18:16 -05:00
Julian Bouzas
5bef0f240f default-nodes: use WpSpaJson API 2022-01-25 07:40:59 -05:00
Julian Bouzas
20187e07b5 m-lua-scripting: add WpSpaJson API 2022-01-25 07:20:35 -05:00
Julian Bouzas
4c1574117a spa-json: add new WpSpaJson API 2022-01-25 07:20:35 -05: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
95e7c4abe8 m-default-nodes-api: add API to get and set default configured node name 2022-01-25 09:57:33 +00:00
Julian Bouzas
10531e95b5 default-nodes: reevaluate when device params changed
Some devices have different nodes for speakers and headphones. In that scenario,
this change notifies the policy to re-link all clients to the new default node
when the user plugs and unplugs the headset.
2022-01-24 16:18:31 -05: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
Julian Bouzas
411378d9fd spa-pod: add missing API sentinel 2022-01-21 13:59:03 +00:00
Wim Taymans
3239c03e2f lib: assert non-NULL input for wp_spa_pod_equal
It should not be called with NULL values or it'll crash.
2022-01-21 13:55:26 +00:00
Wim Taymans
7d4369c1af tests: don't leak fd in test 2022-01-21 09:45:29 +01: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
George Kiagiadakis
c22fbe9ad0 docs: actually mention correct numbers in the priority.session note 2022-01-19 12:57:34 +02:00
George Kiagiadakis
f84778ff8e docs: add a note about good priority values for nodes
Related to #145
2022-01-19 12:29:12 +02: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
93d3051966 Revert "default-nodes: increase priority if node has available routes"
This reverts commit ad80faaa8d.

The same issue is fixed by the intermediate commit by Wim. Let's revert
this to keep the logic in-sync with policy-node.lua and media-session.
2022-01-14 17:55:24 +02:00
Wim Taymans
211f1e6b6c default-nodes: handle nodes without Routes
When a node has not part of any EnumRoute, we must assume it is
available.

Fixes selection of Pro Audio nodes as default nodes.
2022-01-14 16:32:04 +01:00
Julian Bouzas
ad80faaa8d default-nodes: increase priority if node has available routes
Fixes #163
2022-01-14 09:15:08 -05:00
George Kiagiadakis
afb177b5e0 release 0.4.7 2022-01-13 11:27:44 +02: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
Julian Bouzas
8844cfb074 device-activation: show device name in logs 2022-01-12 19:27:17 -05:00
Julian Bouzas
b4245d64c5 default-nodes: add more logs 2022-01-12 19:26:49 -05:00
mazunki
bbd23fa3e3 added support for disabling nodes and devices through conf 2022-01-12 13:07:05 +00:00
Julian Bouzas
75281d8681 default-nodes: check if default node has available route
Fixes #145
2022-01-12 07:16:08 -05: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
Julian Bouzas
07a0a5b404 default-nodes: check if the ports exist in rescan_om
Ports might not be ready in the node's port object manager yet.

Fixes #153 and #150
2022-01-12 09:48:36 +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
bc76cb7d74
spa-pod: fix different architecture errors for boolean values 2022-01-09 10:22:47 +02:00
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
9a733293d7 release 0.4.6 2022-01-06 18:11:51 +02:00
Julian Bouzas
0d008dce75 m-default-nodes-api: don't return stream node if default node name matches
Stream nodes can never be default nodes, so we skip them in case they have the
same name as the actual default node.

Fixes #130
2022-01-06 06:50:32 +00: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
George Kiagiadakis
1c85139640 bump pipewire dep to 0.3.43
we now need it for spa_json_parse_stringn()
2022-01-05 18:13:10 +02:00