annotate 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
rev   line source
giuliomoro@132 1 /*
giuliomoro@132 2 * ClockSynchronizer.h
giuliomoro@132 3 *
giuliomoro@132 4 * Created on: 26 Aug 2015
giuliomoro@132 5 * Author: giulio
giuliomoro@132 6 */
giuliomoro@132 7
giuliomoro@132 8 #ifndef CLOCKSYNCHRONIZER_H_
giuliomoro@132 9 #define CLOCKSYNCHRONIZER_H_
giuliomoro@132 10
giuliomoro@132 11 #include <BeagleRT.h>
giuliomoro@132 12 #include <I2c_Codec.h>
giuliomoro@132 13 #include <NetworkSend.h>
giuliomoro@132 14 #include <native/timer.h>
giuliomoro@132 15 extern I2c_Codec *gAudioCodec;
giuliomoro@132 16
giuliomoro@132 17 class ClockSynchronizer {
giuliomoro@132 18 private:
giuliomoro@132 19 int localOffset;
giuliomoro@132 20 int remoteOffset;
giuliomoro@132 21 RTIME timeOffset;
giuliomoro@132 22 int localCounter;
giuliomoro@132 23 int remoteCounter;
giuliomoro@132 24 RTIME lastTime;
giuliomoro@132 25 void reset();
giuliomoro@132 26 static bool staticConstructed;
giuliomoro@132 27 static void staticConstructor();
giuliomoro@132 28 static float currentSamplingRate;
giuliomoro@132 29 static float targetSamplingRate;
giuliomoro@132 30 static bool threadRunning;
giuliomoro@132 31 static int threadWasRunning;
giuliomoro@132 32 static AuxiliaryTask setClockTask;
giuliomoro@132 33 public:
giuliomoro@132 34 ClockSynchronizer();
giuliomoro@132 35 ~ClockSynchronizer();
giuliomoro@132 36 void setup();
giuliomoro@132 37 void update(int aLocalCounter, int aRemoteCounter, RTIME aLastTime);
giuliomoro@132 38 void adjustClock();
giuliomoro@132 39 static void setClock();
giuliomoro@132 40 };
giuliomoro@132 41
giuliomoro@132 42 #endif /* CLOCKSYNCHRONIZER_H_ */