giuliomoro@135: #ifndef CLOCK_SYNC_THREAD_H_INCLUDED giuliomoro@135: #define CLOCK_SYNC_THREAD_H_INCLUDED giuliomoro@135: giuliomoro@135: #ifdef USE_JUCE giuliomoro@135: #include giuliomoro@135: #define IS_STATIC giuliomoro@135: #else giuliomoro@135: #define IS_STATIC static giuliomoro@135: #include giuliomoro@135: #endif /*USE_JUCE*/ giuliomoro@135: giuliomoro@135: #include "ClockSync.h" giuliomoro@135: giuliomoro@135: #ifdef USE_JUCE giuliomoro@135: class ClockSyncThread : public Thread { giuliomoro@135: #else giuliomoro@135: class ClockSyncThread { giuliomoro@135: #endif /* USE_JUCE */ giuliomoro@135: private: giuliomoro@135: IS_STATIC myClock_t lastTime; // Used for clock synchronization giuliomoro@135: IS_STATIC bool listening; giuliomoro@135: IS_STATIC ClockSync clockSync; giuliomoro@135: IS_STATIC VirtualClock *virtualClock; giuliomoro@135: #ifdef USE_JUCE giuliomoro@135: #else giuliomoro@135: IS_STATIC bool threadIsExiting; giuliomoro@135: IS_STATIC AuxiliaryTask clockSyncTask; giuliomoro@135: #endif /* USE_JUCE */ giuliomoro@135: giuliomoro@135: public: giuliomoro@135: #ifdef USE_JUCE giuliomoro@135: ClockSyncThread(const String &threadName); giuliomoro@135: #else giuliomoro@135: ClockSyncThread(); giuliomoro@135: #endif /* USE_JUCE */ giuliomoro@135: ~ClockSyncThread(); giuliomoro@135: IS_STATIC void init(bool isSlave, int aPort, VirtualClock &aVirtualClock); giuliomoro@135: IS_STATIC void setVirtualClock(VirtualClock &aVirtualClock); giuliomoro@135: giuliomoro@135: IS_STATIC void run(); giuliomoro@135: #ifdef USE_JUCE giuliomoro@135: #else giuliomoro@135: IS_STATIC void startThread(); giuliomoro@135: IS_STATIC void stopThread(); giuliomoro@135: IS_STATIC bool threadShouldExit(); giuliomoro@135: #endif // USE_JUCE giuliomoro@135: }; giuliomoro@135: #endif // CLOCK_SYNC_THREAD_H_INCLUDED