Commit c159f79f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: privatize vlc_timer layout too

parent 5dc04132
...@@ -134,14 +134,7 @@ typedef struct ...@@ -134,14 +134,7 @@ typedef struct
} vlc_rwlock_t; } vlc_rwlock_t;
typedef DWORD vlc_threadvar_t; typedef DWORD vlc_threadvar_t;
typedef struct vlc_timer_t vlc_timer_t; typedef struct vlc_timer *vlc_timer_t;
struct vlc_timer_t
{
HANDLE handle;
void (*func) (void *);
void *data;
};
#endif #endif
#if defined( WIN32 ) && !defined ETIMEDOUT #if defined( WIN32 ) && !defined ETIMEDOUT
......
...@@ -601,35 +601,52 @@ void vlc_control_cancel (int cmd, ...) ...@@ -601,35 +601,52 @@ void vlc_control_cancel (int cmd, ...)
/*** Timers ***/ /*** Timers ***/
struct vlc_timer
{
HANDLE handle;
void (*func) (void *);
void *data;
};
static void CALLBACK vlc_timer_do (void *val, BOOLEAN timeout) static void CALLBACK vlc_timer_do (void *val, BOOLEAN timeout)
{ {
vlc_timer_t *id = val; struct vlc_timer *timer = val;
assert (timeout); assert (timeout);
id->func (id->data); timer->func (timer->data);
} }
int vlc_timer_create (vlc_timer_t *id, void (*func) (void *), void *data) int vlc_timer_create (vlc_timer_t *id, void (*func) (void *), void *data)
{ {
id->func = func; struct vlc_timer *timer = malloc (sizeof (*timer));
id->data = data;
id->handle = INVALID_HANDLE_VALUE; if (timer == NULL)
return ENOMEM;
timer->func = func;
timer->data = data;
timer->handle = INVALID_HANDLE_VALUE;
*id = timer;
return 0; return 0;
} }
void vlc_timer_destroy (vlc_timer_t *id) void vlc_timer_destroy (vlc_timer_t *id)
{ {
if (id->handle != INVALID_HANDLE_VALUE) struct vlc_timer *timer = *id;
DeleteTimerQueueTimer (NULL, id->handle, INVALID_HANDLE_VALUE);
if (timer->handle != INVALID_HANDLE_VALUE)
DeleteTimerQueueTimer (NULL, timer->handle, INVALID_HANDLE_VALUE);
free (timer);
} }
void vlc_timer_schedule (vlc_timer_t *id, bool absolute, void vlc_timer_schedule (vlc_timer_t *id, bool absolute,
mtime_t value, mtime_t interval) mtime_t value, mtime_t interval)
{ {
if (id->handle != INVALID_HANDLE_VALUE) struct vlc_timer *timer = *id;
if (timer->handle != INVALID_HANDLE_VALUE)
{ {
DeleteTimerQueueTimer (NULL, id->handle, NULL); DeleteTimerQueueTimer (NULL, timer->handle, NULL);
id->handle = INVALID_HANDLE_VALUE; timer->handle = INVALID_HANDLE_VALUE;
} }
if (value == 0) if (value == 0)
return; /* Disarm */ return; /* Disarm */
...@@ -638,8 +655,8 @@ void vlc_timer_schedule (vlc_timer_t *id, bool absolute, ...@@ -638,8 +655,8 @@ void vlc_timer_schedule (vlc_timer_t *id, bool absolute,
value -= mdate (); value -= mdate ();
value = (value + 999) / 1000; value = (value + 999) / 1000;
interval = (interval + 999) / 1000; interval = (interval + 999) / 1000;
if (!CreateTimerQueueTimer (&id->handle, NULL, vlc_timer_do, id, value, if (!CreateTimerQueueTimer (&timer->handle, NULL, vlc_timer_do, timer,
interval, WT_EXECUTEDEFAULT)) value, interval, WT_EXECUTEDEFAULT))
abort (); abort ();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment