From 5082e9f45893a0b8805f09211e4688f4829e1cf8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 15 Feb 2024 17:48:58 +0100 Subject: [PATCH] module-rtp: only stop timer when it was running --- src/modules/module-rtp/audio.c | 3 ++- src/modules/module-rtp/stream.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/module-rtp/audio.c b/src/modules/module-rtp/audio.c index ae03d005a..b9153718f 100644 --- a/src/modules/module-rtp/audio.c +++ b/src/modules/module-rtp/audio.c @@ -201,6 +201,7 @@ static void set_timer(struct impl *impl, uint64_t time, uint64_t itime) ts.it_interval.tv_nsec = itime % SPA_NSEC_PER_SEC; spa_system_timerfd_settime(impl->data_loop->system, impl->timer->fd, SPA_FD_TIMER_ABSTIME, &ts, NULL); + impl->timer_running = time != 0 && itime != 0; } static inline void @@ -263,7 +264,7 @@ static void rtp_audio_flush_packets(struct impl *impl, uint32_t num_packets) } spa_ringbuffer_read_update(&impl->ring, timestamp); done: - if (avail < tosend) + if (avail < tosend && impl->timer_running) set_timer(impl, 0, 0); } diff --git a/src/modules/module-rtp/stream.c b/src/modules/module-rtp/stream.c index 7bc2a9e51..e0aa64498 100644 --- a/src/modules/module-rtp/stream.c +++ b/src/modules/module-rtp/stream.c @@ -87,6 +87,7 @@ struct impl { struct pw_loop *data_loop; struct spa_source *timer; + bool timer_running; int (*receive_rtp)(struct impl *impl, uint8_t *buffer, ssize_t len); void (*flush_timeout)(struct impl *impl, uint64_t expirations);