[AD] Add timeBeginPeriod(1) to wtimer.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi all, 

as already discussed in the forum, I would propose to change the current
implementation of tim_win32_rest in wtimer.c to the following: 

[code]
/* tim_win32_rest:
 *  Rests the specified amount of milliseconds.
 */
static void tim_win32_rest(unsigned int time, AL_METHOD(void, callback,
(void)))
{
   unsigned int start;
   unsigned int ms = time;

   const MMRESULT rc = timeBeginPeriod(1);
   if (callback) {
      start = timeGetTime();
      while (timeGetTime() - start < ms)
         (*callback)();
   }
   else {
      Sleep(ms);
   }
   if( rc == TIMERR_NOERROR )
     timeEndPeriod(1);
}
[/code]

The new lines are the call to timeBeginPeriod(1); and the correcponding call
to timeEndPeriod(1); in case the first call was successful. 

This affects only windows, and increases the accuracy of calls to rest(n). 

For the discussions, refer to the following threads: 

http://www.allegro.cc/forums/view_thread.php?_id=456146
http://www.allegro.cc/forums/view_thread.php?_id=453116

As this is my very first contribution, please forgive if anything is not in
the right format or otherwise unexpected. 

Thanks for consideration! 

Best regards Tobias 

-- 
http://www.staedtebauen.de




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/