]> git.sesse.net Git - vlc/blobdiff - include/vlc_threads.h
Asynchronous timer API
[vlc] / include / vlc_threads.h
index 7ccafbbafce2890e507139c7ddee0bb4348df89e..d6535950a23bdff553fd226d6f783c9afe3e4c14 100644 (file)
@@ -108,6 +108,13 @@ typedef pthread_mutex_t vlc_mutex_t;
 #define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER
 typedef pthread_cond_t  vlc_cond_t;
 typedef pthread_key_t   vlc_threadvar_t;
+typedef struct vlc_timer_t vlc_timer_t;
+struct vlc_timer_t
+{
+    timer_t handle;
+    void (*func) (vlc_timer_t *, void *);
+    void *data;
+};
 
 #elif defined( WIN32 )
 typedef struct
@@ -129,6 +136,16 @@ typedef struct
 
 typedef HANDLE  vlc_cond_t;
 typedef DWORD   vlc_threadvar_t;
+typedef struct vlc_timer_t vlc_timer_t;
+struct vlc_timer_t
+{
+    HANDLE handle;
+    void (*func) (vlc_timer_t *, void *);
+    void *data;
+    unsigned overrun;
+    CRITICAL_SECTION serializer;
+    LONG volatile counter;
+};
 
 #endif
 
@@ -164,6 +181,11 @@ VLC_EXPORT( void, vlc_cancel, (vlc_thread_t) );
 VLC_EXPORT( void, vlc_join, (vlc_thread_t, void **) );
 VLC_EXPORT (void, vlc_control_cancel, (int cmd, ...));
 
+VLC_EXPORT( int, vlc_timer_create, (vlc_timer_t *, void (*) (vlc_timer_t *, void *), void *) LIBVLC_USED );
+VLC_EXPORT( void, vlc_timer_destroy, (vlc_timer_t *) );
+VLC_EXPORT( void, vlc_timer_schedule, (vlc_timer_t *, bool, mtime_t, mtime_t) );
+VLC_EXPORT( unsigned, vlc_timer_getoverrun, (const vlc_timer_t *) );
+
 #ifndef LIBVLC_USE_PTHREAD_CANCEL
 enum {
     VLC_DO_CANCEL,