This patch integrates the uplink sink feature of module-virtual-source into
the virtual source library, so that every virtual source can use it.
The patch also introduces latency handling and rewinding for the uplink sink.
Similar to the monitor source, the only useful definition of the latency
appears to be the negative of the master source latency. Rewinding will not
be possible in most situations, because the underlying memblockq is nearly
always empty.
module-combine-sink and module-suspend-on-idle required some changes to
deal correctly with this type of sink.
Analog to the virtual sink consolidation series, the common code of virtual sources
is moved to a library. The library adds support for fixed block size filters and
parameter changing. Rewinding has been dropped because virtual sources do not need
it.
Since 14.0, filter streams would be killed if the master sink or source disappeared. This
patch changes the behavior to allow rescuing of filter streams.
This module cannot be fully consolidated, but still there are significant savings.
With some re-ordering, probably even more of the code could be converted.
This patch moves the code for the virtual sink callbacks and initialization to
a separate file. The code is re-factored, extended and built as library, so that
it can be used by other virtual sinks as well. The suspend-virtual-on-master-suspend
fix for the ladspa sink (!68) was incorporated into the common code as well as the
sink part of !78 which fixes a crash with stacked virtual sinks. !68 has a bug
which leaves a virtual sink unavailable when the master sink disappears. This bug
is also fixed.
Additionally, fixed block size filters, fixed window size filters and updating filter
parameters are supported by the library. Fixed window size filters always deliver the
same number of frames to the filter, padding new data with history frames if necessary.
Rewinding can be disabled or or limited to the number of frames that the virtual sink
supports. Thanks to Alexander E. Patrakov for pointing out how to rewind fixed block
size filters.
The library implements following command line arguments if they are enabled in
valid_modargs: sink_name, sink_properties, sink_input_properties, force_flat_volume,
remix, resample_method and autoloaded.
This patch introduces the vsink structure which holds all data needed
by virtual sinks. This is in preparation of the consolidation of the
virtual sink code. The input_to_master field of the sink will be moved
to the vsink structure after the consolidation. Until all virtual sinks
are converted, sink->input_to_master and sink->vsink->input_to_master
must both be supported.
The pa_alsa_ucm_set_port() function is passed both a mapping context and
a device port, and both of these refer to their respective UCM device.
While switching over to having one port per mapping per UCM device, I
expected both of these to be the same device struct, so added an assert
checking so.
This assertion gets triggered when we have multiple UCM verbs declaring
the same UCM device name. The root cause here is that the ports' UCM
device references are set once while creating the ports for the card, so
they happen to be those of a specific verb and may not match those from
a different UCM verb's profiles' mappings.
Solving the root cause necessitates a larger refactor. What we actually
assume here is that name of the UCM device is same for both the port and
the UCM context, which ends up always true in practice. For now, replace
the assert with a check and error.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/802>
Some versions of the ALSA libraries run into a segmentation fault when
we query a UCM device/modifier status without first setting a UCM verb.
It's not a reasonable thing to do anyway, so check for this case and
return an error. Also do the check in other helpers.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/801>
When we connect Lenovo XT99 bt headset in the Ubuntu 22.04, this
headset could only work in A2DP profile, couldn't work in HFP profile
with a high chance.
This headset supports mSBC, after pulseaudio replies "+BCS:2" to
headset, we expect to receive a "AT+BCS=2\r" from the headset, but
with a high chance, it will receive 2 AT commands in a buffer like
this "AT+CHLD=?\rAT+BCS=2\r", and we also observed other 2 AT commands
in a buffer like this "AT+NREC=0\rAT+CGMI?\r".
Here we don't suppose there is only one AT command in a buffer, we
will find each command by the delimiter "\r" and handle each command
by sequence.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/804>
When `pwd.h` header is not available (i.e. not using glibc) and environment
variables are not set (e.g. running via `env --ignore-environment`) client
library would crash due to uninitialized variable in `pa_get_home_dir()`.
Add missing initialization to fix that.
Fixes: #3792
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/800>
If pa_memblockq_push needs to write into the middle of a chunk, target chunk
is split into head and tail sharing the same memblock. Size of head and
tail chunks is adjusted correctly, head chunk pointer into memblock remains
unchanged from target chunk.
The problem is with tail chunk offset into memblock which should be advanced
past write region of memblock, but currently it is left as 0.
This is causing an issue where seeking a few frames back into the middle of
memblock and writing a frame there ends up with tail chunk referencing frames
from very beginning of memblock causing corrupted output from memblockq.
Fix this by adjusting tail chunk offset into memblock past write region and
add a test case.
Fixes#3789
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/798>