Commit graph

631 commits

Author SHA1 Message Date
Wim Taymans
b23e33c99f media-session: only replace : with space for node.nick 2021-02-13 07:17:55 +01:00
Wim Taymans
062911640c media-session: sanitize name and nick
Replace unwanted chars in the name with _. This makes it compatible
with pulseaudio names and avoids problems with regex.
Replace unwanred chars in the nick with ' '. This ensures JACK
clients don't receive ':' in the device names, which cause it to
fail when parsing the ports.

See #714 and #130
2021-02-12 20:47:41 +01:00
Wim Taymans
2c2ba6eec3 media-session: handle missing dbus support 2021-02-12 17:55:56 +01:00
Wim Taymans
04354215b6 media-session: get the right key for properties 2021-02-12 17:28:52 +01:00
Pauli Virtanen
dfb3bff15b bluez5: fix source priority assignment 2021-02-12 16:11:56 +00:00
Wim Taymans
3cc577ddd6 v4l2: fix sink/source and output/input names 2021-02-12 16:13:00 +01:00
Wim Taymans
2a83811297 bluez: input = source, output = sink 2021-02-12 16:10:58 +01:00
Wim Taymans
fc90a4e48a Implement config/state file handling
Make methods to load_config and load/save state. For now the config
and state directories are the same but it might not be. Implement
the search path for all config/state files as:

  $XDG_CONFIG_HOME/[$prefix]/$name
  $HOME/.config/[$prefix]/$name
  $PIPEWIRE_CONFIG_DIR/pipewire/[$prefix]/$name
  /etc/pipewire/[$prefix]/$name

Make some config files for jack and RT clients. Make pw-cat use the
client-rt config.

Use core state and config management in media-session.
Move all session manager state and config files to the build dir and
set the PIPEWIRE_CONFIG_DIR to this build dir.
2021-02-12 10:25:11 +01:00
Wim Taymans
c605672d43 Implement per client config files
Move the daemon config file loading to a new conf.c file used by
the context to load the configuration. This replaces the module
profiles and some hacks to move properties around.

If there is nothing other specified with $PIPEWIRE_CONFIG_NAME or
a property, the client.conf file is loaded as a fallback.

Update the session manager config file to load the modules via the
config now. Rename the session modules section to another name.

Update pipewire-pulse to also load a specific pulse property file.
This then makes it pssible to assign specific RT priorities for the
pipewire-pulse process.
2021-02-12 10:07:16 +01:00
Wim Taymans
6b11bf71f3 media-session: remove unused code 2021-02-11 12:17:00 +01:00
Pauli Virtanen
beaec3d003 bluez5: set initial profile based on what's connected at startup
Set initial device profile according to what's connected at startup,
rather than having media-session try to set it to A2DP (and fail, if the
profile was not connected, resulting to startup in null profile).

This avoids making a codec switch at device startup (we'll stay with
what BlueZ autoconnected us to, usually the previously used codec).
2021-02-11 11:13:42 +00:00
Wim Taymans
2af7f8204a media-session: remove add_spa_lib, we do this in the config 2021-02-10 11:54:10 +01:00
Jonas Holmberg
f977c45240 media-session: add dbus property to media-session 2021-02-09 18:09:33 +00:00
Jonas Holmberg
d624ed26f4 media-session: add alsa.reserve property to alsa-monitor 2021-02-09 18:09:33 +00:00
Wim Taymans
739f3b9f7f media-session: disable JACK device by default
It is most likely to fail right now.
2021-02-09 17:37:08 +01:00
Wim Taymans
e6ea01046e media-session: add some logging to bluez volume handling
See #699
2021-02-09 10:57:16 +01:00
Pauli Virtanen
db6baf6188 media-session: use separate keys for configured default nodes
Use separate metadata keys for the current effective default nodes
(default.*), and user-configured ones (default.configured.*).

default-nodes saves and restores the configured ones, and policy-node
keeps the effective ones up to date.

For pipewire users, the effective default values should be considered
read-only, as changing them will not have an effect.  To avoid
confusion, policy-nodes will reset their values back immediately if they
are changed.
2021-02-06 18:10:28 +00:00
Wim Taymans
1581b6cfce media-session: give more permissions to Manager flatpaks
If a flatpak app has the Manager media.category set, assign more
permissions to it for now. We should later check with the
permission store if this is really allowed.
2021-02-04 11:53:03 +01:00
Wim Taymans
2b44f42845 pass the complete buffer size to snprintf
There is no reason to pass size-1, snprintf will always put a \0
at the end.
2021-02-02 12:09:29 +01:00
Wim Taymans
a18a8c9e32 media-session: save and restore profile ports
Save the last explicitly set ports per profile.
When a profile change happens, restore the saved ports or select
the best port when nothing was saved.
2021-02-01 18:02:32 +01:00
Wim Taymans
5e15411af4 alsa-monitor: use max channels on non-ACP devices
Otherwise, they might still negotiate to something less than the
max channels.
2021-02-01 15:16:39 +01:00
Pauli Virtanen
f7db158bd6 media-session: give bluez5 objects driver.priority
Makes bluez devices as automatic default devices, with priority slightly
larger than alsa devices.  The priority.driver is also used by
pulse-server on determining automatic default devices, when no default
has been manually set.
2021-01-30 15:00:33 +02:00
Wim Taymans
8fd120cb23 media-session: recheck route status when != available
Save the new state so we can detect changes
Check for available != yes to also recheck when the state becomes
unknown.
2021-01-29 17:23:02 +01:00
Wim Taymans
f43bcca35e media-session: implement route selection and restore
Disable automatic port configuration in acp and move the logic
to the session manager.
Implement initial port selection and restore on profile activation.
Implement route switch when unavailable
Implement port settings save.
2021-01-29 16:59:17 +01:00
Wim Taymans
c0ed88f2f9 media-session: always try to activate the saved profile
When the current profile is not the saved profile, check if the
saved profile is available again and try to activate it.
2021-01-28 16:56:27 +01:00
Wim Taymans
f03deb5324 media-session: try to avoid switching away from hdmi
When HDMI goes to sleep the profile becomes unavailable. Avoid
switching to Off in that case.
2021-01-28 15:41:14 +01:00
Wim Taymans
fc08c79dad media-session: start timeout only when something changed 2021-01-28 14:36:29 +01:00
Wim Taymans
072d3a191c media-session: keep track of all active routes
Keep track of active profile in default-routes so that we can restore
the prefered routes later.
Keep track of all active routes in an array. There can be more than
one active route per direction.
New routes will get their volume restored. Route changes will be saved.
2021-01-28 14:28:46 +01:00
Wim Taymans
b8bac95dad media-session: add info logging to profile restore logic 2021-01-28 11:43:17 +01:00
Wim Taymans
5dc2a7b793 policy-node: reverse config direction for virtual devices
For a virtual source we want to configure it like a sink with
input ports and the monitor ports as the capture ports.
2021-01-27 16:27:06 +01:00
Wim Taymans
295cba8404 policy-node: a virtual source is an output node 2021-01-27 16:14:39 +01:00
Wim Taymans
82bc0710f0 media-session: use a default volume if unknown
Set a safe volume when there is no previously saved volume.
2021-01-27 15:44:52 +01:00
Wim Taymans
0be851739f improve config parsing
Use get_string to get object keys in a more generic way.
2021-01-27 15:36:32 +01:00
Wim Taymans
585f533d27 media-session: move profile selection to media-session
Disable automatic profile selection in the acp device
Implement selection of profiles in the default-profile module
2021-01-27 13:48:10 +01:00
Wim Taymans
cf35e52586 media-session: use the right define for the bitmask 2021-01-27 13:48:10 +01:00
Wim Taymans
c95bd1c3d4 media-session: avoid restoring an unavailable profile 2021-01-25 16:00:20 +01:00
Wim Taymans
98a3527685 media-session: init current_profile to invalid
So that we can detect a switch..
2021-01-25 15:53:54 +01:00
Wim Taymans
39f082fc86 default-profile: don't try to restore bluetooth profiles 2021-01-25 13:17:22 +01:00
Wim Taymans
3366eeb65e media-session: restore route volumes
Follow the active input/output routes. If the route changes, restore
the previously saved settings. If only the properties change, save
them to be restored later.

Fixes #402
2021-01-25 12:11:16 +01:00
Wim Taymans
2c4c78c51e media-session: add alsa.jack-device property to alsa-monitor 2021-01-20 13:48:06 +01:00
Wim Taymans
8f80a2bc15 media-session: handle key == NULL
The key can be null when the metadata subject is removed.
2021-01-19 17:01:24 +01:00
Wim Taymans
579e8a4ea6 json: allocate one extra byte for the \0 2021-01-19 16:56:55 +01:00
Wim Taymans
8c84c96fe1 daemon: add support for mlockall 2021-01-19 12:17:29 +01:00
Pauli Virtanen
d1a0121b7c policy-node: handle moving streams when target.node is removed
When target.node metadata is unset, unset it also from the session node.
Schedule rescan in case this affects links.
2021-01-18 22:22:43 +02:00
Wim Taymans
272c0a4d83 policy-node: silence some normal warning
When a target-node is destroyed from a dont-reconnect node,
kill the node.
2021-01-18 20:56:40 +01:00
Pauli Virtanen
b10123eceb policy-node: make streams follow default sink/src changes
The motivation is to have both existing and new streams that have been
created without explicit target node, to be directed to the same devices
at all times. To achieve this:

Consider what find_node returns as the "default node".

Consider streams that auto+reconnect and don't have an explicit target,
as following default.  In rescan, if the default node has changed,
relink such streams to the new default.

Remove the old code that explicitly moved streams when the default.*
metadata changed, as it implements a similar thing but in a less robust
way (may fail to do what's intended, because the default device
metadata is commonly unset, or the metadata callback comes before
session_create has seen the new nodes).

Enable this feature based on "policy-node.streams-follow-default"
property. Allow setting the property also by loading the
streams-follow-default module. Enable it by default only for the
with-pulseaudio module group.
2021-01-18 20:49:58 +01:00
Wim Taymans
9b9b85ddbf alsa: put card name in udev monitor event
So that we can use it to construct a good name for the card.

Fixes #524
2021-01-17 11:35:27 +01:00
Wim Taymans
abe73c9146 meson: use global b_pie to build PIE executables 2021-01-14 16:29:32 +01:00
Wim Taymans
de851018c1 media-session: fall back to card_name for description
Also try to use the alsa.card_name property for the description if
there is nothing else.

Fixes #524
2021-01-13 19:49:24 +01:00
Wim Taymans
c9354c238f Add -fPIE to installed executables
Fixes #570
2021-01-13 19:40:37 +01:00