From 30766b34bde9af1168f5e0355d64a904b3660fd1 Mon Sep 17 00:00:00 2001 From: arancormonk <180709949+arancormonk@users.noreply.github.com> Date: Wed, 3 Sep 2025 14:21:50 -0500 Subject: [PATCH] rtl_sdr_fm: fix timespec normalization in timed wait --- src/rtl_sdr_fm.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rtl_sdr_fm.cpp b/src/rtl_sdr_fm.cpp index f78aaa9..065aca3 100644 --- a/src/rtl_sdr_fm.cpp +++ b/src/rtl_sdr_fm.cpp @@ -259,7 +259,11 @@ static int ring_read_one(struct output_state *o, int16_t *out) while (ring_is_empty(o)) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_nsec += 10e6; /* 10ms */ + ts.tv_nsec += 10L * 1000000L; /* 10ms */ + if (ts.tv_nsec >= 1000000000L) { + ts.tv_sec += ts.tv_nsec / 1000000000L; + ts.tv_nsec = ts.tv_nsec % 1000000000L; + } pthread_mutex_lock(&o->ready_m); pthread_cond_timedwait(&o->ready, &o->ready_m, &ts); pthread_mutex_unlock(&o->ready_m);