Commit graph

13029 commits

Author SHA1 Message Date
Sergio Costas Rodriguez
5125d69a69 Better meson_options description 2024-01-12 11:35:17 +00: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
Barnabás Pőcze
b9b5a26199 Apply 1 suggestion(s) to 1 file(s) 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
adbd081b12 array: improve pw_array
Handle extend == 0 and don't expand the array but return -ENOSPC.
This makes it possible to handle static arrays, make a function to
make this easier. Remove pw_array_add_fixed() now that we support
this with extend==0 and because it was not used.

Round up the required space to next extend so that the total allocated
size if always a multiple of the extend.

Make pw_array_add_ptr() check for allocation errors instead of crashing.
2024-01-12 12:06:13 +01:00
Demi Marie Obenour
0f533c6d64 docs: Multiple clarifications to documentation
See !1817
2024-01-12 11:55:28 +01:00
Barnabás Pőcze
d8ab51a9fc pw-top: use media.name as display name
Try to use `media.name` as the display name for a node
when none of the other keys are found in its properties.

For example, `pw_stream_new_simple()` only sets `media.name`
on the created node object by default.
2024-01-12 02:12:55 +01:00
Barnabás Pőcze
9d439bac06 pw-top: update name when it changes
Recalculate the display name for a given node after its properties change.
2024-01-12 01:47:05 +01: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
Barnabás Pőcze
4b145ad444 spa: libcamera: bump minimum supported version to 0.2.0 2024-01-11 12:04:27 +00:00
Barnabás Pőcze
268f4856f8 spa: libcamera: use CameraConfiguration::orientation
libcamera commit cc65629b68d49d ("libcamera: camera: Introduce Orientation") [0]
introduced to the `CameraConfiguration::orientation` member to describe the
orientation of the image in the received memory buffers.

Then c65e40b8480ffb ("libcamera: Use CameraConfiguration::orientation") [1]
removed `CameraConfiguration::transform`, which broke the libcamera plugin.

Fix that by using the new `orientation` member.

[0]: https://git.linuxtv.org/libcamera.git/commit/?id=cc65629b68d49d5f2a4d61537584c56ba510a335
[1]: https://git.linuxtv.org/libcamera.git/commit/?id=c65e40b8480ffb5f50e01a4e6713164c7194a937
2024-01-11 12:04:27 +00: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
d0a2e6316b spa: small cleanups
Initialize result variable.
Use strncpy to avoid warnings about using non-NULL terminaded strings.
2024-01-10 15:51:01 +01:00
Wim Taymans
15908328d1 support: fix freewheel timeout in node-driver
When freewheeling we will immediately schedule a new graph cycle when we
get a process call because the graph completed.

When the process call is not done, because of some xrun or
because some node was removed that causes the graph to fail completion,
The next cycle will happen after a timeout.

This timeout was calculated as the ideal wakeup time (after a quantum of
time) and would accumulate for each timeout. The result is that the
timeout ended up far in the future and would stall the freewheel driver
for a long time.

Fix this by always setting the next timeout to wakeup time + freewheel.timeout
seconds. Also add a config property for the timeout (10 seconds, like
jack2 by default).
2024-01-10 11:59:10 +01:00
Wim Taymans
c7519c73ac spa: small cleanups
Use snprint to ensure null terminated strings.
Initialize res, it would be uninitialized when setting a NULL Latency
param.
2024-01-10 11:35:54 +01:00
Pauli Virtanen
70ffbaed74 bluez5: fix node initialization to init all nodes
Now that we can have more than 4 nodes, so should init them all.
2024-01-09 08:07:33 +00:00
Pauli Virtanen
f341dfed54 bluez5: lc3: prefer 7.5 ms frame duration
According to Intel people this is better for their hardware.

Link: https://github.com/bluez/bluez/issues/713
2024-01-09 08:07:33 +00:00
Jonas Holmberg
3b01205585 spa: Fix sign conversion in SPA_IS_ALIGNED
Fix the following compiler warning:
| In file included from /usr/include/spa-0.2/spa/utils/dict.h:14,
|                  from ../src/util_pipewire_objects.c:15:
| /usr/include/spa-0.2/spa/utils/defs.h: In function 'spa_ptr_inside_and_aligned':
| /usr/include/spa-0.2/spa/utils/defs.h:275:56: error: conversion to 'long unsigned int' from 'long int' may change the sign of the result [-Werror=sign-conversion]
|   275 | #define SPA_PTR_ALIGNMENT(p,align)      ((intptr_t)(p) & ((align)-1))
|       |                                                        ^
| /usr/include/spa-0.2/spa/utils/defs.h:276:42: note: in expansion of macro 'SPA_PTR_ALIGNMENT'
|   276 | #define SPA_IS_ALIGNED(p,align)         (SPA_PTR_ALIGNMENT(p,align) == 0)
|       |                                          ^~~~~~~~~~~~~~~~~
| /usr/include/spa-0.2/spa/utils/defs.h:308:13: note: in expansion of macro 'SPA_IS_ALIGNED'
|   308 |         if (SPA_IS_ALIGNED(p2, align)) {
|       |             ^~~~~~~~~~~~~~
2024-01-08 12:11:40 +01:00
Barnabás Pőcze
e2d3f9140b pw-reserve: fix potential DBusMessage memory leak
Our reference to the message must always be dropped,
even if `dbus_connection_send()` fails.
2024-01-08 10:55:02 +00:00
Barnabás Pőcze
72d5417857 pw-reserve: use arg0namespace for dbus match rule
Only names in the `org.freedesktop.ReserveDevice1` namespace
are interesting for the purposes of device reservation, so
use `arg0namespace` in the dbus match rule to filter out others.
2024-01-08 10:55:02 +00:00
Pauli Virtanen
a154169942 bluez5: support multiple BAP transports per device
In multi-ASE configurations there can be multiple transports per device,
each corresponding to different channels.

Emit sink/source nodes for each BAP transport present.

Combine them into a single sink/source in the same way as we do for
device sets.
2024-01-08 10:09:13 +00:00
Pauli Virtanen
d487dc0fc6 bluez5: bap: support ChannelAllocation parameter from BlueZ
For multi-ASE configurations, BlueZ does the channel allocation itself,
and passes us the result in the ChannelAllocation parameter.

If it is present, don't do the allocation ourselves but use that value
instead.
2024-01-08 10:09:13 +00:00
Pauli Virtanen
caebeaa9b3 bluez5: lc3: workaround bad Supported_Max_Codec_Frames_Per_SDU
If Supported_Max_Codec_Frames_Per_SDU is less than what is required by
Supported_Audio_Channel_Counts, override its value assuming the device
actually supports at least that. Needed for Creative Zen Hybrid Pro.

Fix default value for channel count bitmask.
2024-01-08 10:09:13 +00:00
Pauli Virtanen
b533b06b51 bluez5: backend-native: handle multiple commands in RFCOMM input
Do relaxed parsing of RFCOMM commands for AG & HF roles, allowing
multiple commands in same buffer.

Use same parser code for all HFP/HSP AG/HF. Parse input in relaxed way,
as some devices emit spurious \n
2024-01-06 15:42:20 +02: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
b4be094be8 doc: clarify rlimits conf file
Fixes #3760
2024-01-05 10:22:28 +01:00
Wim Taymans
a05a8eb8c6 spa: remove some references to unimplemented items
Fixes #3763
2024-01-05 10:07:58 +01:00
Barnabás Pőcze
e6c2e8465e meson_options: pass proper boolean values to boolean options
Passing strings has been deprecated:
https://mesonbuild.com/Release-notes-for-1-1-0.html#coercing-values-in-the-option-function-is-deprecated
2024-01-05 03:43:46 +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
5152c98789 log: store log level in topics
When there is no specific level for a topic we store the global log level
in the topic level. Make sure this invariant is preserved when the
the global log level is updated.

We can then simply update the log level after we processed the log level
string to update all topics.

This should also make it possible to just use the level from the topic
in all cases and remove a check.
2024-01-04 17:30:21 +01:00
Wim Taymans
e088dd2d2f journal: copy log level to chained logger
Make sure the log level on the chained logger is the same as ours.

Makes PIPEWIRE_DEBUG=3 make run print debug again.

This used to work because the log level was parsed and set before the
loggers were created and chained, and so they all got the same level.

Now that the level can be changed with metadata at runtime, we can't
really update all past loggers so let the journal logger copy the
level itself.
2024-01-04 13:57:26 +01:00
Demi Marie Obenour
76de766cd8 Draft: Allow calling trigger_done from the RT thread
This allows streams to know when the graph is finished and they can
safely drive it again.

Fixes: #3759
2024-01-04 10:21:16 +00:00
Pauli Virtanen
961d0cfdc1 log: make pw_log_topic_register/unregister threadsafe
Make the topic registration/unregistration threadsafe, as they can be
called from constructors of static objects which don't necessarily run
in the main loop thread.
2024-01-04 10:02:55 +00:00
Pauli Virtanen
fb2d05aa61 log: make pw_log_set_level_string public API 2024-01-04 10:02:55 +00:00
Pauli Virtanen
53ba3d0e4c spa: support: remove log pattern support
The log patterns are now handled by plugin host.
2024-01-04 10:02:55 +00:00
Pauli Virtanen
dd8d5e1bed log: make PW_LOG_TOPIC / PW_LOG_TOPIC_STATIC magical
Have PW_LOG_TOPIC / PW_LOG_TOPIC_STATIC emit GCC constructor/destructor
functions that register/unregister the log topic as needed.
2024-01-04 10:02:55 +00:00