Mercurial > hg > beaglert
diff include/ClockSynchronizer.h @ 132:e24c531220ee scope-refactoring
Added some sort of synchronization, not working great though
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 27 Aug 2015 01:42:04 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/ClockSynchronizer.h Thu Aug 27 01:42:04 2015 +0100 @@ -0,0 +1,42 @@ +/* + * ClockSynchronizer.h + * + * Created on: 26 Aug 2015 + * Author: giulio + */ + +#ifndef CLOCKSYNCHRONIZER_H_ +#define CLOCKSYNCHRONIZER_H_ + +#include <BeagleRT.h> +#include <I2c_Codec.h> +#include <NetworkSend.h> +#include <native/timer.h> +extern I2c_Codec *gAudioCodec; + +class ClockSynchronizer { +private: + int localOffset; + int remoteOffset; + RTIME timeOffset; + int localCounter; + int remoteCounter; + RTIME lastTime; + void reset(); + static bool staticConstructed; + static void staticConstructor(); + static float currentSamplingRate; + static float targetSamplingRate; + static bool threadRunning; + static int threadWasRunning; + static AuxiliaryTask setClockTask; +public: + ClockSynchronizer(); + ~ClockSynchronizer(); + void setup(); + void update(int aLocalCounter, int aRemoteCounter, RTIME aLastTime); + void adjustClock(); + static void setClock(); +}; + +#endif /* CLOCKSYNCHRONIZER_H_ */