If there is no valid channel map, assume MONO channels. A valid channel
map should be assigned at the source of the data, not here.
The problem is that when a device uses AUX channels, this will be fixed
up here with a surround setup, which is not right.
It is not enough for `buffer` to be alive in its current
scope because when execution enters that branch, `format`
will be set to `fmt`, which points inside `buffer`. And
since `format` is used outside that scope, `buffer` must
live longer.
This was detected by ASAN when Audacity was starting up.
==25007==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffdbcfef560 at pc 0x7fe44ca95db3 bp 0x7ffdbcfeeda0 sp 0x7ffdbcfeed90
READ of size 4 at 0x7ffdbcfef560 thread T0
#0 0x7fe44ca95db2 in spa_pod_parser_pod ../spa/include/spa/pod/parser.h:67
#1 0x7fe44ca9a805 in spa_format_parse ../spa/include/spa/param/format-utils.h:44
#2 0x7fe44cad293a in port_set_format ../spa/plugins/audioconvert/audioconvert.c:1934
#3 0x7fe44cadad14 in impl_node_port_set_param ../spa/plugins/audioconvert/audioconvert.c:2038
#4 0x7fe44ca587e2 in configure_format ../spa/plugins/audioconvert/audioadapter.c:509
#5 0x7fe44ca60dff in negotiate_format ../spa/plugins/audioconvert/audioadapter.c:822
#6 0x7fe44ca62bbf in impl_node_send_command ../spa/plugins/audioconvert/audioadapter.c:846
#7 0x7fe45ea1c2f1 in node_update_state ../src/pipewire/impl-node.c:407
#8 0x7fe45ea5137e in pw_impl_node_set_state ../src/pipewire/impl-node.c:2251
#9 0x7fe45eb3355f in pw_work_queue_destroy ../src/pipewire/work-queue.c:142
#10 0x7fe45b2cd6f4 in source_event_func ../spa/plugins/support/loop.c:615
#11 0x7fe45b2c634f in loop_iterate ../spa/plugins/support/loop.c:452
#12 0x7fe45e9ebebc in spa_hook_list_clean ../spa/include/spa/utils/hook.h:395
#13 0x5561e03dc722 in main ../src/daemon/pipewire.c:131
#14 0x7fe45da3c28f (/usr/lib/libc.so.6+0x2328f)
#15 0x7fe45da3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
#16 0x5561e03db2a4 in _start ../sysdeps/x86_64/start.S:115
Address 0x7ffdbcfef560 is located in stack of thread T0 at offset 160 in frame
#0 0x7fe44ca56fa9 in configure_format ../spa/plugins/audioconvert/audioadapter.c:475
This frame has 4 object(s):
[32, 36) 'state' (line 493)
[48, 56) 'fmt' (line 494)
[80, 128) 'b' (line 492)
[160, 4256) 'buffer' (line 491) <== Memory access at offset 160 is inside this variable
This reverts commit 5bda4b6a57.
The reason is that when you use a null-audio-sink as a source, the
adapter will think it's a sink while wireplumber will try to use it as a
source.
There is no quick solution for this so revert this check for now.
First clear the started flag so that we ignore scheduling from the
follower. Then stop the follower and the converter.
This is the sequence we follow when deactivating a node, so do the
same here.
it is important that the node is not scheduled anymore when we clear
the format in suspend or else we might crash.
See #2877
When in passthrough mode and there is no converter, simply return
our own PortConfig parameter with our direction and passthrough mode.
Otherwise, use the PortConfig from the converter but filter out only the
PortConfig that matches our direction.
This fixes enumeration of PortConfig on the adapter.
Make a new variable to iterate the other ports so that we can use the
original port to emit notifications.
Fixes Latency and other params set on DSP ports.
When we are simply enumerating the params, just collect the info
but don't act on them, like clearing the format or recalculating
the latency.
This avoids some useless work when enumerating params.
Use the more complete configure_format function to clear the format
and buffers when the EnumFormat param changed.
When the follower updates EnumFormat, it probably wants to renegotiate
to a new format, so clear the current format so that we do that when
starting the next time.
EnumFormat should also not only return the current format in case we
are negotiated but it should return all possible formats.
See #2832
After the ports are reconfigured, we need to perform the setup again so
that buffers and processing can happen with the right settings.
This fixes an issue when autoswitching between A2DP and HFP with
bluetooth headsets when there is also a stereo capture device available.
The input stream of the browser is quickly reconfigured between stereo
and mono with only a Pause command in between, clearing the setup state
is enough to redo the setup when going back to Playing.
Fixes#2764
This reverts commit 6c963ed933.
This code was meant to set a filter on the format for the follower
but is not implemented yet.
Problem is that the unit tests and wireplumber call this code and would
need to be patched.
Just like the optional build, make all field parsing optional. This
will leave the fields with their default values if they are not parsed
from the param.
We can then remove our custom functions and use the generic ones in
various places.
Set up the adapter and then set the started field to true before we
Start the follower and converter. It is possible that the follower will
start processing immediately so the started state needs to be set
correctly.
Similarly, first perform the Pause and Suspend calls on the follower
and converter before clearing our buffers and format so that things
are stopped properly.
See #2764
The parsing functions expect float values in the default locale so use
the spa_dtoa function to generate such a float.
Fixes setting params with floating point values when the locale is not
the default locale.
When we were using the resampler and then bypass it when the configured
rate == 1.0, we create a pop because we don't process the queued data in
the resampler anymore.
Avoid this by keeping the resampler active as soon as the rate property
is set on the audioconvert. The resampler itself will use a more
efficient copy method in that case anyway and it is expected that the
rate will change again later when we need to reactivate the resampler.
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(some_array); i++)
.. stuff with some_array[i].foo ...
becomes:
SPA_FOR_EACH_ELEMENT_VAR(some_array, p)
.. stuff with p->foo ..
So that we can reuse optimized versions in unoptimized noise
functions.
Do allocation a little different so that we can align everything
from the start.