gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/gui sdl.cpp


From: Vitaly Alexeev
Subject: [Gnash-commit] gnash/gui sdl.cpp
Date: Mon, 18 Sep 2006 13:43:53 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Vitaly Alexeev <alexeev>        06/09/18 13:43:53

Modified files:
        gui            : sdl.cpp 

Log message:
        Don't hog the CPU.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl.cpp?cvsroot=gnash&r1=1.18&r2=1.19

Patches:
Index: sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/sdl.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- sdl.cpp     25 Aug 2006 14:21:11 -0000      1.18
+++ sdl.cpp     18 Sep 2006 13:43:52 -0000      1.19
@@ -113,24 +113,21 @@
     int button_state_old = -1;
 
     SDL_Event  event;
-    while (true) {
+       while (true)
+       {
 
-       if (_timeout && SDL_GetTicks() >= _timeout) {
+               if (_timeout && SDL_GetTicks() >= _timeout)
+               {
                break;
        }
 
        Uint32 start_tick = SDL_GetTicks();
 
-       if ( _func ) _func(this);
-
-       Uint32 time_left = SDL_GetTicks()-start_tick;
-
-       // Poll events until it's time for next movie advance
-       while ( (SDL_GetTicks()-start_tick) < _interval )
+               while (true)
        {
                if (SDL_PollEvent(&event) == 0)
                {
-                       continue;
+                               break;
                }
 
                switch (event.type)
@@ -177,11 +174,17 @@
             return true;
           break;
                }
-
        }
 
-    }
+               if ( _func ) _func(this);
 
+               int delay = _interval - (SDL_GetTicks() - start_tick);
+               if (delay < 0)
+               {
+                       delay = 0;
+               }
+               SDL_Delay(delay);
+       }
     return false;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]