Commit graph

10157 commits

Author SHA1 Message Date
Arun Raghavan
48c57ba4c5 pacat: Make temporary string variables less cryptically named 2022-07-22 08:00:33 -04:00
Arun Raghavan
de137908a8 sink: Only update sink inputs if reconfiguration succeeds 2022-07-22 08:00:33 -04:00
Arun Raghavan
8fff528000 source: Bring some debug logging in sync with what we do for sinks 2022-07-22 08:00:33 -04:00
Arun Raghavan
d666f44fa4 sink, source: Drop return value from reconfigure function
This wasn't actually used anywhere.
2022-07-22 08:00:33 -04:00
Arun Raghavan
3de9f445fa sink-input,source-output: Disallow volume change on passthrough streams
We shouldn't be setting volumes on these streams as that would change
the content.
2022-07-22 08:00:33 -04:00
Arun Raghavan
6815521f11 alsa-sink: Fix AES bit setting for HDMI and S/PDIF
pa_sink_is_passthrough() might not be true at the time of unsuspend, so
we can't count on it to set the AES bits. Let's just remember
passthrough state from reconfiguration and use that.
2022-07-22 08:00:33 -04:00
Arun Raghavan
ce069ebd61 alsa-sink: Set more AES bits for passthrough audio
Based on what PipeWire and Kodi's ALSA engine do.
2022-07-22 08:00:33 -04:00
Arun Raghavan
09e8033c49 alsa-source: Bring reconfigure in line with alsa-sink
This got fixed for new API expectations (channel map will always be
set), so keep things up-to-date.
2022-07-22 08:00:33 -04:00
Arun Raghavan
e79cefb723 alsa-sink: Explicitly handle channel map reconfiguration
We don't actually support it, but handle this path correctly.
2022-07-22 08:00:33 -04:00
Arun Raghavan
9f3e82ac31 sink, source: Fix reconfiguration of monitor sources
We should only reconfigure monitor sources when the corresponding sink
is reconfigured (and when it is, we should unconditionally set it to the
requested spec/map of whatever the sink got reconfigured to).

The previous logic was incorrect on all 3 counts.
2022-07-22 08:00:33 -04:00
Arun Raghavan
2046afe683 sink, source: Merge sink sample spec setter functions into one
It seems better to update the whole sample spec (and channel map) at a
shot rather than piecemeal.
2022-07-22 08:00:33 -04:00
Arun Raghavan
7df1b78ac2 shell-completion: Add --encoding for pacat 2022-07-22 08:00:33 -04:00
Arun Raghavan
3e4dc134d4 man: Document the --encoding option for pacat 2022-07-22 08:00:33 -04:00
Arun Raghavan
50e4c06a44 tests: Fix up an apocryphal variable name 2022-07-22 08:00:33 -04:00
Arun Raghavan
376945dc43 sink, source: Print channel count when reconfiguring
Add this as we might reconfigure the number of channels too.
2022-07-22 08:00:33 -04:00
Arun Raghavan
8d6f415c85 sink, source: Add comment about not reconfiguring channel map
There is no meaningful usecase at the moment for it.
2022-07-22 08:00:33 -04:00
Arun Raghavan
96c119fbe4 sink, source: Add a channel map validity check for reconfiguration
Also move the check to an early assert instead of silently bailing.
2022-07-22 08:00:33 -04:00
Arun Raghavan
5d1184b35a sink, source: Drop redundant restore argument to reconfigure
The sample spec's NULLness is sufficient to determine whether we are
restoring or not.
2022-07-22 07:46:34 -04:00
Arun Raghavan
6afdebb55f sink, source: Don't force refresh while saving volume for passthrough
There's no reason to go to the h/w to refresh the volume when we are
just saving the value for restoration later.
2022-07-22 07:46:34 -04:00
Arun Raghavan
b550fa5628 sink, source: Add API to update sample spec
This is useful to have visibility into when the whole sample spec
changes at runtime (during reconfiguration, for example).
2022-07-22 07:46:34 -04:00
Arun Raghavan
628c0c0b74 alsa: Implement reconfiguration of channel count/map
This is needed at the moment for passthrough support of high bitrate
formats (such as DTS-HD and Dolby TrueHD), which, in addition to setting
a higher sample rate also set channel count to 8. It would be clunky to
require users to reset the HDMI profile based on the format being
played, so for consistency we continue to only allow setting formats on
the stereo profile, and reconfigure channels as needed for the duration
of pakssthrough playback.

We implement the source side as well for consistency.
2022-07-22 07:46:34 -04:00
Arun Raghavan
4693028b9b sink, source: Add API to change channel count
This makes this part symmetrical with the rest of the sample spec, and
will be useful when we implement switching channel count in a sink.
2022-07-22 07:46:34 -04:00
Arun Raghavan
f9d139c3bc pacat: Allow specifying non-PCM encoding for playback
This adds a --encoding argument to allow specifying a non-PCM format for
playback. This is expected to be useful for testing support for
compressed formats.
2022-07-22 07:46:34 -04:00
Arun Raghavan
47298b8de8 sink, source: Add a way to change channel map
This adds functions to allow changing the channel map on a sink or
source. We make module-null-sink use this function instead of changing
the channel map manually to allow for logging and notifications.

The source function is currently unused but we add it to maintain
symmetry with the sink.
2022-07-22 07:46:34 -04:00
Arun Raghavan
e4a085f6d3 null-sink: Add avoid-processing support 2022-07-22 07:46:34 -04:00
Arun Raghavan
ecbe1e8c22 null-sink: Add the ability to dump what we're rendering
This should be useful for manual and automated testing, to examine what
the data coming out of null sink looks like.
2022-07-22 07:46:34 -04:00
Arun Raghavan
d46908f9b6 tests: Add a test to validate sink reconfiguration 2022-07-22 07:46:34 -04:00
Arun Raghavan
52a9d87053 tests: Refactor common client code from passthrough test
This code can be reused for other tests that need to connect to the PA
server and load a NULL sink. The idea is to grow this out with basic
primitives that various tests need to make it easier to add more unit
tests for various situations.
2022-07-22 07:46:34 -04:00
Arun Raghavan
01c26546fa sink, source: Add an avoid-processing mode
This generalises the avoid-resampling concept (don't resample for any
rate above the default/alternate sample rate) to include channel count
and sample format as well. The rationale for this is that users who wish
to send out their data untouched by processing in PulseAudio can do so.

In addition to this, there are opportunities for certain hardware (such
as systems with a DSP connected to a codec) to offload processing to the
DSP (providing potential cost savings).

Finally, this also enables modules that might be able to perform
transformations of (ANY -> sink format), and this allows us to implement
such transformations.
2022-07-22 07:45:45 -04:00
Arun Raghavan
cbaf278f1e sink, source: Consolidate passthrough setup in reconfigure
This moves over the saving+resetting/restoring of volumes and source
suspending/unsuspending while entering/leaving passthrough mode into
reconfigure functions. This makes it easier to reason about exactly what
behaviour occurs at the time, as well as avoids loss of precision during
the remapping of the internal volume values in this case.
2022-07-22 07:07:58 -04:00
Arun Raghavan
0d85b18460 sink, source: Allow reconfigure to change the complete sample spec
For the passthrough case, we allow the entire sink sample spec to be
changed in reconfigure. This will be needed for high bitrate formats. We
duplicate this for sources to keep things in sync as well.

Relatedly, we also restore the original spec on leaving passthrough
mode. We were getting away with not doing so in the past as, while
incorrect, not restoring the rate was not disastrous. With the ability
to change channel count, not restoring breaks the meaning of profiles
entirely. The saving and restoration logic is restricted to sink/source
reconfiguration code to allow it to be self-contained and easier to
reason about.

All this also applies to the channel map. We don't actually explicitly
reconfigure the channel map at the moment, but since
pa_sink/source_reconfigure() can now change the channel count, it seems
to make sense to include the channel map along with that API change for
future use.
2022-07-22 07:07:58 -04:00
Peter Meerwald-Stadler
9360dce76d raop-client: Fix typo
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/733>
2022-07-18 14:47:38 +00:00
Peter Meerwald-Stadler
e8509ea85c volume: Fix typo
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/733>
2022-07-18 14:47:38 +00:00
Peter Meerwald-Stadler
f71eafe4d9 module-tunnel: Fix typos
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/733>
2022-07-18 14:47:38 +00:00
Peter Meerwald-Stadler
63d0db832c module-combine-sink: Fix indentation
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/733>
2022-07-18 14:47:38 +00:00
Peter Meerwald-Stadler
0b4af61ee7 module-combine-sink: Use fabs() instead of abs() for double
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/733>
2022-07-18 14:47:38 +00:00
Igor V. Kovalenko
07a9fcefba build-sys: meson: Move qpaeq to daemon build
Equalizer control requires server modules only available when daemon is built.
Move qpaeq script to be installed together with daemon.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/734>
2022-07-18 14:03:45 +00:00
Nicolas Cavallari
baa3d24b76 build-sys: Add missing libatomic_ops dependencies
Add libatomic_ops dependencies to libraries/modules that showed a
failure on an arch that does not have native atomic operations support.

Not all optional dependencies were tested, so it is possible that
some optional modules are still missing libatomic_ops dependencies.

Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/732>
2022-07-18 13:59:14 +00:00
Nicolas Cavallari
fd81201f28 build-sys: Fix atomic support detection
Attempting to use atomics operations on an architecture that does not
support them generally results in a link error:

ld: /tmp/ccjYcMPP.o: in function `func':
testfile.c:(.text+0x1c): undefined reference to `__sync_bool_compare_and_swap_4'

The current build system uses cc.compiles() to check if atomic ops are
supported, but cc.compiles() does not attempt to link, so the test fails
to enable libatomics_opts.

Fix this by using cc.links() instead of cc.compiles().

Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/732>
2022-07-18 13:59:14 +00:00
Jaroslav Kysela
81a051089f alsa-mixer: extend pa_alsa_mixer_find with the subdevice check
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

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/730>
2022-07-18 13:51:33 +00:00
Jaroslav Kysela
d1675df0cd alsa-mixer: fix the re-attach code for the mixer control element
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.

Fixes: def8eb074 ("alsa-mixer: allow to re-attach the mixer control element")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/730>
2022-07-18 13:51:33 +00:00
Jaroslav Kysela
eb870fcba9 alsa-ucm: remove extra space from the device.intended_roles property
Before:
  device.intended_roles = " voice"

After:
  device.intended_roles = "voice"

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/731>
2022-06-29 17:03:46 +02:00
Alper Nebi Yasak
5dd411190d alsa-ucm: Create multiple profiles per verb for conflicting devices
Right now we try to add all UCM devices of a verb to a single profile.
But if some devices using different PCMs are configured as conflicting
with one another, we will only be able to utilize one of them, chosen
seemingly based on the order in the UCM config file.

This is not a problem with conflicting devices sharing a PCM, as they
are assigned to the same mapping and the ports mechanism only enables
one of them to be active at a time.

To utilize all devices in a UCM verb even when there are conflicting
devices using different PCMs, calculate subsets of devices which
can be simultaneously used and create a profile for each such set.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:15:08 +03:00
Alper Nebi Yasak
e49da7bcd6 alsa-ucm: Disable old devices when switching profiles of same verb
While switching profiles, it was enough to switch UCM verbs since that
disables all enabled UCM devices and every profile had a distinct verb.
However, switching to the current verb does not disable any devices.

To support multiple profiles for a verb we need to explicitly disable
the old profile's devices, since they might be conflicting with the new
profile's devices and will prevent them from being enabled. Compare both
profiles' mappings, and disable the devices not in the new mappings.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:15:08 +03:00
Alper Nebi Yasak
4821a0569e alsa-ucm: Make mapping UCM contexts have only one modifier
After previous patches, we should be generating no combination ports, so
we don't need to store multiple modifiers per mapping. Simplify the code
based on this.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:15:08 +03:00
Alper Nebi Yasak
084d70a1e2 alsa-ucm: Make mapping UCM contexts have only one device
After previous patches, we should be generating no combination ports, so
we don't need to store multiple devices per mapping. Simplify the code
based on this.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:15:07 +03:00
Alper Nebi Yasak
bf1708213b alsa-ucm: Make ports store only one device
After previous patches, we should be generating no combination ports, so
we don't need to store multiple devices per port. Simplify the code
based on this.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:12:37 +03:00
Alper Nebi Yasak
0789a8fb76 alsa-ucm: Remove combination port generation logic
A previous commit makes mapping names depend on the UCM device name.
Since UCM device names are unique, this means a mapping will at most
have one port and thus no combination ports can be generated.

This removes the dead code in the pa_alsa_ucm_add_ports_combination()
function, unrolls the remaining code in its helper functions that it
used, and renames it to pa_alsa_ucm_add_port() to signal that it no
longer generates combinations.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:11:56 +03:00
Alper Nebi Yasak
a50330a4a5 alsa-ucm: Make one input/output mapping per UCM device
PulseAudio combines UCM devices that have the same PlaybackPCM or
CapturePCM value into a single mapping with multiple ports. It also
creates ports in the same mapping for each valid combination of those
UCM devices.

Since mappings are the things we put in profiles, we can put in a
profile either all devices of a joint mapping or none of them. This
causes some complications with device conflicts. For example, a
different UCM device might be marked as conflicting with some (but not
all) of the devices in a joint mapping. In this case we can do one of
three things:

- Include all devices in one profile, and hope the conflicting device
  isn't chosen as the mapping's active port. We shouldn't do this as it
  puts conflicting devices in the same profile.

- Make one profile with the joint group, and one with the other device.
  This is somewhat acceptable as we have no conflicts, but we sacrifice
  some compatible combinations of devices.

- Do not group the devices into the same mapping, and make one profile
  for each compatible combination of devices. This appears to be the
  best option, one where we can always have the maximum number of
  working devices.

This patch chooses the third option and makes one input and/or output
mapping per UCM device, by using UCM device names instead of PCM device
strings in the mapping names.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:11:56 +03:00
Alper Nebi Yasak
e8e2f4320c alsa-ucm: Split out helpers for device set name, description, priority
Combination port logic calculates some useful properties for device
groups that we could reuse while generating multiple profiles to support
conflicting devices. Split them into their own functions.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
2022-06-28 15:11:56 +03:00