Commit graph

1079 commits

Author SHA1 Message Date
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
kirankrishnappa-intel
b69e089648 bluez5: Add support for 32KHz sampling frequency 2023-12-08 08:34:09 +00:00
Pauli Virtanen
92f0815e4d bluez5: media-sink: keep one more buffer free
We delay the audio a bit to keep packet intervals equal, which keeps
some data in buffers.

In theory the calculation keeps one buffer free, but it doesn't
explicitly keep "extra" buffer space so in theory might flush too late
and next process() might not have free buffers.  However, as we encode
next packet right away this shouldn't really occur...

Try to keep one extra spare buffer free so that the flush time is
certainly early enough.
2023-12-05 18:37:36 +02:00
Pauli Virtanen
a9ff282501 bluez5: drop queued data on node stop
Clear queued buffers when stopping consuming, to ensure that all buffers
are usable when we start again.

Do for A2DP as we already do for SCO.
2023-12-05 18:37:36 +02:00
Pauli Virtanen
81aaf0e204 bluez5: set io status properly when sink is not going to consume
When sink is not ready to consume buffers, set io and status to indicate
it already has data.
2023-12-05 18:37:36 +02:00
Frédéric Danis
442a208382 Bluez5: backend-native: HSP AG release SCO link on AT+CKPD=200
Bluetooth PTS test HSP/AG/ACR/BV-01-I request AG to release the SCO link
upon reception of AT+CKPD=200 reception
2023-11-29 15:43:22 +00:00
Pauli Virtanen
f14572648a bluez5: deal with too small Supported_Max_Codec_Frames_Per_SDU
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.
2023-11-23 17:47:55 +00:00
Pauli Virtanen
f327ed845f bluez5: add some debug to bap-codec-lc3
We don't want to dump on all calls to codec_select_config, so use debug
context.
2023-11-23 17:47:55 +00:00
Wim Taymans
ca069974fc bluez5: avoid compiler warning 2023-11-16 10:35:33 +01:00
Pauli Virtanen
43af0645b7 bluez5: set BAP QoS RTN correctly
Set QoS RTN according to values supported by server values.
2023-11-14 22:08:23 +02:00
Pauli Virtanen
de9086481f bluez5: media-sink: set node.group for ISO group nodes
It's better to schedule nodes in the same ISO group together, since they
are supposed to produce synchronized output.
2023-11-12 18:48:25 +02:00
Pauli Virtanen
17c583bbe7 bluez5: iso-io: get proper group id for broadcast 2023-11-12 18:48:25 +02:00
Pauli Virtanen
b2e58198cc bluez5: make iso_io ISO groups transport-specific
Different BT adapters have separate ISO groups, so we should schedule
them separately.
2023-11-12 18:22:15 +02:00
Silviu Florian Barbulescu
e1fd73da66 Fix set state not seated on linked transport 2023-11-08 10:10:17 +02:00
Sam James
0e35750fde
spa: bluez: fix -Walloc-size
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>
2023-11-05 21:36:49 +00:00
Pauli Virtanen
b7e863b8cf bluez5: fix logic error in device set leader selection
Fix device set node sometimes not being emitted.

When leader changed it marked no-one as leader, do that in less buggy
way.
2023-10-24 19:45:03 +03:00
Pauli Virtanen
d121d273f0 bluez5: add more debug for device sets 2023-10-24 19:40:44 +03:00
Pauli Virtanen
528c7c0f22 bluez5: set BAP Locations/Context endpoint properties
BlueZ now requires endpoints to set Locations/Context, so set them to
some sensible default values. These could in principle be made
configurable later.
2023-10-21 13:38:27 +03:00
Pauli Virtanen
44a166c288 bluez5: use bigger fallback SCO mtu if kernel doesn't tell us
Use bigger fallback maximum MTU, when kernel fails to tell us, which
shouldn't happen but apparently can. We choose the packet size based on
incoming data, so these values aren't usually needed so we can just bump
them.

Also report errors as necessary.
2023-10-15 16:31:17 +00:00
Barnabás Pőcze
d2b5b53c08 spa: bluez: fix SBC encoder/decoder leak
`sbc_finish()` wasn't called on the msbc en/decoder of
sco-sink and sco-source. Fix that.
2023-10-06 13:07:16 +00:00
Pauli Virtanen
e71cf62b69 bluez5: adapt to further BAP API changes in BlueZ
BlueZ master BAP API is changing, so match our code to that.
2023-10-04 18:36:34 +03:00
Pauli Virtanen
bfcbeccec2 bluez5: adapt to changes in BlueZ BAP API
BlueZ master branch now puts various QoS fields into a separate dict, in
properties and method input and return values.

Adjust our code to match that.
2023-09-30 18:13:30 +00:00
Pauli Virtanen
a9cc3f2813 bluez5: deprioritize audio-gateway if remote is HFP HF + A2DP sink
If remote supports both HFP HF and AG, both may get connected, which
occurs with Pipewire<->Pipewire connection.  In this case, Pipewire on
both sides may pick the audio-gateway profile.

To avoid both sides being audio-gateway, if remote is both A2DP sink and
HF, use lower priority for the audio-gateway profile.  Generally, BlueZ
won't connect both A2DP Source and Sink between same devices at the same
time, so we use that to determine which side should be the receiver.
2023-09-24 15:45:33 +03:00
Pauli Virtanen
5f7afe588c bluez5: backend-native: fix codec handling with simultaneous HF & AG
It may occur that we have RFCOMM connected as both HF and AG.  The codec
switching and support checks should in this case always use the remote
HF RFCOMM.

Fix by finding the RFCOMM with the correct profile, remote as HF.
2023-09-24 15:45:33 +03:00
Barnabás Pőcze
06ba425378 treewide: use spa_assert_not_reached() instead of assert(false) 2023-09-16 17:50:25 +02:00