bluetooth: Allow SCO socket packet size to be larger than mSBC frame

With USB Alternate Setting 3 size of HCI payload is 72 bytes which is already
larger than mSBC frame size. Largest known size of HCI payload is with USB
Alternate Setting 5 (144 bytes), make it the default SCO socket MTU.

Reserve additional space in bluetooth encoder buffer to cover this case.

Since mSBC encoder and decoder will now work with larger packet sizes, drop
assertions about MTU larger than mSBC frame size.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/617>
This commit is contained in:
Igor V. Kovalenko 2021-07-25 23:41:36 +03:00 committed by PulseAudio Marge Bot
parent ade71b8ce7
commit d517a204de
3 changed files with 44 additions and 14 deletions

View file

@ -329,8 +329,18 @@ static int sco_acquire_cb(pa_bluetooth_transport *t, bool optional, size_t *imtu
if (sock < 0)
goto fail;
if (imtu) *imtu = 60;
if (omtu) *omtu = 60;
/* The correct block size should take into account the SCO MTU from
* the Bluetooth adapter and (for adapters in the USB bus) the MxPS
* value from the Isoc USB endpoint in use by btusb and should be
* made available to userspace by the Bluetooth kernel subsystem.
*
* Set initial MTU to max known payload length of HCI packet
* in USB Alternate Setting 5 (144 bytes)
* See also pa_bluetooth_transport::last_read_size handling
* and comment about MTU size in bt_prepare_encoder_buffer()
*/
if (imtu) *imtu = 144;
if (omtu) *omtu = 144;
if (t->device->autodetect_mtu) {
struct sco_options sco_opt;
@ -347,11 +357,6 @@ static int sco_acquire_cb(pa_bluetooth_transport *t, bool optional, size_t *imtu
}
}
/* read/decode machinery only works if we get at most one MSBC encoded packet at a time
* when it is fixed to process stream of packets, lift this assertion */
pa_assert(*imtu <= MSBC_PACKET_SIZE);
pa_assert(*omtu <= MSBC_PACKET_SIZE);
return sock;
fail: