From cadfcf6c7dd5d5f6e8b5a2fe3a1d3dd9e24b96ef Mon Sep 17 00:00:00 2001 From: Stephen Sinclair Date: Fri, 14 Sep 2018 15:58:02 +0200 Subject: [PATCH] alsa: further fix timestamp overflows Implicit conversion to unsigned, thanks again @jpcima --- RtMidi.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RtMidi.cpp b/RtMidi.cpp index 778e7c6f..0364291b 100644 --- a/RtMidi.cpp +++ b/RtMidi.cpp @@ -1611,18 +1611,18 @@ static void *alsaMidiHandler( void *ptr ) y.tv_nsec = apiData->lastTime.tv_nsec; y.tv_sec = apiData->lastTime.tv_sec; if (x.tv_nsec < y.tv_nsec) { - int nsec = (y.tv_nsec - x.tv_nsec) / 1000000000 + 1; + int nsec = (y.tv_nsec - (int)x.tv_nsec) / 1000000000 + 1; y.tv_nsec -= 1000000000 * nsec; y.tv_sec += nsec; } if (x.tv_nsec - y.tv_nsec > 1000000000) { - int nsec = (x.tv_nsec - y.tv_nsec) / 1000000000; + int nsec = ((int)x.tv_nsec - y.tv_nsec) / 1000000000; y.tv_nsec += 1000000000 * nsec; y.tv_sec -= nsec; } // Compute the time difference. - time = x.tv_sec - y.tv_sec + (x.tv_nsec - y.tv_nsec)*1e-9; + time = (int)x.tv_sec - y.tv_sec + ((int)x.tv_nsec - y.tv_nsec)*1e-9; apiData->lastTime = ev->time.time;