bluez5: sco-io: start writing only after the packet size is known

The kernel-provided SCO write MTU is currently never the correct packet
size for writing, so don't try to use it. Some adapter firmware (eg.
BCM20702A0 0b05:17cb) appears in practice sensitive to the alignment of
the msbc frames, and writes with wrong packet size break things but only
on certain headsets. For other adapters, this doesn't appear to matter.
This commit is contained in:
Pauli Virtanen 2021-07-11 16:43:17 +03:00 committed by Wim Taymans
parent 579481ab70
commit 0c9f0210ed

View file

@ -186,8 +186,12 @@ int spa_bt_sco_io_write(struct spa_bt_sco_io *io, uint8_t *buf, int size)
uint16_t packet_size;
uint8_t *buf_start = buf;
packet_size = (io->read_size > 0) ? SPA_MIN(io->write_mtu, io->read_size) : (io->write_mtu / 2) * 2;
spa_assert(packet_size > 0);
if (io->read_size == 0) {
/* The proper write packet size is not known yet */
return 0;
}
packet_size = SPA_MIN(io->write_mtu, io->read_size);
if (size < packet_size) {
return 0;