Author: titmuss
Date: Mon Jul  7 08:52:43 2008
New Revision: 2667

URL: http://svn.slimdevices.com?rev=2667&root=Jive&view=rev
Log:
Bug: N/A
Description:
Fix another problem with SDL timers. The timer callback is not fully 
re-entrant, and if the timer interval==0 this could lead
to timers being lost. Now if a timer is set with interval==0 then it is treated 
as a single shot timer, and an interval=1 is 
sent to SDL.


Modified:
    7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
    7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_timer.c
    7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_utils.c

Modified: 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
URL: 
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h?rev=2667&root=Jive&r1=2666&r2=2667&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h (original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h Mon Jul  7 08:52:43 2008
@@ -263,6 +263,7 @@
 
 /* Util functions */
 void jive_print_stack(lua_State *L, char *str);
+void jive_debug_traceback(lua_State *L, int n);
 int jiveL_getframework(lua_State *L);
 int jive_getmethod(lua_State *L, int index, char *method) ;
 void *jive_getpeer(lua_State *L, int index, JivePeerMeta *peerMeta);

Modified: 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_timer.c
URL: 
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_timer.c?rev=2667&root=Jive&r1=2666&r2=2667&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_timer.c (original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_timer.c Mon Jul  7 
08:52:43 2008
@@ -4,9 +4,10 @@
 ** This file is subject to the Logitech Public Source License Version 1.0. 
Please see the LICENCE file for details.
 */
 
+//#define RUNTIME_DEBUG 1
+
 #include "common.h"
 #include "jive.h"
-
 
 typedef struct {
        SDL_TimerID timerId;
@@ -76,6 +77,7 @@
 
        /* if this timer is called once then unref the _timerData */
        if (data && data->once) {
+               DEBUG_TRACE("RM ONCE TIMER %p: id=%p ref=%ld", lua_topointer(L, 
-1), data->timerId, data->ref);
                SDL_RemoveTimer(data->timerId);
                luaL_unref(L, LUA_REGISTRYINDEX, data->ref);
 
@@ -132,9 +134,18 @@
        lua_getfield(L, 1, "interval");
        interval = lua_tointeger(L, -1);
 
+       /* If the interval is 0 treat this as a single shot timer. */
+       if (interval == 0) {
+               interval = 1;
+               data->once = 1;
+       }
+
        lua_pushvalue(L, 1);
        data->ref = luaL_ref(L, LUA_REGISTRYINDEX);
        data->timerId = SDL_AddTimer(interval, &timer_callback, data);
+
+       DEBUG_TRACE("ADD TIMER %p: id=%p ref=%ld int=%d once=%d", 
lua_topointer(L, 1), data->timerId, data->ref, interval, data->once);
+
        data->busy = 0;
 
        return 0;
@@ -155,6 +166,9 @@
        }
 
        data = (TimerData *) lua_touserdata(L, -1);
+
+       DEBUG_TRACE("RM TIMER %p: id=%p ref=%ld", lua_topointer(L, 1), 
data->timerId, data->ref);
+
        SDL_RemoveTimer(data->timerId);
        luaL_unref(L, LUA_REGISTRYINDEX, data->ref);
 

Modified: 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_utils.c
URL: 
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_utils.c?rev=2667&root=Jive&r1=2666&r2=2667&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_utils.c (original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/src/ui/jive_utils.c Mon Jul  7 
08:52:43 2008
@@ -44,6 +44,19 @@
        }
 }
 
+
+void jive_debug_traceback(lua_State *L, int n) {
+       JIVEL_STACK_CHECK_BEGIN(L);
+
+       lua_getglobal(L, "debug");
+       lua_getfield(L, -1, "traceback");
+       lua_call(L, 0, 1);
+
+       printf("debug.traceback:%s\n", lua_tostring(L, -1));
+       lua_pop(L, 2);
+
+       JIVEL_STACK_CHECK_END(L);
+}
 
 int jiveL_getframework(lua_State *L) {
        lua_getglobal(L, "jive");

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to