SDL timers

Plataform: SDL running on Windows XP or Vista.
SDL version: 1.2.13 compiled as static library ( .LIB ) and linked.
Compiler: Open Watcom C/C++ 1.7 or 1.7.

I am using a timer in a process that is used as a toolbar of other process that
is the master application. They communicate with inter-process communications
techniques (mutex + memory mapped file as shared memory) common in Windows.

It worked ok but if a left the machine without activity for several hours (more
than 3, +/- ) the sdl timer looks to stop calling the callback function. Is
there any limit for the continuous use of a timer ? The delay used was 15 ms .

The most relevant part of the code follows :

static unsigned int __cdecl TimerCallBack(Uint32 interval, void *param)
{
PushUserEvent(IPC_TIMER); //call to SDL_PushEvent(SDL_Event *event)
return(interval);
}

int ipc_AddTimer(int ms)
{
tid = SDL_AddTimer(ms, TimerCallBack, NULL );
if (tid == NULL)
return 0;
else
return 1;
}

Thanks ,
Armando Alaminos Bouza

sorry …

Compiler: Open Watcom C/C++ 1.7 or 1.8.> Compiler: Open Watcom C/C++ 1.7 or 1.7.

SDL version: 1.2.13 ?compiled as static library ?( .LIB ) and linked.

Keep in mind that you are required to distribute your source code or
dynamically linked binaries under the terms of the GNU LGPL.

I am using a timer in a process that is used as a toolbar of other process that
is the master application. ?They communicate with inter-process communications
techniques (mutex + memory mapped file as shared memory) common in Windows.

It worked ok but if a left the machine without activity for several hours (more
than 3, +/- ) the sdl timer looks to stop calling the callback function. Is
there any limit for the continuous use of a timer ? ?The delay used was 15 ms .

Sounds like a bug. Perhaps you are overflowing your event queue or
suffering some kind of deadlock condition. I would do some more
investigation to find out what might be going wrong, but I think your
problem is simpler than that: your program design is silly.

What would you need to update more often than 60 times a second for
some kind of toolbar? If you really require that your application
performs an action every 15 ms, your current technique will not be
particularly reliable in the short term, due to the overhead
introduced by locking the event queue.

If you used SDL 1.3, then rather than using a timer and delivering a
message to the SDL event queue, you could instead use
SDL_WaitEventTimeout(), which would allow you to wait for events like
input from the user, but which would return after a specified amount
of time even if no event has arrived. Will this help you?On Fri, Mar 27, 2009 at 8:04 AM, Armando Alaminos Bouza wrote:


http://codebad.com/

Dear Donny,

Thanks for your hints !

You are right regarding the interval, i could do it 20 times per sec
(50 ms), and will do that.

But I suspected of the timer because if it is changed by a SDL_Delay(15)
(or Sleep(15) ) followed by reading the event queue, the problem vanished.

Of course, the availability of SDL_WaitEventTimeout() could be great.
May we consider LibSDL 1.3 stable ? There is no mention to 1.3 in
the URL i check (http://www.libsdl.org/download-1.2.php ).

If 1.3 is not stable i could write my own version of
SDL_WaitEventTimeout() until it is available.

Thanks again,
Armando.