Perform detection of supported sample format and rates just after device is
opened, before `snd_pcm_hw_params()` is called for the first time. This fixes a
problem where device restricts available sample rates after HW params are set
preventing sample rate detection (seen with UAC2 devices and kernel 6.1.9)
Bug: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1414
Bug: https://github.com/alsa-project/alsa-lib/issues/119
Link: aed52c507f
[Wim: Apply to acp add_pro_profile(), enable pa_alsa_supported_*()]
The full identifier check must be executed for the new melem
creation, otherwise the duplicate control element code check
is reached.
Example (using the snd-aloop driver):
numid=56,iface=PCM,name='PCM Notify',device=1,subdevice=1
numid=62,iface=PCM,name='PCM Notify',device=1,subdevice=2
Link: 81a051089f
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The new helem must be tracked and old helem must be cleared
to make the code work properly. Introduce the pointer to helem
as the private value for melem and add the necessary code.
Also, add a check for the duplicate mixer elements. The duplicate
mixer element invokes the abort check in alsa-lib. Print a warning
instead and handle the exit gracefully.
Link: d1675df0cd
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It may be possible that the ALSA control element appears
again. Allow this combination by checking, if the pulseaudio
mixer element already exists. Do not create the duplicate
mixer element in this case.
Link: def8eb074e
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
sync_mixer() calls d->set_volume(d, &d->real_volume);
which makes v and &dev->real_volume point to the same memory area
and valgrind complains:
Source and destination overlap in memcpy(0xcc53e2c, 0xcc53e2c, 260)
at 0x488CFA0: __GI_memcpy (vg_replace_strmem.c:1121)
by 0xBB0803F: set_volume (acp.c:1143)
by 0xBB0EDCB: acp_device_set_port (acp.c:1897)
by 0xBA9CD87: impl_set_param (alsa-acp-device.c:757)
because the compiler apparently implicitly converts this into a memcpy()
and memcpy(3) explicitly says "The memory areas must not overlap."
api.acp.hidden-ports and api.acp.hidden-profiles can be used to pass
a json array of ports and profiles to hide. They will not show and
will not be selectable.
Don't try to multiple the max_buffer_size with the frame scale or else
we might try to set a min_buffer_size larger than the max_buffer_size.
Instead, use the frame_scale only to scale the quantum_limit and then
clamp against the max_buffer size.
See #3000
We place the currently configured runtime settings in the properties but
clear the values when not negotiated. Don't do that but place the
defaults (when set) instead.
When we don't have the thread id yet, don't add the pollfds yet
but wait until we do our first wait operation.
Use flags for eventfd. We can use this to communicate between all kinds
of threads with read/write.
Use evl_init() in the init function, don't attach the main loop, just
the thread that dos the first poll.
Some devices appear to set Supported_Max_Codec_Frames_Per_SDU == 1 while
claiming they support two channels per stream, which is then not
possible.
In this case, limit the number of channels by the number of frames per
SDU when selecting.
Also adjust PAC sorting.
It doesn't make sense to hang these on the data loop, so let's have
these on the main loop instead. Also avoids a potential crash while
removing them (since removal happens on the main loop and the data loop
might be polling while we're doing the remove).
added cleanup of unused variables and fix warning about missing initializers
to resolve build warnings in pipewire-rs
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Don't use the current time as the nsec field in the graph clock because
it can jitter a lot. Instead, use the smoothed next_time, like we do
for timer based scheduling.
Since we track the current time against the rate converted ideal time,
lock on to the first timestamp when we reset the dll.
See #3657
Don't return the value of the last snd_pcm_resume() call because that
might be -ENOSYS when resume is not implemented for the card and then
the non-error (because we used drop/prepare later) propagates and
logs an error.
Backport from Pulseaudio. Reimplement get_data_path. We'll look for the
override files similarly as we do for other config files
(XDG_CONFIG_HOME then /etc then install location), instead of looking at
the Pulseaudio locations ~/.local/share/pulseaudio etc.
Upstream commits:
From: SimonP <simonp.git@gmail.com>
alsa-mixer: Respect XDG base directory spec when loading profile sets
Try $XDG_DATA_HOME, then $XDG_DATA_DIRS, and finally fall back to old behaviour.
From: SimonP <simonp.git@gmail.com>
alsa-mixer: Respect XDG base directory spec when loading path configs
Try $XDG_DATA_HOME, then $XDG_DATA_DIRS, and finally fall back to old
behaviour (prefix-defined directory).
core-util: Ignore non-absolute XDG base dirs
These are invalid per the spec.
This adds an api.alsa.bind-ctls property to alsa-pcm sink and source
nodes, to bind a property to an ALSA PCM ctl. The property is an array
of ctl names that should be bound.
This can be handy, for example, to bind the Playback/Capture Rate
controls on a USB gadget, in order to track the PCM's state via a node
param.
This is currently wired to be read-only, but it should be easy enough to
make it writable.
Use `SPA_CONTAINER_OF()` instead of direct casting as it is
more resilient against future changes that might reorder the
members in `struct spa_debug_log_ctx`.
Because we now always _drop/_prepare_/_start, the snd_pcm_recover()
before that is no longer useful.
Retry snd_pcm_resume() after suspend when -EAGAIN and fall back to
_drop/_prepare/_start when that fails.
We need to disable the resampler when there is a pitch element. This was
correctly done in setup_matching but not in check_position_config().
See #3628
GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
./pipewire-0.3.84/spa/plugins/bluez5/codec-loader.c:176:14: warning: allocation of insufficient size ‘1’ for type ‘struct impl’ with size ‘1032’ [-Walloc-size]
```
The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```
So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(struct impl)`. GCC then sees we're not
doing anything wrong.
Signed-off-by: Sam James <sam@gentoo.org>
When the device has not configured a format, remove the properties that
depend on the format so that they don't limit what we can configure the
device with next.
See #3613
In pw_context_recalc_graph, PipeWire takes the currently configured
clock target duration from the position as target rate. The position is
not set for the videotestsrc since the set_io function is not
implemented. This leads to a segfault when the videotestsrc is
configured and loaded.
Add the same dummy implementation of set_io as in the v4l2-source and
the libcamera-source to prevent the segfault.