Commit graph

5380 commits

Author SHA1 Message Date
Wim Taymans
78e5c2f3e6 utils: handle random_r fallback
musl does not seem to have it so fall back to rand() and srand().
2023-02-22 16:48:04 +01:00
Wim Taymans
4e298f2fe7 pipewire: add pw_random()
Make pw_getrandom() more usable by handling the EINTR case and returning
< 0 when there was an error or not enough random data was available.

Make a new pw_random() function that uses pw_getrandom() but falls back
to a pseudo random number generator otherwise. This pseudo random number
generator is seeded with either data from the urandom source or from the
current time when pipewire is initialized.

In most cases where crytographic security is not required pw_random()
should be easier to use.
2023-02-22 15:27:27 +01:00
Robert Mader
0b69f37a7c gstpipewiresrc: Do not alter meta plane count
Shared memory buffers may contain multiple planes.
Thus we need to keep the meta plane number as derived from the format.

Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3045
2023-02-21 08:17:26 +00:00
Mike Playle
23b86761a5 Add autoconnect parameter to pipewiresrc element 2023-02-21 08:16:44 +00:00
Thomas Weißschuh
2d5e0ef47b context: free properties on allocation failure 2023-02-20 12:12:00 +00:00
Wim Taymans
1c9ffef813 module-rtp: reset ringbuffer on resync 2023-02-17 15:38:11 +01:00
Wim Taymans
8eaf46a678 module-rtp: add rate matching for the source
correlate the timestamps against the graph clock and calculate a rate
correction. this smooths out the timestamps.
2023-02-17 11:23:51 +01:00
Wim Taymans
fbd068977c module-rtp: Add rtp-midi support
Add rtp-midi support with the media.type = midi option
2023-02-16 16:47:29 +01:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Robert Mader
353c1f709d gstpipewiresrc: make stream errors permanent
When pw_stream receives a proxy error it does not set its state to an
error state on its own, commenting:
```
we just emit the state change here to inform the application.
If this is supposed to be a permanent error, the app should
do a pw_stream_set_error()
```

Until now this was not done in the pipewiresrc, resulting in the
negotiation loop to not bail out after an error as a successive
`pw_stream_get_state()` did not return an error state.

Make the error permanent so negotiation errors make us take the
appropriate error paths.
2023-02-15 14:49:42 +01:00
Wim Taymans
965b220206 module-rtp: clear ringbuffer in resync
When we resync to the timestamp, clear the ringbuffer to avoid playing
old stale samples.
2023-02-15 11:08:08 +01:00
Wim Taymans
aa3b776f6f module-rtp: resync after paused state
After the paused state, resync to the new clock time.
2023-02-15 11:06:01 +01:00
Wim Taymans
dd0d3ac264 pw-cat: remove useless code
The data stride for encoded formats should be 1 and also placed in the
stride in the buffer (not 0). So there is really no difference with the
regular codepath.
2023-02-14 16:44:52 +01:00
Wim Taymans
b9ddd54a98 pw-cat: don't read more than the requested frames 2023-02-14 16:44:52 +01:00
Niklāvs Koļesņikovs
5e0bfa0beb
RLIMITs: add support for generating limits.d files
This commit implements generating /etc/security/limits.d/20-pw-defaults.conf and
/etc/security/limits.d/25-pw-rlimits.conf files. The numbering is arbitrary and
may very well warrant being in the reverse order, however `man 5 limits.conf`
does not appear to specify the parsing order or even say exactly how multiples
matches will resolve, so the value can be adjusted later, if required.

The actual limit values, the match rule and even whether each file is to be
installed can be changed via the build system before compilation. Likewise
the files can be modified or (re)moved during distro package building phase.

The 20-pw-defaults.conf should only be installed on legacy systems lacking both
a modern kernel and up to date systemd, because all it does is set the current
Linux default. Accordingly its not installed by default.

Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd@relay.firefox.com>
2023-02-14 17:37:59 +02:00
Niklāvs Koļesņikovs
d082ec0809
src/modules/meson.build: fix indentation and remove obsolete comment
Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd@relay.firefox.com>
2023-02-14 17:37:59 +02:00
Barnabás Pőcze
e09b97edc4 pipewire: impl-core: actually return created object
Actually return the pointer to the created object
from `impl-core.c:core_create_object()` instead of
returning a NULL pointer.

This has not caused issues because the return value
is not checked anywhere.
2023-02-13 19:55:45 +01:00
Wim Taymans
2865e40618 filter: support pw_filter_trigger_process()
Add pw_filter_trigger_process() as a way to implement a driver node.
Also add a function to check if a filter is a driver.
2023-02-13 17:58:42 +01:00
Wim Taymans
c6a977f793 filter: change_mask is 64 bits 2023-02-13 17:21:58 +01:00
Wim Taymans
2469a69f98 filter: clean up param indexes
Prefix param index with PORT_ and NODE_ depending on what they are used
for.
2023-02-13 17:19:25 +01:00
Wim Taymans
68f6d4d6de log: improve format debug log
Use the format debug log instead of generic pod log
2023-02-13 17:15:04 +01:00
Wim Taymans
344be779b1 filter-chain: support single copy plugin
When input and output are linked with a copy function, don't disable the
node but add it to the valid graph inputs.
2023-02-07 14:14:55 +01:00
Wim Taymans
72242dc91f filter-chain: add invert plugin
To invert the polarity of a signal.

See #3008
2023-02-07 13:46:06 +01:00
Wim Taymans
fda829a1fa conf: fixup config comments
Use () to mark optional fields to avoid confusion with [] for arrays.
Add contition fields where available.
2023-02-07 10:35:43 +01:00
Wim Taymans
5552ff7fdd conf: add conditions to modules, exec and objects
Make it possible to conditionally load modules, objects and exec by
adding match rules for context properties.

This makes it possible to only load a module when  property is set,
which makes it possible to unset a property in a local config to disable
module loading. One example is the x11 modules, which can then be
disabled on a per user bases based on config overrides.
2023-02-07 09:50:46 +01:00
Huang-Huang Bao
4b60569c4a gst: correct buffer & meta offset calculation
The offset in GstVideoMeta point to location of merge-mapped buffer memories (see "gst_buffer_find_memory()") instead of raw memory location for each plane, make adjustment to comply this rule.

Also some cleanups.

Fixes 023577e391
2023-02-06 06:34:14 +00:00
Thomas Weißschuh
4f9f32084c module-combine-stream: add missing proxy event version 2023-02-06 06:07:13 +00:00
Barnabás Pőcze
06df127ad9 pipewire: mem: refuse invalid file mapping
Refuse to map a file if the specified `offset + size` would
be bigger than the size of the file. This prevents receiving
SIGBUS when the consumer tries to make an incorrect mapping.

See #2617 #2914 #3007
2023-02-03 22:44:32 +01:00
Dmitry Sharshakov
d42656c0d9 filter-chain: add example configs for spatializer 2023-02-03 13:49:18 +03:00
Wim Taymans
caf58ecffb keys: don't use macro to define keys
Make PW_ENABLE_DEPRECATED use the symbol directly without using the
PW_DEPRECATED macro to work around rust compiler bug.

See #2952
2023-02-03 10:26:47 +01:00
Wim Taymans
5ee7be9534 conf: revert to 32 min-quantum
ae077a4967 accidentally changed the
default min-quantum to 16, revert it back to 32 because 16 is really
low.

See #2791
2023-02-03 09:12:51 +01:00
Huang-Huang Bao
023577e391 gst: add buffer video meta support
Fixes video buffer strides handling.
This enables passing of image datas with right line padding.
2023-02-03 07:23:35 +00:00
Thomas Weißschuh
38f88d3d25 thread-loop: constify timespec argument
This makes it easier for the user to see that pw_thread_loop_get_time()
does not modify the timespec so that it can be reused over multiple
calls.
2023-02-03 00:28:56 +00:00
Frédéric Simonis
04e769ff35 Add source example for the loopback module 2023-02-02 19:10:42 +00:00
Wim Taymans
7e2dab876a module-rtp-sink: handle buffer offset and size correctly 2023-02-02 16:08:40 +01:00
Wim Taymans
aed394cf89 module-rtp: use timestamps as ringbuffer index
Use the timestamps directly as the ringbuffer index. We can save some
conversions to bytes and there is a direct mapping to RTP timestamp,
clock position and ringbuffer index.

Simplify the source a little. Remove the buffering state, we always
start with read and write pointers separted by the target buffering.
2023-02-02 15:54:53 +01:00
Wim Taymans
16e995be26 module-rtp: remove some useless debug 2023-02-02 12:12:01 +01:00
Wim Taymans
b50fa83325 module-rtp-sink: improve sync
Always write to index of the clock, not just for the first packet.
This ensure the timestamp on the packet always matches the time it was
processed in the graph.
2023-02-01 20:06:19 +01:00
Wim Taymans
1a5de467db module-rtp: support direct clock timestamps
Always use the timestamp of the graph clock for RTP packets. Add an
option to apply a random or fixed offset.
Add a ts-refclk option on the sender to specify a reference clock to
use for timestamping. This will activate the direct timestamp mode and
signal this in the SDP.

Parse ts-refclk and ts-offset from the SDP. Make it possible to match
them in rules. Add option to activate the direct-timestamp, where the
rate matching is disabled and the timestamps are used directly for
writing and reading from the ringbuffer using the graph clock.

This makes it possible to set a PTP clock on sink and source and avoid
rate matching by using a shared clock.
2023-02-01 18:31:33 +01:00
Wim Taymans
e3b358ac8b support: add support for other clocks
Add support for using other clocks.
clock.id can be used to set one of the system clocks.
clock.device can be used to open a clock device such as a PTP clock
device.
Use a dll to track the progress of non-monotonic clocks.
2023-02-01 15:54:54 +01:00
Dmitry Sharshakov
e4f4ef9e1c filter-chain: fix spatializer rate changes 2023-01-30 22:44:55 +03:00
Barnabás Pőcze
b931f53783 filter-chain: review comments 2023-01-30 22:02:48 +03:00
Wim Taymans
05048a2d9d filtet-chain: fix compilation without sofa 2023-01-30 21:43:07 +03:00
Dmitry Sharshakov
a5d15ff16a filter-chain: fix warning 2023-01-30 21:12:06 +03:00
Wim Taymans
6539535176 filter-chain: remove mutex
We only ever load the IR from the main thread so we don't need a lock.
2023-01-30 21:07:06 +03:00
Wim Taymans
42a40e07d7 filter-chain: make sofa changes lockfree
Use the control changes to load a new IR, then signal to data thread to
use the new IR. In the data thread, signal the main thread to free the old
IR after we swapped it out.

THis moves all allocations from the data thread into the main thread.
2023-01-30 21:07:06 +03:00
Wim Taymans
63002bfcee filter-chain: add method to notify control changes 2023-01-30 21:07:06 +03:00
Dmitry Sharshakov
cf09077705 spatializer: free old convolvers immediately
We shouldn't need them anymore
2023-01-30 21:07:06 +03:00
Dmitry Sharshakov
9a3bf1a6de spatializer: interpolate IRs
Fixes clicking
2023-01-30 21:07:06 +03:00
Dmitry Sharshakov
9399fc318e spatializer: move to sofa_plugin 2023-01-30 21:07:06 +03:00