Commit graph

9034 commits

Author SHA1 Message Date
Wim Taymans
ecc0eecf0f mixer-dsp: mix a quantum of data at a time
When there is no input, mix up to a quantum of data. Otherwise we might
send too much data to the next node and cause a delay if it does not
handle this.
2022-06-22 15:50:56 +02:00
Wim Taymans
a427e602bd audioconvert: in merge mode, flush input
In merge mode we handle 1 quantum and then flush the input and
output. Fixes a case were samples were cut at the start.
2022-06-22 15:48:09 +02:00
Wim Taymans
5363bdcfcb gst: protect negotiated field with lock
Move the lock around the negotiated field.

See !1287
2022-06-21 13:19:32 +02:00
Wim Taymans
a4998e0b87 filter-chain: allow unconnected filter ports
When there are unconnected filter ports, allow this but give a warning.
Improve error messages.
2022-06-21 13:07:11 +02:00
Wim Taymans
eb26c2a95e filter-chain: ladspa properties are different from flags
Don't use the ladspa properties as the plugin flags, they don't
match.
2022-06-21 12:53:11 +02:00
Wim Taymans
05064bd558 filter-chain: error out on 0 handles
When we end up in a case where we are running 0 handles, such as when we
have a stereo filter but we want mono output, emit an error until we can
reasonably handle this case.
2022-06-20 19:35:19 +02:00
Barnabás Pőcze
97a275e71e pulse-server: update quirks before querying the name
`client_update_quirks()` may modify `client::props` depending
on the "pulse.rules" section defined in the configuration file,
which means that it can change the value corresponding to the
"application.name" key. Therefore, `client::name` needs to
be queried after that.
2022-06-20 17:30:05 +00:00
Barnabás Pőcze
0f45d784d8 pulse-server: update client::name on UPDATE_CLIENT_PROPLIST command
`client::name` points to a string that is owned by `client::props`,
so when the property list is updated, it needs to be refreshed as well.
Otherwise, various use-after-frees can be triggered, for example:

==1471586==ERROR: AddressSanitizer: heap-use-after-free on address 0x60200007e7d0 at pc 0x7f14390755d0 bp 0x7ffe23edee30 sp 0x7ffe23ede5a8
READ of size 3 at 0x60200007e7d0 thread T0
    #0 0x7f14390755cf in printf_common /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors_format.inc:553
    #1 0x7f1439077215 in __interceptor_vsnprintf /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:1665
    #2 0x7f1434ead47d in spa_vscnprintf ../spa/include/spa/utils/string.h:239
    #3 0x7f1434eae2ae in impl_log_logtv ../spa/plugins/support/logger.c:138
    #4 0x7f14385cacc7 in pw_log_logt ../src/pipewire/log.c:135
    #5 0x7f1433aef8e9 in do_set_profile ../src/modules/module-protocol-pulse/pulse-server.c:4656
    #6 0x7f1433b0af4d in handle_packet ../src/modules/module-protocol-pulse/server.c:109
    #7 0x7f1433b0e747 in do_read ../src/modules/module-protocol-pulse/server.c:276
    #8 0x7f1433b0eb04 in on_client_data ../src/modules/module-protocol-pulse/server.c:306
    #9 0x7f1434ec56a0 in source_io_func ../spa/plugins/support/loop.c:442
    #10 0x7f1434ec4a21 in loop_iterate ../spa/plugins/support/loop.c:430
    #11 0x7f14385dc23d in pw_main_loop_run ../src/pipewire/main-loop.c:148
    #12 0x55b065d73722 in main ../src/daemon/pipewire.c:131
    #13 0x7f143742928f  (/usr/lib/libc.so.6+0x2928f)
    #14 0x7f1437429349 in __libc_start_main (/usr/lib/libc.so.6+0x29349)
    #15 0x55b065d722a4 in _start (./src/daemon/pipewire-pulse+0x42a4)

0x60200007e7d0 is located 0 bytes inside of 16-byte region [0x60200007e7d0,0x60200007e7e0)
freed by thread T0 here:
    #0 0x7f14390be672 in __interceptor_free /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:52
    #1 0x7f14386a775a in do_replace ../src/pipewire/properties.c:414
    #2 0x7f14386a785e in pw_properties_set ../src/pipewire/properties.c:441
    #3 0x7f14386a658b in pw_properties_update ../src/pipewire/properties.c:309
    #4 0x7f1433adb055 in do_update_proplist ../src/modules/module-protocol-pulse/pulse-server.c:3246
    #5 0x7f1433b0af4d in handle_packet ../src/modules/module-protocol-pulse/server.c:109
    #6 0x7f1433b0e747 in do_read ../src/modules/module-protocol-pulse/server.c:276
    #7 0x7f1433b0eb04 in on_client_data ../src/modules/module-protocol-pulse/server.c:306
    #8 0x7f1434ec56a0 in source_io_func ../spa/plugins/support/loop.c:442
    #9 0x7f1434ec4a21 in loop_iterate ../spa/plugins/support/loop.c:430
    #10 0x7f14385dc23d in pw_main_loop_run ../src/pipewire/main-loop.c:148
    #11 0x55b065d73722 in main ../src/daemon/pipewire.c:131
    #12 0x7f143742928f  (/usr/lib/libc.so.6+0x2928f)

previously allocated by thread T0 here:
    #0 0x7f1439072faa in __interceptor_strdup /usr/src/debug/gcc/libsanitizer/asan/asan_interceptors.cpp:439
    #1 0x7f14386a6fe2 in do_replace ../src/pipewire/properties.c:394
    #2 0x7f14386a785e in pw_properties_set ../src/pipewire/properties.c:441
    #3 0x7f1433a6c52d in read_props ../src/modules/module-protocol-pulse/message.c:147
    #4 0x7f1433a6f467 in message_get ../src/modules/module-protocol-pulse/message.c:359
    #5 0x7f1433ab3191 in do_set_client_name ../src/modules/module-protocol-pulse/pulse-server.c:1030
    #6 0x7f1433b0af4d in handle_packet ../src/modules/module-protocol-pulse/server.c:109
    #7 0x7f1433b0e747 in do_read ../src/modules/module-protocol-pulse/server.c:276
    #8 0x7f1433b0eb04 in on_client_data ../src/modules/module-protocol-pulse/server.c:306
    #9 0x7f1434ec56a0 in source_io_func ../spa/plugins/support/loop.c:442
    #10 0x7f1434ec4a21 in loop_iterate ../spa/plugins/support/loop.c:430
    #11 0x7f14385dc23d in pw_main_loop_run ../src/pipewire/main-loop.c:148
    #12 0x55b065d73722 in main ../src/daemon/pipewire.c:131
    #13 0x7f143742928f  (/usr/lib/libc.so.6+0x2928f)
2022-06-20 17:30:05 +00:00
Wim Taymans
0d49d1f293 conf: mix-lfe is by default false 2022-06-20 17:43:44 +02:00
Wim Taymans
a13f65f583 alsa-seq: disable the running status
Running status is not something we want in the PipeWire graph.
2022-06-20 16:18:42 +02:00
Wim Taymans
25d9039f2e alsa-seq: handle midi event decoder errors 2022-06-20 16:12:49 +02:00
Wim Taymans
40f50deae9 alsa: remove NoteOn 0-velocity fixup
Pass MIDI events as they are.

JACK requires NoteOn 0-velocity midi events to be patched to NoteOff
events for compatibility with LV2 plugins. Let's do this patchup in
the JACK layer then and add an option to disable it.

It's best to pass the midi messages unmodified and then patch them up
wherever they need patching up.
2022-06-20 15:51:33 +02:00
Wim Taymans
d13a206866 audioconvert: fix resampler in_offset
Only advance the in_offset with the number of samples that were consumed
by the resampler. In case when the resampler is filling up an old
buffer, this can be less than n_samples.

Fixes a2dp source and possibly others.
2022-06-20 12:33:52 +02:00
Wim Taymans
ff05ebada6 pulse-server: tweak record attributes
Add some 'before' debug info of the attributes.
First clamp the fragsize to the maxlength and then clamp to the
minfrag or else we could bypass the configured minfrag by setting a
lower maxlength.
Scale the maxlength to at least twice the fragsize so that we can
buffer enough data in the ringbuffer to serve fragsize bytes.

See #2447
2022-06-20 11:42:59 +02:00
Lucas Holt
6a15a02ec2 Add support for MidnightBSD
Fix build issue

Fix build issue
2022-06-19 18:22:47 +00:00
Yuri Chornoivan
4922aed6c6 Update Ukrainian translation 2022-06-19 09:24:53 +00:00
Wim Taymans
6b09a304dc adapter: name control ports as "control" 2022-06-17 15:40:56 +02:00
Wim Taymans
83588daf60 adapter: support control ports in PortConfig 2022-06-17 12:49:33 +02:00
Wim Taymans
16a7c27498 settings: remove 44.1KHz from allowed rates again
It seems to cause too many problems. It people want rate switching they
can add an override themselves.
2022-06-17 09:02:13 +02:00
Barnabás Pőcze
ae34b68e3a pulse-server: message: improve resizing logic
As Coverity points out, `ensure_size()` is not fully correct.

Let us assume that the message already has some allocated storage,
and the `realloc()` call in the next `ensure_size()` invocation fails.
In that case `message::data` is freed, but the pointer is left behind.
If another `ensure_size()` call is made, then `realloc()` will be called
(since the previous call left `message::allocated` as zero), but the
first argument of the `realloc()` call will be a dangling pointer.

In order to avoid the above, first of all, clear `message::data` after
a failed `realloc()` call, and immediately return `-ENOMEM` if
`message::length` is greater than `message::allocated` since
that signals if the message has even run into an out-of-memory
situation.
2022-06-16 18:38:30 +00:00
Barnabás Pőcze
080a97c0bb pulse-server: message: store pointer to impl directly
Store a pointer to the owner `impl` object instead of
the (embedded) `stat` object. This way `message_free()`
can be simplified since the owner `impl` does not need
to be passed explicitly.
2022-06-16 18:38:30 +00:00
Barnabás Pőcze
b843b0ab29 pulse-server: message: remove unnecessary forward declaration
`struct client` is never referenced in "message.h",
so remove the forward declaration for it.
2022-06-16 18:38:30 +00:00
Barnabás Pőcze
492a328227 spa: audioconvert: free resampler
resample::free() needs to be called in `impl_clear()` otherwise the
resampler's private data is leaked when the audioconvert instance is destroyed.
2022-06-16 19:49:50 +02:00
Barnabás Pőcze
bc67745c07 pipewire: module-raop-sink: fix memory leak
As Coverity points out, previously, when the `else`
branch was taken, then `tokens` was not freed.
2022-06-16 18:57:38 +02:00
Barnabás Pőcze
84c01bb0bc pipewire: module-pipe-tunnel: accept file descriptor 0
As Coverity points out, `open()` returning 0 is not an error,
it should be handled just like any other valid file descriptor.
2022-06-16 17:55:59 +02:00
Barnabás Pőcze
96d0902dc8 spa: ffmpeg: set spa_handle_factory::version
Initialize the version with the `SPA_VERSION_HANDLE_FACTORY` macro.
This way `spa-inspect` can properly inspect the factory.
2022-06-16 17:29:42 +02:00
Barnabás Pőcze
de5a85d808 spa: ffmpeg: implement spa_handle::clear
Implement the spa_handle::clear method for both the encoder and decoder.
At the moment, they both do nothing.
2022-06-16 17:29:20 +02:00
Barnabás Pőcze
f2bd2ef6fb spa: ffmpeg: implement spa_handle_factory::get_size
This method is necessary for the creation of a handle,
so implement it for both the encoder and decoder.
2022-06-16 17:28:23 +02:00
Barnabás Pőcze
6cb8fb899d spa: ffmpeg: move some function declarations to a header
Move the declarations for `spa_ffmpeg_{dec,enc}_init` to the
"ffmpeg.h" header file. This way the implementation is checked
against the signature.
2022-06-16 17:27:36 +02:00
Barnabás Pőcze
1a21da9898 spa: tools: spa-inspect: clear and free handles
Call the handle's `clear()` method after it has been
inspected, and free the allocated storage for the handle.
2022-06-16 16:59:40 +02:00
Wim Taymans
3cb5fab176 audioconvert: rework the control loop
Use the offset to skip entries in the sequence array.
Use one loop to handle intermediate and trailing samples.
Fixes an issue where the last chunk of a sequence would be ignored.
2022-06-16 16:45:32 +02:00
Wim Taymans
e0af67b670 examples: fix spelling mistake 2022-06-16 16:40:47 +02:00
Wim Taymans
de2e819fec audioconvert2: rename to audioconvert 2022-06-16 09:19:05 +02:00
Wim Taymans
cf04bb573c audioconvert: remove old plugins 2022-06-16 09:16:49 +02:00
Wim Taymans
f74b59b39f examples: fix volume fade in and out with control 2022-06-16 09:09:27 +02:00
Wim Taymans
c160cd0176 audioconvert2: implement control port
Add a control port when requested in the PortConfig.
Fix the sequence loop.
Make a copy of the sample pointers before changing them.
2022-06-16 09:09:27 +02:00
Wim Taymans
5a60fd7041 audioconvert2: remove unused monitor field 2022-06-16 09:09:27 +02:00
Wim Taymans
194b8e2d97 audioconvert2: emit param change when volume changes 2022-06-16 09:09:27 +02:00
Wim Taymans
0ec41e60ef audioconvert2: fix for quantum changes
Use the offset as the buffer size.
Use the amount of requested - amount of used samples as queued samples.
2022-06-16 09:09:27 +02:00
Wim Taymans
708b57aa64 examples: add control support to adapter
Based on patches by Julian Bouzas  in !222
2022-06-16 09:09:27 +02:00
Wim Taymans
fa9baa6488 examples: fix up adapter-control
Negotiate format, then buffers.
Give quantum-limit as a property when making nodes.
Set clock and position io and fill in rate and duration.
2022-06-16 09:09:27 +02:00
Wim Taymans
db49021104 audioconvert2: add control port processing 2022-06-16 09:09:27 +02:00
Wim Taymans
d5c28149f1 audioconvert2: fix in/out queued samples 2022-06-16 09:09:27 +02:00
Wim Taymans
7fe15ee5db audioconvert2: add beginnings of control ports 2022-06-16 09:09:27 +02:00
Wim Taymans
d3baa16559 audioconvert2: reset node in Flush/Suspend 2022-06-16 09:09:27 +02:00
Wim Taymans
8e6a8a705b audioconvert2: clamp in and output samples
Make sure we don't read or write more samples than available in the
buffers.
2022-06-16 09:09:27 +02:00
Wim Taymans
9e93fe3c36 audioconvert2: remap volumes to right channels
We get the volumes with a channelmap of the input/output, remap this to
the channelmixer internal layout.
2022-06-16 09:09:27 +02:00
Wim Taymans
50c37cc801 audioconvert2: rearrange some code
Move some code around so that we don't have to prepare the output
buffers when there is no input to process.
2022-06-16 09:09:27 +02:00
Wim Taymans
d5e333eea7 audioconvert2: in merge mode, always process quant samples 2022-06-16 09:09:27 +02:00
Wim Taymans
c4d77d421a audioconver2: process monitor ports immediately 2022-06-16 09:09:27 +02:00