]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/x11/x11_timer.h
* modules/gui/skins/win32/win32_run.cpp: don't forget to delete VlcProc
[vlc] / modules / gui / skins / x11 / x11_timer.h
index 788a90578364bc49444228cb953fd1b0079343c4..4a7b9d9913465451268a4be58a9423f849bd44fd 100644 (file)
@@ -2,7 +2,7 @@
  * x11_timer.h: helper class to implement timers
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_timer.h,v 1.1 2003/06/05 22:16:15 asmax Exp $
+ * $Id: x11_timer.h,v 1.6 2003/07/25 22:50:12 gbazin Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -26,7 +26,8 @@
 #ifndef VLC_SKIN_X11_TIMER
 #define VLC_SKIN_X11_TIMER
 
-#include <list.h>
+#include <list>
+using namespace std;
 
 typedef struct
 {
@@ -36,7 +37,7 @@ typedef struct
 
 class X11Timer;  // forward declaration
 
-typedef void(*callback_t)( void* );
+typedef bool(*callback_t)( void* );
 
 //---------------------------------------------------------------------------
 class X11Timer
@@ -46,14 +47,20 @@ class X11Timer
         mtime_t _interval;       
         callback_t _callback;
         void *_data;
+        vlc_mutex_t _lock;
+        mtime_t _nextDate;
 
     public:
         X11Timer( intf_thread_t *p_intf, mtime_t interval, callback_t func, 
                   void *data );
         ~X11Timer();
 
-        mtime_t getNextDate( mtime_t current );
-        void Execute();
+        void SetDate( mtime_t date );
+        mtime_t GetNextDate();
+        bool Execute();
+        
+        inline void Lock() { vlc_mutex_lock( &_lock ); }
+        inline void Unlock() { vlc_mutex_unlock( &_lock ); }
 };
 //---------------------------------------------------------------------------
 class X11TimerManager
@@ -63,18 +70,24 @@ class X11TimerManager
         intf_thread_t *_p_intf;
         timer_thread_t *_p_timer;
         list<X11Timer*> _timers;
-        
+        vlc_mutex_t _lock;
+
         X11TimerManager( intf_thread_t *p_intf );
         ~X11TimerManager();
 
-        static void *Thread( void *p_timer );
+        static void Thread( void *p_timer );
+        void WaitNextTimer();
 
     public:
+        static void Initialize();
         static X11TimerManager *Instance( intf_thread_t *p_intf );
         void Destroy();
 
-        void addTimer( X11Timer *timer ) { _timers.push_back( timer ); }
+        void addTimer( X11Timer *timer );
+        void removeTimer( X11Timer *timer );
 
+        inline void Lock() { vlc_mutex_lock( &_lock ); }
+        inline void Unlock() { vlc_mutex_unlock( &_lock ); }
 };
 //---------------------------------------------------------------------------
 #endif