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