view include/ClockSynchronizer.h @ 152:8f98b32d0e23 ClockSync

Last commit on this branch for a while. Overall not very succesful
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 05 Oct 2015 13:06:14 +0100
parents e24c531220ee
children
line wrap: on
line source
/*
 * 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_ */