module-rtp: only stop timer when it was running

This commit is contained in:
Wim Taymans 2024-02-15 17:48:58 +01:00
parent 49e7e3a0f0
commit 5082e9f458
2 changed files with 3 additions and 1 deletions

View file

@ -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);
}

View file

@ -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);