From 18f09fd09d4b673239904a7c9d9b160d38620153 Mon Sep 17 00:00:00 2001 From: pelya Date: Tue, 19 Jun 2012 13:11:13 +0300 Subject: [PATCH] Another fix for compatibility hacks for MilkyTracker --- .../src/video/android/SDL_androidvideo-1.2.c | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c index eccaf4cb7..7aaefd448 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c @@ -1144,15 +1144,18 @@ void SDL_ANDROID_MultiThreadedVideoLoopInit() void SDL_ANDROID_MultiThreadedVideoLoop() { + int lastUpdate = SDL_GetTicks(); // For compat mode + int nextUpdateDelay = 100; // For compat mode while(1) { int signalNeeded = 0; int swapBuffersNeeded = 0; int ret; + int currentTime; SDL_mutexP(videoThread.mutex); videoThread.threadReady = 1; SDL_CondSignal(videoThread.cond2); - ret = SDL_CondWaitTimeout(videoThread.cond, videoThread.mutex, SDL_ANDROID_CompatibilityHacks ? 100 : 1000); + ret = SDL_CondWaitTimeout(videoThread.cond, videoThread.mutex, SDL_ANDROID_CompatibilityHacks ? nextUpdateDelay : 1000); if( videoThread.execute ) { videoThread.threadReady = 0; @@ -1169,14 +1172,28 @@ void SDL_ANDROID_MultiThreadedVideoLoop() ANDROID_VideoQuit(videoThread._this); break; case CMD_UPDATERECTS: - if( ! SDL_ANDROID_CompatibilityHacks ) // DIRTY HACK for MilkyTracker + if( SDL_ANDROID_CompatibilityHacks ) // DIRTY HACK for MilkyTracker - DO NOT update screen when application requests that, update 50 ms later + { + if( nextUpdateDelay >= 100 ) + nextUpdateDelay = 50; + else + nextUpdateDelay = lastUpdate + 50 - (int)SDL_GetTicks(); + } + else { ANDROID_FlipHWSurfaceInternal(videoThread.numrects, videoThread.rects); swapBuffersNeeded = 1; } break; case CMD_FLIP: - if( ! SDL_ANDROID_CompatibilityHacks ) // DIRTY HACK for MilkyTracker + if( SDL_ANDROID_CompatibilityHacks ) // DIRTY HACK for MilkyTracker - DO NOT update screen when application requests that, update 50 ms later + { + if( nextUpdateDelay >= 100 ) + nextUpdateDelay = 50; + else + nextUpdateDelay = lastUpdate + 50 - (int)SDL_GetTicks(); + } + else { ANDROID_FlipHWSurfaceInternal(0, NULL); swapBuffersNeeded = 1; @@ -1186,10 +1203,13 @@ void SDL_ANDROID_MultiThreadedVideoLoop() videoThread.execute = 0; signalNeeded = 1; } - else if( SDL_ANDROID_CompatibilityHacks && ret == SDL_MUTEX_TIMEDOUT && SDL_CurrentVideoSurface ) + if( SDL_ANDROID_CompatibilityHacks && SDL_CurrentVideoSurface && + ( ret == SDL_MUTEX_TIMEDOUT || nextUpdateDelay <= 0 ) ) { ANDROID_FlipHWSurfaceInternal(0, NULL); swapBuffersNeeded = 1; + lastUpdate = SDL_GetTicks(); + nextUpdateDelay = 100; } SDL_mutexV(videoThread.mutex); if( signalNeeded )