From f9e93e95de429a1e30965e40b1527f100d072f3c Mon Sep 17 00:00:00 2001 From: meep-eep Date: Fri, 10 Jan 2003 22:37:24 +0000 Subject: [PATCH] Timing fixes, from fOSSiL. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@540 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c | 2 +- sc2/src/sc2code/libs/graphics/sdl/sdl_common.c | 2 +- sc2/src/sc2code/libs/sound/openal/stream.c | 2 +- sc2/src/sc2code/libs/threads/sdl/sdlthreads.c | 6 ++++++ sc2/src/sc2code/libs/threads/sdl/sdlthreads.h | 5 +++-- sc2/src/sc2code/planets/lander.c | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c b/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c index 2343f0f84..17976529b 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c +++ b/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c @@ -120,7 +120,7 @@ transition_task_func (void *data) for (;;) { - SleepThread (10); + SDL_Delay (10); current_time = SDL_GetTicks (); delta_time = current_time - last_time; diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 21d7063da..8408e8658 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -528,7 +528,7 @@ TFB_FlushGraphics () // Only call from main thread!! } else { - SleepThread (1); + TaskSwitch (); } last_fade = current_fade; diff --git a/sc2/src/sc2code/libs/sound/openal/stream.c b/sc2/src/sc2code/libs/sound/openal/stream.c index 0eb79659f..b9b510750 100644 --- a/sc2/src/sc2code/libs/sound/openal/stream.c +++ b/sc2/src/sc2code/libs/sound/openal/stream.c @@ -161,7 +161,7 @@ StreamDecoderTaskFunc (void *data) { int i; - SleepThread (1); + TaskSwitch (); for (i = MUSIC_SOURCE; i < NUM_SOUNDSOURCES; ++i) { diff --git a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c index e905e487f..ddf67fc6e 100644 --- a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c +++ b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c @@ -45,6 +45,12 @@ SDLWrapper_PrintThreadStats (SDL_Thread *thread) { } #endif +void +SDLWrapper_SleepThread (TimeCount sleepTime) +{ + SDL_Delay (sleepTime * 1000 / ONE_SECOND); +} + void SDLWrapper_SleepThreadUntil (TimeCount wakeTime) { TimeCount now; diff --git a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h index 03c2c4a0b..deef2c8a4 100644 --- a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h +++ b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h @@ -33,8 +33,9 @@ typedef int (*NativeThreadFunction) (void *); SDL_CreateThread ((func), (data)) #define NativeKillThread(thread) \ SDL_KillThread ((thread)) -#define NativeSleepThread(ms) \ - SDL_Delay ((ms)) +extern void SDLWrapper_SleepThread (TimeCount sleepTime); +#define NativeSleepThread(sleepTime) \ + SDLWrapper_SleepThread ((sleepTime)) extern void SDLWrapper_SleepThreadUntil (TimeCount wakeTime); #define NativeSleepThreadUntil(wakeTime) \ SDLWrapper_SleepThreadUntil ((wakeTime)) diff --git a/sc2/src/sc2code/planets/lander.c b/sc2/src/sc2code/planets/lander.c index 1da11bd87..3ab110d87 100644 --- a/sc2/src/sc2code/planets/lander.c +++ b/sc2/src/sc2code/planets/lander.c @@ -1462,7 +1462,7 @@ InitPlanetSide (void) #ifdef SPIN_ON_LAUNCH pSolarSysState->PauseRotate = 1; ClearSemaphore (GraphicsSem); - SleepThread (1); + TaskSwitch (); SetSemaphore (GraphicsSem); #endif // Adjust pSolarSysState->MenuState.first_item by a random jitter.