Commit graph

953 commits

Author SHA1 Message Date
Pauli Virtanen
83050e647b bluez5: aptx-ll: produce 7.5ms packets
Put a bit more samples to packets to make it more robust.  The 7.5ms
interval may also fit better with other BT devices.
2024-02-05 19:34:47 +02:00
Barnabás Pőcze
4aa2e44796 spa: move dbus helpers out of bluez plugin
The file is moved into a new "include-private" directory. This is done
because otherwise adjustments would have to be made to the list of installed
headers, the way include tests currently work and which files are
used for generating documentation.
2024-02-05 13:03:20 +00:00
Pauli Virtanen
ddf3be0a39 bluez5: lc3: clean up some sanity checks
Fix some sanity checks and add mtu check.  Don't use
spa_return_val_if_fail here as it can spam stderr.

The buffer size check in codec_encode can't be hit.
2024-02-05 08:59:18 +00:00
Pauli Virtanen
61c585c8e6 bluez5: support Google's Opus A2DP vendor codec 2024-02-04 12:58:40 +02:00
Pauli Virtanen
ff0305dada bluez5: disambiguate the two Opus codecs 2024-02-04 12:57:31 +02:00
Pauli Virtanen
0c434e4821 bluez5: reset A2DP codec shared endpoint status on disconnect 2024-02-04 12:57:31 +02:00
Pauli Virtanen
45385b2b66 bluez5: SBC-XQ does not need its own endpoint
The endpoint caps are identical for SBC and SBC-XQ, so they can share
the same endpoint.

This reduces the number of registered endpoints by one.
2024-02-04 12:57:31 +02:00
Pauli Virtanen
805e5cf9c1 bluez5: show only codec profiles also for HFP/HSP
Don't show a "codecless" profile for HFP, similarly as we do for A2DP.

Simplify codec handling: for HFP/A2DP there's at most one transport for
each profile, so no need to check it has right codec.  There's also no
need for "fallback profile", we always just emit nodes for the transport
we find.
2024-02-03 16:10:12 +00:00
Pauli Virtanen
597116bb23 bluez5: backend-native: ensure we no transports are leaked
Make sure we don't leak transport even if remote sends invalid command
sequences.
2024-02-03 16:10:12 +00:00
Pauli Virtanen
f142c0a5b0 bluez5: ensure transport->codec is set also for HSP 2024-02-03 16:10:12 +00:00
Pauli Virtanen
db7b764bf2 bluez5: deprioritize AAC-ELD since it's untested
The AAC-ELD support was not properly tested on devices.  In theory it
should be OK, but it's untested.

Bump it down in priority so it won't be selected by default.
Also log info on FDK-AAC AAC-ELD support status.
2024-02-01 08:06:06 +00:00
Pauli Virtanen
8e3c0f02b2 doc: bluez5: document some internals in media-codec 2024-01-29 08:50:32 +00:00
Pauli Virtanen
21392d327f bluez5: lowball fallback delay values
Reduce fallback delay values used when BT device doesn't provide the
information itself.

It may be better to have audio late than early, so use values that are
probably close to or below the delays of majority of headsets.
2024-01-28 18:00:04 +02:00
Pauli Virtanen
2ed0cddc57 bluez5: sco-sink: more accurate latency values
Use audio packet size for the latency, support for latencyOffsetNsec.
2024-01-28 18:00:04 +02:00
Pauli Virtanen
c0eb634156 bluez5: media-sink: more accurate latency
Don't include the quantum in latency: the latency relative to graph
cycle start doesn't depend on the quantum.  Instead, the audio packet
size determines it.
2024-01-28 18:00:04 +02:00
Pauli Virtanen
95b13391eb bluez5: media-sink: fix wrong clock
Should use position for graph clock rate.
2024-01-27 18:04:57 +02:00
Pauli Virtanen
84c5ba09dc bluez5: support api.bluez5.internal flag also for sco
Enable the /Internal media class hack also for SCO.

Session manager can use this to adjust SCO sink/source media.class when
it is going to emit front-end nodes hiding the hardware ones.
2024-01-26 11:58:30 +00:00
Pauli Virtanen
05402284c1 bluez5: backend-native: fix all rfcomm lookups to check profile
The rfcomm list may contain various AG & HF ones, so the profile must be
checked everywhere they are looked up.

Fix the rfcomm lookups everywhere to do it.

Fixes Pipewire<->Pipewire HFP connections, and sending HFP HF commands
to HSP or AG.
2024-01-26 11:57:30 +00:00
Pauli Virtanen
65f594c6a1 bluez5: further HFP cleanups
Fix naming issues.
2024-01-25 08:43:45 +00:00
Pauli Virtanen
ebde25fe58 bluez5: clean up SCO code a bit
Minor cleanup in variable naming etc.
2024-01-25 08:43:45 +00:00
Pauli Virtanen
45ff965f33 bluez5: support LC3-SWB in SCO sink/source
Add support for LC3-SWB encoding/decoding.

Tested on Pixel Buds Pro.
2024-01-25 08:43:45 +00:00
Pauli Virtanen
fe412784a4 bluez5: support LC3-SWB in HFP RFCOMM & add codec id for it
HFP 1.9 adds LC3 as a possible codec in addition to CVSD & mSBC.
E.g. Pixel Buds Pro latest firmware supports it.

Add the RFCOMM side and codec selection for it.
2024-01-25 08:43:45 +00:00
Pauli Virtanen
89077d16ec bluez5: prefer 16khz input for LE Audio duplex configurations
Devices may advertise other values, but not certain they will work well
in duplex configuration.

E.g. my Samsung Galaxy Buds2 Pro emits buzzing sound with 48kHz duplex
input.
2024-01-23 08:40:46 +00:00
Pauli Virtanen
cde8f9261c bluez5: lc3: pick qos values from BAP spec tables
Don't believe QoS values recommended by the device, which may be
suboptimal.  Instead, pick the values from the BAP v1.0.1 Table 5.2.

Link: https://github.com/bluez/bluez/issues/713
2024-01-23 08:40:46 +00:00
Pauli Virtanen
08819e3d17 bluez5: indicate to LC3 plugin whether endpoint is sink/duplex
The codec can make use of information on whether the endpoint is sink,
and whether there will be both sink and source configured.
2024-01-23 08:40:46 +00:00
Pauli Virtanen
9474030582 bluez5: determine available BAP profiles from remote endpoints
The PAC profile UUIDs do not appear in the UUID list, but are still
useful to know before SelectProperties.

Set them ahead of time based on the visible remote endpoints.
2024-01-23 08:40:46 +00:00
Pauli Virtanen
8eb1f5aa35 bluez5: pick right codec when multiple ones share the endpoint
The "default" codec is the one with fill_caps != NULL, and should be
picked if we don't know which one we are using.

Fixes showing AAC-ELD as supported when it's not, which happened because
it's ordered before the default AAC in the codec list unlike the other
"shared endpoint" codecs.
2024-01-22 22:38:45 +02:00
Wim Taymans
2f46ee2793 bluez: fix compilation some more 2024-01-22 15:39:17 +01:00
Wim Taymans
b2c8bd9311 bluez5: fix compilation 2024-01-22 15:20:53 +01:00
Adam Marcus
560b26a5b5 bluez5: add ELD support check 2024-01-22 14:04:16 +00:00
Adam Marcus
99b180f838 bluez5: correct endpoint name 2024-01-22 14:04:16 +00:00
Adam Marcus
e04fbb9f2a bluez5: avoid adding new codec endpoint 2024-01-22 14:04:16 +00:00
Adam Marcus
abf9725be1 bluez5: refactor ELD check 2024-01-22 14:04:16 +00:00
Adam Marcus
79ee1eaff0 bluez5: add AAC-ELD codec 2024-01-22 14:04:16 +00:00
Pauli Virtanen
cee92e08a9 bluez5: lc3: fix wrong enum_config
The rate is not a bitmask.
2024-01-16 23:48:34 +02:00
Pauli Virtanen
89cdf4f6eb bluez5: move no-HFP fast connect checks to better place
Not waiting for HFP when no HFP backend should be checked via
adapter_connectable_profiles in spa_bt_device_check_profiles where the
relevant logic is.

Cleanup by moving the checks there.
2024-01-16 14:29:01 +00:00
Pauli Virtanen
7c9b96c606 bluez5: add quirk for SoundCore mini2
AVRCP volume doesn't work properly with this device.

Closes #2927
2024-01-14 13:21:34 +02:00
Pauli Virtanen
ea5ff6b3c1 bluez5: more informative warning with unknown transports
Unknown transports visible in DBus usually belong to a different
sound server instance that is talking to BlueZ.

Explain this in the warning message that we log, so that people can more
easily understand why things are not working.
2024-01-14 10:57:56 +00:00
Pauli Virtanen
89d86c73c4 bluez5: add quirk for Rockbox Brick 2024-01-13 12:37:57 +02:00
Pauli Virtanen
70ffbaed74 bluez5: fix node initialization to init all nodes
Now that we can have more than 4 nodes, so should init them all.
2024-01-09 08:07:33 +00:00
Pauli Virtanen
f341dfed54 bluez5: lc3: prefer 7.5 ms frame duration
According to Intel people this is better for their hardware.

Link: https://github.com/bluez/bluez/issues/713
2024-01-09 08:07:33 +00:00
Pauli Virtanen
a154169942 bluez5: support multiple BAP transports per device
In multi-ASE configurations there can be multiple transports per device,
each corresponding to different channels.

Emit sink/source nodes for each BAP transport present.

Combine them into a single sink/source in the same way as we do for
device sets.
2024-01-08 10:09:13 +00:00
Pauli Virtanen
d487dc0fc6 bluez5: bap: support ChannelAllocation parameter from BlueZ
For multi-ASE configurations, BlueZ does the channel allocation itself,
and passes us the result in the ChannelAllocation parameter.

If it is present, don't do the allocation ourselves but use that value
instead.
2024-01-08 10:09:13 +00:00
Pauli Virtanen
caebeaa9b3 bluez5: lc3: workaround bad Supported_Max_Codec_Frames_Per_SDU
If Supported_Max_Codec_Frames_Per_SDU is less than what is required by
Supported_Audio_Channel_Counts, override its value assuming the device
actually supports at least that. Needed for Creative Zen Hybrid Pro.

Fix default value for channel count bitmask.
2024-01-08 10:09:13 +00:00
Pauli Virtanen
b533b06b51 bluez5: backend-native: handle multiple commands in RFCOMM input
Do relaxed parsing of RFCOMM commands for AG & HF roles, allowing
multiple commands in same buffer.

Use same parser code for all HFP/HSP AG/HF. Parse input in relaxed way,
as some devices emit spurious \n
2024-01-06 15:42:20 +02:00
Pauli Virtanen
1197b581d9 spa: use only static log topics 2024-01-04 10:02:55 +00:00
Pauli Virtanen
eaea03c26c spa: export log topic enumerations 2024-01-04 10:02:55 +00:00
Mauro Carvalho Chehab
d26916828d bluez5: update bluez-hardware.conf to ignore sbc-mq on Primark earbud
Primark True Wireless earbud doesn't support sbc-xq. Having it
enabled causes bluez to enter into a loop enabling/disabling
the device dozens of times per minute, making it unusable.
2023-12-26 16:02:22 +00:00
Pauli Virtanen
7f2dd3531c bluez5: use only one input route
Don't have separate input route for A2DP and HFP, as it is generally not
necessary.

When in A2DP mode when there's also HFP possible, emit the input route
in SPA_PARAM_Route, even though there is no corresponding input node
emitted.

The host may then emit a loopback microphone node, and switch profiles
according to its status. Having the input route available at all times
allows to retain changes to volume settings made when there is no real
input node.
2023-12-09 14:05:50 +02:00
Kiran K
44df080482 bluez5: Add support for 32KHz for lc3 codec
Fixes: b69e089648 ("bluez5: Add support for 32KHz sampling frequency")
2023-12-08 19:15:50 +05:30