Skip to content

Commit

Permalink
alsa: further fix timestamp overflows
Browse files Browse the repository at this point in the history
Implicit conversion to unsigned, thanks again @jpcima
  • Loading branch information
radarsat1 committed Sep 14, 2018
1 parent e9d4ff6 commit cadfcf6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions RtMidi.cpp
Expand Up @@ -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;

Expand Down

0 comments on commit cadfcf6

Please sign in to comment.