ecore-x vsync tool. fix multi-client handling so ticking continues

a mistaking in using the wrong tick var caused ticking to stop when a
client that is ticking exits while another ticks. this fixes it.
This commit is contained in:
Carsten Haitzler 2014-08-02 13:15:14 +09:00
parent aad0192a89
commit 812494ca58
1 changed files with 37 additions and 23 deletions

View File

@ -38,14 +38,15 @@ typedef struct
char val; char val;
} Msg; } Msg;
static int tick = 0;
static Eina_Thread_Queue *thq = NULL; static Eina_Thread_Queue *thq = NULL;
static volatile int ticking = 0;
static void static void
_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread) _tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
{ {
Msg *msg; Msg *msg;
void *ref; void *ref;
int tick = 0;
for (;;) for (;;)
{ {
@ -60,14 +61,16 @@ _tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
} }
else else
{ {
again: do
msg = eina_thread_queue_poll(thq, &ref);
if (msg)
{ {
tick = msg->val; msg = eina_thread_queue_poll(thq, &ref);
eina_thread_queue_wait_done(thq, ref); if (msg)
{
tick = msg->val;
eina_thread_queue_wait_done(thq, ref);
}
} }
if (msg) goto again; while (msg);
} }
if (tick == -1) exit(0); if (tick == -1) exit(0);
if (tick) if (tick)
@ -78,7 +81,17 @@ again:
if (t) if (t)
{ {
*t = _vsync_wait(); *t = _vsync_wait();
ecore_thread_feedback(thread, t); do
{
msg = eina_thread_queue_poll(thq, &ref);
if (msg)
{
tick = msg->val;
eina_thread_queue_wait_done(thq, ref);
}
}
while (msg);
if (tick) ecore_thread_feedback(thread, t);
} }
} }
} }
@ -91,6 +104,9 @@ _tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg
if (t) if (t)
{ {
static double pt = 0.0;
pt = *t;
_svr_broadcast_time(*t); _svr_broadcast_time(*t);
free(t); free(t);
} }
@ -117,16 +133,16 @@ _tick_send(char val)
static void static void
_tick_start(void) _tick_start(void)
{ {
tick++; ticking++;
if (tick == 1) _tick_send(1); if (ticking == 1) _tick_send(1);
} }
static void static void
_tick_end(void) _tick_end(void)
{ {
if (tick <= 0) return; if (ticking <= 0) return;
tick--; ticking--;
if (tick == 0) _tick_send(0); if (ticking == 0) _tick_send(0);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
@ -197,21 +213,19 @@ _svr_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{ {
char *dat = ev->data; char *dat = ev->data;
int i; int i;
int penabled = cdat->enabled;
for (i = 0; i < ev->size; i++) for (i = 0; i < ev->size; i++)
{ {
if (dat[i]) if (dat[i]) cdat->enabled++;
else if (cdat->enabled > 0) cdat->enabled--;
}
if (ev->size > 0)
{
if (penabled != cdat->enabled)
{ {
cdat->enabled++;
if (cdat->enabled == 1) _tick_start(); if (cdat->enabled == 1) _tick_start();
} else if (cdat->enabled == 0) _tick_end();
else
{
if (cdat->enabled > 0)
{
cdat->enabled--;
if (cdat->enabled == 0) _tick_end();
}
} }
} }
} }