From f1d9b2317cee870cacd9d9f08d85a603e7f0e40c Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 21 Dec 2020 01:54:34 +0200 Subject: [PATCH] sco-sink: adjust data flush timeout for msbc according to packet size Instead of using a hardcoded value for the minimum delay between writes, select it according to the mtu/packet size that is currently used. This is necessary for correct playback with lower mtu values. --- spa/plugins/bluez5/sco-sink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index 8c6a5d84d..316bcff7f 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -401,8 +401,12 @@ next_write: processed = written; next_timeout = get_next_timeout(this, now_time, processed / port->frame_size); - if (this->transport->codec == HFP_AUDIO_CODEC_MSBC && next_timeout < 7500000) - next_timeout = 7500000; + + if (this->transport->codec == HFP_AUDIO_CODEC_MSBC) { + uint64_t min_delay = (this->transport->write_mtu / port->frame_size + * SPA_NSEC_PER_SEC / port->current_format.info.raw.rate); + next_timeout = SPA_MAX(next_timeout, min_delay); + } if (this->clock) { this->clock->nsec = now_time;