From 459a1114f198d292bfc0d407a7750d18631eb3ab Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 19 Jun 2022 03:06:16 +0300 Subject: [PATCH] bluez5: sco-io: we should always read from socket Not reading from the socket appears to cause messages to pile up to some limit, which causes problems if we start the source after some point. --- spa/plugins/bluez5/sco-io.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/spa/plugins/bluez5/sco-io.c b/spa/plugins/bluez5/sco-io.c index 0b399e910..065775076 100644 --- a/spa/plugins/bluez5/sco-io.c +++ b/spa/plugins/bluez5/sco-io.c @@ -55,16 +55,12 @@ * since kernel might not report it as the socket MTU, see * https://lore.kernel.org/linux-bluetooth/20201210003528.3pmaxvubiwegxmhl@pali/T/ * - * Since 24 is the packet size for the smallest setting (ALT1), we'll stop - * reading when rx packet of at least this size is seen, and use its size as the - * heuristic maximum write MTU. Of course, if we have a source connected, we'll - * continue reading without stopping. + * We continue reading also when there's no source connected, to keep socket + * flushed. * * XXX: when the kernel/backends start giving the right values, the heuristic * XXX: can be removed */ -#define HEURISTIC_MIN_MTU 24 - #define MAX_MTU 1024 @@ -94,12 +90,6 @@ static void update_source(struct spa_bt_sco_io *io) int enabled; int changed = 0; - enabled = io->source_cb != NULL || io->read_size < HEURISTIC_MIN_MTU; - if (SPA_FLAG_IS_SET(io->source.mask, SPA_IO_IN) != enabled) { - SPA_FLAG_UPDATE(io->source.mask, SPA_IO_IN, enabled); - changed = 1; - } - enabled = io->sink_cb != NULL; if (SPA_FLAG_IS_SET(io->source.mask, SPA_IO_OUT) != enabled) { SPA_FLAG_UPDATE(io->source.mask, SPA_IO_OUT, enabled); @@ -118,11 +108,6 @@ static void sco_io_on_ready(struct spa_source *source) if (SPA_FLAG_IS_SET(source->rmask, SPA_IO_IN)) { int res; - /* - * Note that we will read from the socket for a few times even - * when there is no source callback, to autodetect packet size. - */ - read_again: res = read(io->fd, io->read_buffer, SPA_MIN(io->read_mtu, MAX_MTU)); if (res <= 0) {