Commit graph

988 commits

Author SHA1 Message Date
Pauli Virtanen
44d958d397 pulse-server: show warning about snap kernel features only once
Don't spam the warning about kernel missing features required for snap
on every pulseaudio connection, but instead show it only once, as the
situation is not going to improve.
2024-05-01 13:17:31 +03:00
Barnabás Pőcze
6a26e6dd3f treewide: fix some format string issues
Use the proper specifier, and cast to a known type where the type
is not guaranteed by any standard.

See #3975
2024-04-25 07:24:10 +00:00
Barnabás Pőcze
4cea8eb01f pulse-server: use memcpy() to write string into message
The length of the string is already known, so use `memcpy()`
instead of `strcpy()` to copy the string into the message buffer.
2024-04-16 07:37:12 +00:00
Barnabás Pőcze
150211a3f8 pulse-server: message_dump(): fix format_info memory leak 2024-04-16 07:37:12 +00:00
Barnabás Pőcze
3fa92bbd15 pulse-server: ignore unsaveable values when deserializing property list
PulseAudio's property list can store arbitrary data, but
pw_properties can only store null-terminated strings.
So for the time being, ignore those values that don't
have null-terminators or have zero bytes inside.
2024-04-16 07:37:12 +00:00
Barnabás Pőcze
12bddf6521 pulse-server: stricter length checking when deserializing property list
The length of the value for each value in a property list is serialized
twice. Both the reference implementation and pipewire-pulse send
the same length, so be stricter and only accept a property list
if both lengths are the same.
2024-04-16 07:37:12 +00:00
Wim Taymans
c534acac46 spa: handle empty values better
Make sure the properties are not empty before trying to access them.
2024-04-10 11:08:40 +02:00
Wim Taymans
7e9e261fa6 conf: support property rules
Add pw_conf_section_update_props_rules() that will not only update the
properties of a section but wil also apply rules in section.rules and
match against the context properties.

Use this by default when using pw_context_conf_update_props().

Add a new method to get a string name of the VM type. Place the
cpu.vm.name in the context properties.

This makes it possible to deprecate the vm.overrides with something more
flexible based on rules. Update the conf files and docs to refect this.
2024-03-15 12:10:41 +01:00
Wim Taymans
ea524b158c audioconvert: add monitor.passthrough option
Add a monitor.passthrough option. This will pass all latency information
directly between the port and its monitor ports.

This is interesting when the adapter (and audioconvert) is used with a
null-audio-sink that simply forwards the data to a real sink/souce. In
that case, we want the sink/source latency to be passed unmodified.

Set the monitor.passthrough on the pulseaudio null-sink because
a passthrough virtual sink is the most likely use case for this.

Add some monitor.passthrough default config where it makes sense.

Fixes #3888
2024-03-11 16:20:27 +01:00
Wim Taymans
3c27dcd868 pulse-server: Make sure peer_sink name is filled
Use 'unknown' when we can't find the peer_name. Otherwise we will just
get a protocol error when the node.name is missing.
2024-02-19 17:39:39 +01:00
Sergio Costas Rodriguez
4d3658b271 snap-policy: fix memory leak
This patch fixes a memory leak when there is a snap with an
invalid ID.
2024-02-03 13:08:38 +00:00
Sergio Costas
fed1432172 snap-policy: ensure audio works with .deb snapd 2024-02-03 13:07:56 +00:00
Sergio Costas
e8fcaa5157 snap-policy: Manage ENOPROTOOPT error in aa_getpeercon() 2024-01-30 10:28:27 +00:00
Wim Taymans
306c90618f pulse-server: the device changed when EnumRoute changes
We use EnumRoute of the card to fill in the ports of the device so when
EnumRoute changes, the associated devices also needs a change event.
2024-01-24 11:22:52 +01:00
Wim Taymans
bffcb2e6f1 pulse-server: implement subscribe in device-restore
Add a client that subscribes to the list of subscribers and make the
client watch for EnumFormat changes.

When a subscribed client sees an EnumFormat change for a sink, emit EVENT
to the client.

This will send the EVENT to pavucontrol when the supported IEC958
formats change so that it can update the gui.
2024-01-23 18:08:32 +01:00
Wim Taymans
979eb0278f pulse-server: reset spa_param_info.user after events
After we emited all changed events, reset the user field. This way the
event handlers can check what params are changed.
2024-01-23 18:06:45 +01:00
Wim Taymans
ac91c0dc1c pulse-server: implement stream-restore EVENT
Add method to update the client routes. Add an event when the client
routes changed.

Listen for route_changed events on clients that do a subscribe on the
stream-restore extension. Emit an EVENT when the routes change.

This keeps the system notifications volumes in sync between
gnome-control center and pavucontrol and probably in other tools
as well.

Fixes #3805
2024-01-23 13:31:05 +01:00
Wim Taymans
d71fb40989 pulse-server: move extension to modules
Add extension support to modules. This is a list of extension commands
that can be performed on the module.

Remove the custom registry of extensions and make proper modules that
implement the extensions.

This is more in line with what pulseaudio does. The advantage is that the
modules actually show up in the module list and that we can use the
module user_data to implement the extension later.
2024-01-23 13:31:05 +01:00
Sergio Costas Rodriguez
8c3cfab17b Replace even more spaces with tabs 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
e1571404d7 Replace more spaces with tabs 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
6506bb2f44 Replace spaces with tabs 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
fda4addf1e Fix spacing when calling functions 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
1c9016280c Move add_permission definition inside block 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
67b9e9c4e8 Move context variable definition inside block 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
18d0e2e850 Move variable definition inside block 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
1728b7de59 Better error logging if getting connections fails 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
ae11e61105 fix possible leak
If pw_check_flatpak() sets app_id, its value will leak when
calling pw_snap_get_audio_permissions(). This patch fixes
this.
2024-01-12 11:35:17 +00:00
Barnabás Pőcze
abc4bd111b Apply 1 suggestion(s) to 1 file(s) 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
b054bc2591 Use assert to check client is not NULL 2024-01-12 11:35:17 +00:00
Barnabás Pőcze
c34bd9575f Apply 1 suggestion(s) to 1 file(s) 2024-01-12 11:35:17 +00:00
Barnabás Pőcze
69b093ebf1 Apply 1 suggestion(s) to 1 file(s) 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
5e20a2d570 Add missing files
Accidentally, I forgot to add snap-policy.* files.
2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez
d568dcd64f pipewire-pulse: add snap permissions support
SNAP containers have two main "audio" security rules:

 * audio-playback: the applications inside the container can
   send audio samples into a sink

 * audio-record: the applications inside the container can
   get audio samples from a source

Also, old SNAP containers had the "pulseaudio" rule, which just
exposed the pulseaudio socket directly, without limits. This
is similar to the current Flatpak audio permissions.

In the pulseaudio days, a specific pulseaudio module was used
that checked the permissions given to the application and
allowed or forbade access to the pulseaudio operations.
With the change to pipewire, this functionality must be
implemented in pipewire-pulse to guarantee the sandbox
security.

This patch adds support for sandboxing permissions in the
pulseaudio module, and implements support for the SNAP audio
security model, thus forbiding a SNAP application to record
audio unless it has permissions to do so.

The current code for pipewire-pulseaudio checks the permissions
of the snap and adds three properties to each new client:

 * pipewire.snap.id: contains the Snap ID of the client.

 * pipewire.snap.audio.playback: its value is 'true' if the client
   has permission to play audio, or 'false' if not.

 * pipewire.snap.audio.record: its value is 'true' if the client
   has permission to record audio, or 'false' if not.

These properties must be processed by wireplumber to add or
remove access permissions to the corresponding nodes. That
code is available in a separate patch: https://gitlab.freedesktop.org/pipewire/wireplumber/-/merge_requests/567
2024-01-12 11:35:17 +00:00
Wim Taymans
9a5609de2b modules: move some spa_debug_mem to the log
Instead of dumping to stderr, write it to the log file.
2024-01-11 17:49:50 +01:00
Wim Taymans
3baba76c77 pulse-server: improve message debug
Add prefix to messages to mark sent and received messages.
Send mem debug to log instead of stderr.
Log the complete message and debug the command.
2024-01-11 12:05:29 +01:00
Wim Taymans
3da66734bd modules: add reconnect support to module-pulse-tunnel
When the pulse connection is broken, reconnect with the given interval.

Add the reconnect_interval_ms property to the pulse modules.
2024-01-05 13:34:19 +01:00
Wim Taymans
370bf7206b pulse-server: add pipewire-pulse:log-level message
Add a /core message to set the log level of the pulse-server.

An alternative would be to watch the settings metadata and follow the
server settings. This is however less flexible so the custom message
was chosen.
2024-01-04 17:43:53 +01:00
Wim Taymans
a3c6b3acae log: add pw_log_topic_custom_enabled()
Add a function to check if a specfic custom log level has been defined
for a topic.

We can use this to dynamically check if we need to do the connection debug
messages.

We can also get rid of the conn.* pattern hack to disable connection
messages by default.
2024-01-04 17:40:57 +01:00
Wim Taymans
8f66df2f78 pulse-server: call update_object_info in manager_added
get_device_info() requires us to call update_object_info() in the added
and updated events.

Fixes a bug where the properties were invalid in the avahi txt record.
2024-01-04 10:43:03 +01:00
Duncan Overbruck
fffda6b6d1 pulse-server: fill in active port for monitors
The monitor sources also list the port of the sink and so the active
port needs to be collected as well so it doesn't fall back to the first
port (which might not be available).
2023-12-20 10:15:06 +01:00
Mark Gallagher
ee42a6868d Add pulseaudio gsettings schema 2023-12-16 21:09:17 +01:00
Wim Taymans
06d6551cc1 pulse-server: handle errors in echo-cancel geometry
Check for errors when loading the geometry instead of silently failing.
The points need to be given in the user locale and so might fail to
parse when given in JSON format.

Format the geometry nicely when loading the module.
2023-12-14 12:16:29 +01:00
Wim Taymans
5e750f6fb8 modules: place floats in properties in JSON format
Using %f will result in a locale dependent format and might not parse
with JSON parsers or even our own spa_atof() function.
2023-12-14 11:50:30 +01:00
Pauli Virtanen
4e2057930f pulse-server: update all params only after enumeration complete
For params that don't emit change events, the param enumeration does not
start core sync, and its enumeration may be incomplete if a previous
core sync completes first.

Fix by always starting a core sync if we are updating params.

This fixes dev_info.active_port being sporadically SPA_ID_INVALID if
there is event pressure, which causes do_set_volume randomly set the
volume on the node instead of setting it on the device.  This can be
triggered e.g. by shaking the volume slider in Pavucontrol with mouse.
2023-12-09 11:23:25 +00:00
Barnabás Pőcze
d88def09bd pipewire: module-roc-{sink,source}: add rudimentary ROC_INTERFACE_AUDIO_CONTROL support 2023-11-23 17:21:39 +01:00
Barnabás Pőcze
333fd8d2ae pipewire: module-roc-{sink,source}: port to ROC v0.3.X
ROC 0.3 introduced breaking changes, so adjust the code.
Also set the minimum supported ROC version to 0.3.0.

Fixes #3667
2023-11-23 14:12:35 +01:00
Wim Taymans
0c857f5455 pulse-server: add stream/device state in dev_info
Also include and update the state of the device/stream in
collect_device_info so that we can compare it against the previous value
and emit a change event.

Fixes #3660
2023-11-20 11:39:31 +01:00
Pauli Virtanen
90bd9adb6b pulse-server: rename combine sinks option
Let's call it "sinks" in the docs, but keep the Pulseaudio name for
backward compat.
2023-11-20 08:41:13 +00:00
Pauli Virtanen
843e733479 doc: add documentation for pipewire-pulse modules
Add (minimal) reference documentation for each pipewire-pulse module.

Add some preprocessing to substitute @pulse_module_options@ in docs from
PW_KEY_MODULE_USAGE so the module options don't need to be repeated.

Produce Doxygen docs + generate manpages pipewire-pulse-modules.7,
pipewire-pulse-module-*.7
2023-11-20 08:41:13 +00:00
Wim Taymans
11320cf203 tweak number of buffers
In most cases we can use just 1 buffer.

The alsa-pcm-source needs at least 2 buffers so increment the min
limit.
2023-10-13 14:00:29 +02:00