From 99d5436f15408f278e39584087c02037b3940dc8 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Thu, 23 Feb 2023 22:01:53 +0200 Subject: [PATCH] bluez5: media-sink: write packets exactly on time Delay output by one packet, so that we never need to wait for node_process to supply more data when a packet is due out, and can write audio packets at exactly equal intervals (up to timer/io accuracy). In principle, this should not be necessary. However, enable it for now, in case this improves the various stutter/etc. bug reports. --- spa/plugins/bluez5/media-sink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spa/plugins/bluez5/media-sink.c b/spa/plugins/bluez5/media-sink.c index 3cee50ad7..56149a210 100644 --- a/spa/plugins/bluez5/media-sink.c +++ b/spa/plugins/bluez5/media-sink.c @@ -754,13 +754,16 @@ again: / port->current_format.info.raw.rate); /* - * We could delay the output by one packet to avoid waiting + * We can delay the output by one packet to avoid waiting * for the next buffer and so make send intervals exactly regular. * However, this is not needed for A2DP or BAP. The controller * will do the scheduling for us, and there's also the socket buffer * in between. + * + * Although in principle this should not be needed, we + * do it regardless in case it helps. */ -#if 0 +#if 1 this->next_flush_time += SPA_MIN(packet_time, duration_ns * (port->n_buffers - 1)); #endif