Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values.

Went through the code and used the macro and fixed a couple places that were using incorrect timestamp comparisons.
This commit is contained in:
Sam Lantinga 2013-10-20 20:42:55 -07:00
parent 84561c952a
commit 367ffcc3af
12 changed files with 23 additions and 21 deletions

View file

@ -220,7 +220,7 @@ static int
ARTS_Suspend(void)
{
const Uint32 abortms = SDL_GetTicks() + 3000; /* give up after 3 secs */
while ( (!SDL_NAME(arts_suspended)()) && (SDL_GetTicks() < abortms) ) {
while ( (!SDL_NAME(arts_suspended)()) && !SDL_TICKS_PASSED(SDL_GetTicks(), abortms) ) {
if ( SDL_NAME(arts_suspend)() ) {
break;
}

View file

@ -125,9 +125,7 @@ BSDAUDIO_WaitDevice(_THIS)
/* Use timer for general audio synchronization */
Sint32 ticks;
ticks =
((Sint32) (this->hidden->next_frame - SDL_GetTicks())) -
FUDGE_TICKS;
ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
if (ticks > 0) {
SDL_Delay(ticks);
}

View file

@ -135,8 +135,7 @@ ESD_WaitDevice(_THIS)
}
/* Use timer for general audio synchronization */
ticks =
((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
if (ticks > 0) {
SDL_Delay(ticks);
}

View file

@ -133,9 +133,7 @@ PAUDIO_WaitDevice(_THIS)
/* Use timer for general audio synchronization */
Sint32 ticks;
ticks =
((Sint32) (this->hidden->next_frame - SDL_GetTicks())) -
FUDGE_TICKS;
ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
if (ticks > 0) {
SDL_Delay(ticks);
}