giuliomoro@132: /* giuliomoro@132: * ClockSynchronizer.h giuliomoro@132: * giuliomoro@132: * Created on: 26 Aug 2015 giuliomoro@132: * Author: giulio giuliomoro@132: */ giuliomoro@132: giuliomoro@132: #ifndef CLOCKSYNCHRONIZER_H_ giuliomoro@132: #define CLOCKSYNCHRONIZER_H_ giuliomoro@132: giuliomoro@132: #include giuliomoro@132: #include giuliomoro@132: #include giuliomoro@132: #include giuliomoro@132: extern I2c_Codec *gAudioCodec; giuliomoro@132: giuliomoro@132: class ClockSynchronizer { giuliomoro@132: private: giuliomoro@132: int localOffset; giuliomoro@132: int remoteOffset; giuliomoro@132: RTIME timeOffset; giuliomoro@132: int localCounter; giuliomoro@132: int remoteCounter; giuliomoro@132: RTIME lastTime; giuliomoro@132: void reset(); giuliomoro@132: static bool staticConstructed; giuliomoro@132: static void staticConstructor(); giuliomoro@132: static float currentSamplingRate; giuliomoro@132: static float targetSamplingRate; giuliomoro@132: static bool threadRunning; giuliomoro@132: static int threadWasRunning; giuliomoro@132: static AuxiliaryTask setClockTask; giuliomoro@132: public: giuliomoro@132: ClockSynchronizer(); giuliomoro@132: ~ClockSynchronizer(); giuliomoro@132: void setup(); giuliomoro@132: void update(int aLocalCounter, int aRemoteCounter, RTIME aLastTime); giuliomoro@132: void adjustClock(); giuliomoro@132: static void setClock(); giuliomoro@132: }; giuliomoro@132: giuliomoro@132: #endif /* CLOCKSYNCHRONIZER_H_ */