From 924eb347a9e1ea84e9c880edfb585fbf17bb6596 Mon Sep 17 00:00:00 2001 From: borine <32966433+borine@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:29:25 +0000 Subject: [PATCH] Filter internal delay D-Bus signals Only emit D-Bus delay signal for internal processing delays if the change is >= 10ms --- src/ba-transport-pcm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ba-transport-pcm.c b/src/ba-transport-pcm.c index 01947922a..18c36198d 100644 --- a/src/ba-transport-pcm.c +++ b/src/ba-transport-pcm.c @@ -783,16 +783,17 @@ int ba_transport_pcm_delay_sync(struct ba_transport_pcm *pcm, unsigned int updat } } - else { - if (pcm->mode == BA_TRANSPORT_PCM_MODE_SINK && - update_mask == BA_DBUS_PCM_UPDATE_DELAY) { + + /* If the remote device does not provide delay update reports we can still + * inform local D-Bus clients of our internal processing delay. */ + if ((t->profile & BA_TRANSPORT_PROFILE_MASK_A2DP) == 0 || + !t->a2dp.delay_reporting) { + + if (update_mask == BA_DBUS_PCM_UPDATE_DELAY) { + /* To avoid creating a flood of dbus signals, we only notify clients * when the codec + processing value changes by more than 10ms */ - unsigned int delay = 0; - if (t->profile == BA_TRANSPORT_PROFILE_A2DP_SOURCE) - delay += t->a2dp.delay; - - delay += t->pcm->codec_delay_dms + pcm->processing_delay_dms; + unsigned int delay = pcm->codec_delay_dms + pcm->processing_delay_dms; unsigned int diff = delay >= pcm->reported_codec_delay_dms ? delay - pcm->reported_codec_delay_dms : pcm->reported_codec_delay_dms - delay;