Commit graph

3795 commits

Author SHA1 Message Date
Pauli Virtanen
882f9ad2b3 bluez5: emit BAP device set nodes as needed
Emit BAP device set nodes, which the session manager can use to combine
the sinks/sources of a device set to a single sink/source.

Emit the actual sinks/sources with media.class=.../Internal to hide them
from pipewire-pulse.

Add separate device set routes to the set leader device.  Other routes
of the set members will be marked as unavailable when the set is active.

Accordingly, return failure for attempts to set these unavailable
routes, so that volumes etc. of the "internal" nodes are only controlled
via the device set route.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
1a44754f8d bluez5: wait for devices in the same set before emitting nodes
Emit nodes only after all devices in the same set are ready, or until
add timeout elapses.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
d642569394 bluez5: parse device set information via dbus
Parse device set information from DBus, and link devices to each other
according to it.  Add signal for notifying about device set changes.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
eca13ec230 bluez5: iso-io: get BAP interval from dbus, not getsockopt
For ISO server sockets, the QOS struct from getsockopt contains values
with different meaning from ISO client socket. Get the values via DBus
instead, which is right in both cases.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
ae76789f24 bluez5: iso-io: ensure streams are initially marked idle
Mark streams idle when they are being stopped/started, so that the
pause-to-sync logic always triggers when they are added.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
6e94487057 bluez5: set BAP channel location from transport if unset
If BAP codec configuration is mono channel with unspecified location,
set the channel position from transport location.

This in principle should be set in SelectProperties, but currently BlueZ
doesn't tell us that yet there, so we hack it up later on.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
8f840e703b bluez5: lc3: number of blocks is not the number of channels
The number of channels is determined by Audio_Channel_Allocation.
One frame block contains all channels. (BAP v1.0.1 Sec. 4.2)

Fix the handling of frame blocks and counting of numbers of channels. We
support and configure only one frame block per packet.

Consider omitted Audio_Channel_Allocation to indicate MONO stream (see
BAP v1.0.1 Sec 4.3.2).
2023-04-10 07:00:44 +00:00
Pauli Virtanen
e4cd99f76f bluez5: add some debug for media-sink 2023-04-10 07:00:44 +00:00
Forest
252620a18d alsa-profiles: SB Audigy: stereo mixer paths
This is a follow-up to d5390c7, where we switched to the 'PCM' mixer controls
on Sound Blaster Audigy devices, since the ones we used before only work in the
stereo-to-all-speakers mirroring mode.

It turns out we do use that mode after all, but only in a couple of profiles.
Since returning those profiles to the default mixer path yields uneven volume
steps similar to #2934, we instead add a new mixer path just for that mode.
2023-04-09 12:20:26 -07:00
Forest
1e77a7cc51 alsa-profiles: SB Audigy: rename path config file
This makes the file name consistent with the other device-specific ones.
2023-04-09 12:14:39 -07:00
Forest
6939c1e4ee alsa-profiles: SB Audigy: remove absent elements
Some of the elements/keys that were copied from analog-output.conf are not
implemented by the Audigy driver, so we don't need to reference them.
2023-04-09 12:14:29 -07:00
Pauli Virtanen
772ff3365b bluez5: backend-native: add two missing OK HFP replies
We should reply OK to both AT+BIEV and AT+IPHONEACCEV.
2023-04-08 11:05:06 +00:00
Forest
d5390c7199 alsa-profiles: use SB Audigy PCM mixer controls
Creative Labs Sound Blaster Audigy cards (snd_emu10k1 driver) expose
mixer controls named 'PCM Front', 'PCM Rear', etc. in addition to the
more common 'Front', 'Rear', etc.  The latter seem to be intended for
a stereo-to-all-speakers mirroring mode that we do not use, and have
no effect when we adjust them.
https://docs.kernel.org/sound/cards/audigy-mixer.html

We therefore define a custom mixer path for Audigy devices, using the
PCM mixer controls.

This has been tested on an Audigy 5/Rx.  Based on a brief look at the
ALSA driver, I think all Audigy devices (vendor 0x1102, device 0x0004
or 0x0008) have the same PCM controls, making this change probably safe
for our existing Audigy udev rules.

Relevant kernel files:
sound/pci/emu10k1/emu10k1_main.c
sound/pci/emu10k1/emufx.c
include/sound/emu10k1.h

Fixes #2934
2023-04-07 21:15:38 +00:00
Sourav Das
8cf9986774 spa:bluez5: fix compilation
on lower bluez version, BT_ISO_QOS macro is not available
    So, need to check it also fixes the compilation.
2023-04-06 09:19:47 +00:00
Wim Taymans
463e723a1e test: add more lossless tests
Also test that S16->F32->S32 and U16->F32->U32 are lossless.
2023-04-06 10:00:17 +02:00
Wim Taymans
edf2062830 fix compilation 2023-04-05 19:53:33 +02:00
Wim Taymans
6dcf0027d8 audioconvert: implement mix/resample_disabled
Fail when resampling or channelmixing is required but disabled.
2023-04-05 19:51:16 +02:00
Ashok Sidipotu
805a1c61d9 adapter-control: avoid the divide by zero while generating sequence. 2023-04-05 16:33:09 +05:30
Ashok Sidipotu
7dbad54ae5 audioconvert: donot return errors in the volume ramp setparams
Also avoid the divide by zero while generating sequence.
2023-04-05 16:27:48 +05:30
Wim Taymans
74831aa967 support: add support for checking loop context
Add check for running the the loop context and thread.

Add checks in filter and stream to avoid doing things when not run from
the context main-loop because this can crash things when doing IPC from
concurrent threads.
2023-04-04 16:19:41 +02:00
Wim Taymans
f2be2923e6 thread: use pthread_equal to compare thread ids 2023-04-04 12:43:25 +02:00
Wim Taymans
d41d8cf983 audioconvert: fix return values
Return negative error numbers for errors.
2023-04-03 21:34:10 +02:00
Wim Taymans
e5809cf4f4 spa: move audio props to audio section 2023-04-03 21:30:11 +02:00
Ashok Sidipotu
dcec2e785e audioconvert: add a invalid value for scale
The invalid value here is zero, this will help avoid inadvertant parameter
updates and brings this on par with rest of the volume ramp parameters
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
b61bf8a27d adapter-control: bundle the volume ramp parmeters with volume 2023-04-03 19:04:55 +00:00
Ashok Sidipotu
74872250e8 audioconvert: make volume ramp parameters non-sticky
This mean the volume ramp parameters will have to be issued along with volume
every time. They will not be persistant.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
737bc89ab9 audioconvert: grow the volume ramp buffer
Grow the volume ramp sequence command buffer dynamically, if needed.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
e75fe4d469 adapter-control: add support of scale volume ramp param 2023-04-03 19:04:55 +00:00
Ashok Sidipotu
8bfafaeca2 audioconvert: add support of volume ramp scale parameter
- Add support for Linear and Cubic volume scales
- Also start treating a "zero" value of volume ramp parameters as invalid
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
7b91d506f1 adapter-control: add support for volume ramp time params
- Add support for both native and non-native modes
- Add "examples" in the help text
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
b0f6c4a8c0 audioconvert: add support for volume ramp time params 2023-04-03 19:04:55 +00:00
Ashok Sidipotu
075fd49ccc adapter-control: add CLI options
-To select between non-native(via control channel) and native modes(via audio
adapter ). The control port will be opened only in the non-native mode.
-To select different sample and sample step sizes. The Legacy non-native
 mode also uses these params now.
-To provide the alsa device.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
b1b5367d40 adapter-control: use the volume ramp parameters to ramp volume
Add a compiler macro for now to switch between the inband(control port based)
volume ramping and out of band(using volume ramp parameters)
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
40cf237eb3 audioconvert: add volume ramp parameters
Add volume ramp parameters and the add ramp up and down funtions which get
triggered on volume change.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
3b1ce6c268 audioconvert: parameterize channelmix_process_control() function
Decouple the function from control port and parameterize it, so that it can be
called any spa pod sequence.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
2a12dfeb47 adapter-control: add more debug messages 2023-04-03 19:04:55 +00:00
Ashok Sidipotu
3ed282fad5 adapter-control: enable SPA debug logs
Also add timestamp to the logs.
2023-04-03 19:04:55 +00:00
Pauli Virtanen
6db234ad0c bluez5: media-sink: use iso-io for BAP
Use the ISO IO helpers to get synchronized BAP output, and rate match to
the ISO schedule.

The rate matching is necessary, since the driver may be ticking at a
corrected rate, different from the ISO interval rate.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
cec050ac25 bluez5: add spa_bt_iso_io that does the low-level part for ISO
Add factored out helper for ISO socket I/O.

ISO sockets need synchronization of writes and audio position for
different stream fds in the same isochronous group, and it's easier to
separate out the part that coordinates it.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
0ed124f0fb bluez5: add rate matching for BAP to media-sink
Add basics for rate matching.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
41c155bb4c bluez5: split rate control out of decode-buffer 2023-04-03 16:35:22 +00:00
Pauli Virtanen
e0939ff8ab bluez5: don't set bluez timeout on transport release
Setting bluez timeout on transport release makes codec switches delayed,
and is not necessary.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
c0d55eae86 bluez5: use release timeout for all transport types
Avoiding unnecessary release + reacquire when nodes restart makes sense
for all transport types.  Do timed releases for all transport types, not
only SCO.
2023-04-03 16:35:22 +00:00
Arun Raghavan
3dc08c09d1 volume: Fix inverted check for buffer validity 2023-03-31 08:19:07 +00:00
Wim Taymans
108715ebfb alsa: add tsched use to info log
Fixes !1580
2023-03-30 17:50:35 +02:00
Wim Taymans
7da61e2dfa examples: fix adapter control
target_rate and duration need to be configured now.

Fixes #3125
2023-03-30 15:15:41 +02:00
Wim Taymans
b3940627dd audioconvert: pass the NODE_ASYNC flag correctly
Pass the follower async flag correctly in the adapter.
2023-03-30 15:03:29 +02:00
Wim Taymans
4fb17d1c03 audioadapter: clear rate matching when not using converter
Ensure that we clear the rate matching when we are not using the
converter. This will make the follower use the quantum instead of the
dummy unused rate matching area.

Exit when we can't make an internal converter because then things really
are not going to work. Remove some of the pointless NULL checks.
2023-03-30 15:03:29 +02:00
Wim Taymans
a163f29a43 improve logging 2023-03-30 15:03:21 +02:00
Wim Taymans
5ae73fccdd alsa: only update alsa sources when added to the data loop 2023-03-29 15:31:21 +02:00