Commit graph

13351 commits

Author SHA1 Message Date
Wim Taymans
3cf9ccf4a7 filter-graph: handle NULL in and out
We need to pass exactly n_inputs and n_outputs pointers to the process
function but make it possible to set some to NULL so that the data is
ignored.
2025-01-07 10:42:04 +01:00
Wim Taymans
49f48a5fda filter-graph: separate data and size for filter graph
Remove the chunk and add separate arrays with data and n_samples. This aligns
better with other methods and makes it possible to more easily reuse
arrays of pointers as input and output.
2025-01-07 10:38:32 +01:00
Wim Taymans
d6030adada filter-graph: optimize mix function a little
Make special cases for no and 1 gain value when mixing.
2025-01-07 09:40:45 +01:00
Wim Taymans
efa615945e filter-graph: rename some properties 2025-01-07 09:35:05 +01:00
Wim Taymans
9f9e962dd6 filter-graph: pass spa_pod in get_props 2025-01-07 09:31:48 +01:00
Wim Taymans
094a45a6f7 filter-graph: make it possible to set n_inputs/n_outputs in graph
So that the graph can be a self contained object.
2025-01-07 09:26:53 +01:00
Wim Taymans
e7d61a6fdf filter-graph: cleanup up port data
An input port has at most 1 link so we can avoid the loop and the
default port data. We can then also improve the logging and log
something when we set silence.
2025-01-07 09:24:56 +01:00
Wim Taymans
c5ae456b9e filter-graph: pass dict to activate functions
This makes it possible to expand it more later.
2025-01-07 09:23:23 +01:00
Barnabás Pőcze
591c40eed4 pipewire-jack: fix property list underallocation
`(n_items) + 1 * sizeof(*items)` is not the correct size to allocate
for `n_items + 1` count of objects each with size `sizeof(*items)`,
the `+ 1` should be inside the parentheses.

Fixes #4481
Fixes: 4baa94fce2 ("thread: make it possible to set a custom create function")
2025-01-05 21:03:50 +00:00
Barnabás Pőcze
0d497a5f43 spa: debug: pod: print unsigned numbers as unsigned
Both `spa_rectangle` and `spa_fraction` store unsigned numbers,
so print them as unsigned, the same way it is already done in
`spa_debug_strbuf_format_value()`.
2025-01-05 21:33:03 +01:00
Elliot Chen
419bc600a8 pipewiresink: split buffer and send them in turn if needed
For some streams, the buffer size is changed and may exceed
the acquired buffer size which is acquired from the pool of
pipewiresink. Need split buffer and send them in turn for
this case.
2025-01-03 15:58:37 +09:00
Arun Raghavan
974117f41a module-rtp: Fix previous typo fix
We want to track the difference between the PTP timestamp (now) and the
last RTP send, not the synthesized next RTP timestamp (which will always
be smoothly incrementing).
2024-12-31 15:24:46 -05:00
Arun Raghavan
c143e89118 module-rtp: Fix typo in check for lagging sender 2024-12-31 11:58:03 -05:00
Arun Raghavan
088d8011f2 tools: Document a couple of missing short form args for pw-loobpack 2024-12-31 11:22:49 -05:00
Elliot Chen
152a6683ef pipewiresink: active stream after finishing preoll when changing state from paused to playing 2024-12-30 11:48:34 +09:00
Pauli Virtanen
90f8b0e40b spa: acp: remove some strictly not necessary SplitPCM properties
Remove some api.alsa.split.* properties that the monitor script can
figure out itself.
2024-12-23 11:46:02 +02:00
Pauli Virtanen
dcccfcab7f spa: acp: get and emit UCM information for SplitPCM devices
When api.alsa.split-enable=true for ACP device, instruct UCM to not
use alsa-lib plugins for SplitPCM devices.

Grab the information from UCM for the intended channel remapping, and
add the splitting information to the nodes emitted.

Session manager can then look at that, and load nodes to do the channel
splitting.
2024-12-21 16:03:19 +02:00
Pauli Virtanen
7c7a54dd87 doc: add options to spa-acp-tool.1 2024-12-21 16:03:19 +02:00
Pauli Virtanen
7d7019d939 spa-acp-tool: parse properties with spa_json
Fixes crash in parsing properties due to access after end of string.
2024-12-21 16:03:19 +02:00
Niklas Carlsson
51e7ed3421 filter-chain: add sqrt plugin
To take the square root of the signal.
2024-12-20 17:58:08 +00:00
Niklas Carlsson
d7718dbcb7 filter-chain: add abs plugin
To calculate the absolute value of the signal.
2024-12-20 17:58:08 +00:00
Niklas Carlsson
7785f61677 audioconvert: align low-/highpass calculations
The current biquad calculations are based on RBJ's cookbook [1],
except for low-/highpass. Since the filter configuration is also
based on using the definition of Q, it makes sense to also align
the remaining calculations to use the same filter cookbook instead
of using resonance which doesn't result in the same coefficients
as when using Q.

[1] = https://www.w3.org/TR/audio-eq-cookbook/
2024-12-20 11:03:43 +01:00
Pauli Virtanen
e4ff13a75d module-loopback: support latencyOffsetNsec Prop
Add support for latencyOffsetNsec Prop, which just controls the nsec
part of the ProcessLatency.

This is needed to support latency offset in Pulseaudio apps when using
loopbacks as front-end nodes to underlying sinks.
2024-12-15 20:10:01 +00:00
Barnabás Pőcze
c556cced91 pipewire: module-raop-sink: remove unused function 2024-12-14 23:28:43 +01:00
Barnabás Pőcze
bf43515589 pipewire: thread: fix strerror() argument 2024-12-14 23:28:43 +01:00
Barnabás Pőcze
08c7c7999b pipewire: rtsp-client: use offsetof()
Use `offsetof()` instead of `sizeof()` to correctly determine the offset
of the flexible array member.
2024-12-14 23:28:43 +01:00
Barnabás Pőcze
11e0492f79 spa: vulkan: simplify memcpy() call 2024-12-14 23:28:43 +01:00
Barnabás Pőcze
bedcbf3631 spa: filter-graph: builtin: pointer instead of copying 2024-12-14 23:28:43 +01:00
Barnabás Pőcze
bf5d5f0201 spa: define feature macro without value
This is how it is done everywhere else.
2024-12-14 23:28:43 +01:00
Barnabás Pőcze
05ec64623a pw-cli: remove unused INDENT macro 2024-12-14 23:27:45 +01:00
Barnabás Pőcze
b1443185ea gst: sink: remove unnecessary variable
`res` can be removed without changing the behaviour, so do that.
2024-12-14 23:27:45 +01:00
Barnabás Pőcze
1f06d00838 pw-container: fix indentation 2024-12-14 23:27:45 +01:00
Barnabás Pőcze
705c2a652b pipewire: module-vban: fix vban serial header
The expression `VBAN_PROTOCOL_SERIAL | vban_BPSList[14]` is assigned
to an 8 bit field of the header, but, `vban_BPSList[14]` being
115200, it does not fit. Instead, its index, 14, should be
placed in the header.

In addition to fixing the issue, add `-Werror=constant-conversion`,
and clang diagnostic that catches such issues.

Fixes: 1a5514e5cf ("module-vban: create streams per stream_name")
2024-12-14 23:09:45 +01:00
Pauli Virtanen
a4e2d9cbb0 bluez5: lc3: bump media_codec version 2024-12-14 10:57:23 +00:00
Pauli Virtanen
bf12fe6d8b bluez5: lc3: simplify parsing 2024-12-14 10:57:23 +00:00
Pauli Virtanen
8f1983d14c bluez5: lc3: fix log name conflict 2024-12-14 10:57:23 +00:00
Iulia Tanasescu
3309fa0674 doc: Document BAP LC3 codec audio capabilities
This documents the configurable values for the BAP LC3 codec capabilities.
2024-12-14 10:57:23 +00:00
Iulia Tanasescu
9a5b2d42f9 bluez5: Configure LC3 codec capabilities
Currently, the PipeWire daemon registers BlueZ LE Media Endpoints
with audio capabilities covering all settings defined in the BAP spec.
However, some scenarios might require the capabilities to be restricted
to specific configurations.

This adds a method to read LC3 codec specific capabilities from the
Wireplumber config file, and provide those settings when registering
Media Endpoint objects with BlueZ. If the values are not present in
the config file, all settings will be used by default.

Below is an example of how to set the LC3 capabilities in the config
file, to support the 16_2 setting from the BAP spec:

bluez5.bap-server-capabilities.rates = [16000]
bluez5.bap-server-capabilities.durations = [10]
bluez5.bap-server-capabilities.channels = [1, 2]
bluez5.bap-server-capabilities.framelen_min = 40
bluez5.bap-server-capabilities.framelen_max = 40
bluez5.bap-server-capabilities.max_frames = 2
2024-12-14 10:57:23 +00:00
Barnabás Pőcze
b5490954d0 spa: filter-graph: ladspa: add dl_lib dependency
The ladspa plugin uses `dlopen()`, etc. directly,
so add the `dl_lib` dependency. This is not necessary
in a new enough environment since newer glibc versions
have merged most things into libc.
2024-12-14 10:55:28 +00:00
Iulia Tanasescu
d6567ea6a2 doc: Add sync_factor config option
This adds the new "sync_factor" entry in the JSON for Broadcast Source
endpoint config parameters.
2024-12-14 10:54:38 +00:00
Iulia Tanasescu
cb000ad3dc bluez5: Configure sync_factor
For a BAP Broadcast Source endpoint, the QoS sync_factor enables the user
to adjust the Periodic Advertising interval based on the ISO interval
configured for the stream:

PA_Interval = sync_factor * ISO_Interval

Currently, this value is hardcoded to 2. This commit makes the sync_factor
configurable in the Wireplumber config file, along with the other config
parameters for BIGs.
2024-12-14 10:54:38 +00:00
Arun Raghavan
85fa0aae40 gst: src: Set possible_caps before stream connect
The value is used when a the format changes in handle_format_change(),
and while it seems this was typically expected to happen async and thus
protected by the thread lock, there are cases (such as with
auto-port-config) where a param might be set within the
pw_stream_connect() call itself (in the case of auto-port-config, by the
impl_init() of the audioadapter).
2024-12-13 13:44:09 +00:00
Barnabás Pőcze
ff75f550ad ci: add missing libebur128 dependency
The `build_all` job enables most features, including the ebur128
filter-graph plugin. However, the dependency is currently not
installed, which leads to meson failing to set up the build.

Fixes: df271d13f3 ("filter-chain: add ebur128 filter")
2024-12-10 22:18:46 +00:00
Barnabás Pőcze
69dcc7db7b pipewire: context: pw_context_find_format(): fix stack use-after-free
Since fc49c1697a ("context: improve negotiation") it is possible
that the out parameter `format` will be set to `filter`. However,
`filter` is a SPA POD from the local SPA POD builder `fb`, which
references the local buffer `fbuf`.

In those cases, if the callers then make use of the returned SPA POD,
a stack use-after-free happens, such as the one displayed below.

The issue could be reliably triggered by executing the `video-play`
example program, and then trying to use the same camera in firefox.
As seen below, the input node, firefox's, provides no format preference,
causing the output format to be used. Previously, this had led
to the use-after-free described above.

pw.link    | [impl-link.c: 130 link_update_state()] (46.0.1 -> 114.0.0) init -> negotiating (paused-configure)
pw.context | [  context.c: 935 pw_context_find_format()] 0x51e000000080: finding best format 3 1
pw.context | [  context.c: 943 pw_context_find_format()] 0x51e000000080: states 3 1
pw.context | [  context.c: 958 pw_context_find_format()] 0x51e000000080: Got output format:
pw.context | [  context.c: 959 pw_context_find_format()]  video/raw
pw.context | [  context.c: 959 pw_context_find_format()]            format : (Id) YUY2
pw.context | [  context.c: 959 pw_context_find_format()]              size : (Rectangle) 640x480
pw.context | [  context.c: 959 pw_context_find_format()]         framerate : (Fraction) 30/1
pw.context | [  context.c: 966 pw_context_find_format()] 0x51e000000080: no input format filter, using output format: Success
=================================================================
==418404==ERROR: AddressSanitizer: stack-use-after-return on address 0x73993ee46200 at pc 0x739941d31020 bp 0x7fff526b4670 sp 0x7fff526b4660
READ of size 4 at 0x73993ee46200 thread T0
    #0 0x739941d3101f in spa_pod_builder_raw ../spa/include/spa/pod/builder.h:150
    #1 0x739941d3b35d in do_negotiate ../src/pipewire/impl-link.c:294
    #2 0x739941d46214 in check_states ../src/pipewire/impl-link.c:727
    #3 0x739941f14405 in process_work_queue ../src/pipewire/work-queue.c:64
    #4 0x73993d0dbe99 in source_event_func ../spa/plugins/support/loop.c:894
    #5 0x73993d0d6881 in loop_iterate ../spa/plugins/support/loop.c:727
    #6 0x739941d76b05 in spa_loop_control_enter ../spa/include/spa/support/loop.h:264
    #7 0x739941d76d93 in spa_loop_control_leave ../spa/include/spa/support/loop.h:268
    #8 0x739941d78946 in pw_main_loop_quit ../src/pipewire/main-loop.c:109
    #9 0x5a64b3cb1cec in main ../src/daemon/pipewire.c:130
    #10 0x739940c34e07  (/usr/lib/libc.so.6+0x25e07) (BuildId: 98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
    #11 0x739940c34ecb in __libc_start_main (/usr/lib/libc.so.6+0x25ecb) (BuildId: 98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
    #12 0x5a64b3caf3b4 in _start (/pipewire/build/src/daemon/pipewire+0x173b4) (BuildId: f9e8403a377e28bf8bd9cf0a5b89d33f08499917)

Address 0x73993ee46200 is located in stack of thread T0 at offset 512 in frame
    #0 0x739941c6ed5e in pw_context_find_format ../src/pipewire/context.c:907

  This frame has 15 object(s):
    [...]
    [432, 480) 'fb' (line 911)
    [512, 4608) 'fbuf' (line 912) <== Memory access at offset 512 is inside this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-return ../spa/include/spa/pod/builder.h:150 in spa_pod_builder_raw
    [...]

Fixes: fc49c1697a ("context: improve negotiation")
2024-12-10 22:48:13 +01:00
Wim Taymans
94e823ddad filter-graph: add dcblock and ramp plugins 2024-12-09 15:00:35 +01:00
Wim Taymans
df271d13f3 filter-chain: add ebur128 filter
The EBU R128 filter measures the signal and generates LUFS control
notifications for further processing.

It also adds a plugin that can convert LUFS to a gain (based on a target
LUFS).

Also add an example filter-chain to enable the EBU R128 measurement and
how to use the results to adjust the volume dynamically.

See #2286 #222 #2210
2024-12-09 11:31:33 +01:00
Wim Taymans
f0f9fbb009 filter-graph: activate nodes after linking
Don't activate the nodes while linking but make a last stage where all
the nodes are activated. This makes it possible to better set up the
nodes based on the port data.
2024-12-09 11:30:05 +01:00
Wim Taymans
1bead99daf filter-graph: handle nodes with only control
It's possible to make a node with only control and notify so don't error
out on those nodes.
2024-12-09 11:30:05 +01:00
Wim Taymans
2b24b27f7f meson: move some filter-graph deps to spa
The filter-graph deps can now be in spa meson
2024-12-09 11:30:04 +01:00
Alper Nebi Yasak
507ec0b39a alsa-ucm: Set up hardware volumes again on duplicate port additions
While initializing ALSA cards with UCM, we call pa_alsa_ucm_add_port()
for each UCM device for each UCM verb. This checks if a port has been
already added by name and skips port initialization if it is already
done. Different UCM verbs can have devices with the same name, which
means their port names end up being the same. So, this port creation
step currently is only done for one UCM verb for both UCM devices.

Volume control setup is also part of this process. The UCM devices only
know about the volume mixer information from the UCM verb that they are
defined in, so the volume control setup is done for one UCM verb at a
time. Skipping this setup when a same-named port exists means only the
profiles belonging to the first initialized UCM verb have working
hardware volume control.

Move the volume control setup out of the port initialization block so
that we try to do it every time, therefore for every UCM verb. However,
check that we don't run it twice for the same UCM verb for a port.

In theory, the PlaybackVolume etc. value can be different per-verb
for the same device, so we can't simplify this code to a single volume
setup per port.

Link: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/840
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2024-12-07 18:32:48 +00:00