annotate core/Clock.cpp @ 151:e9c9404e3d1f ClockSync

Pff partially working. No PID. When setting the audio clock on the bbb to 44098 the master and slave clock keep diverging instead of converging ...
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 22 Sep 2015 04:10:07 +0100
parents 772dbb57442b
children
rev   line source
giuliomoro@135 1 #include "Clock.h"
giuliomoro@135 2
giuliomoro@135 3 namespace Clock
giuliomoro@135 4 {
giuliomoro@136 5 #ifdef USE_JUCE
giuliomoro@136 6 myClock_t getTimeUs(){
giuliomoro@136 7 struct timeval tv;
giuliomoro@136 8 struct timezone tz;
giuliomoro@136 9 int ret=gettimeofday(&tv, &tz);
giuliomoro@136 10 if(ret == -1){
giuliomoro@136 11 printf("Error while getting time of the day\n");
giuliomoro@136 12 return -1;
giuliomoro@136 13 }
giuliomoro@136 14 myClock_t time=tv.tv_usec + tv.tv_sec*1e6;
giuliomoro@136 15 // printf("Time is: %.6f\n", time/1000000.0);
giuliomoro@136 16 // printf("Time is: %lld\n", time);
giuliomoro@136 17 return time;
giuliomoro@136 18 }
giuliomoro@136 19 #else
giuliomoro@136 20 myClock_t getTimeUs(){
giuliomoro@136 21 return (myClock_t)((rt_timer_read()+500)/1000);
giuliomoro@136 22 }
giuliomoro@136 23 #endif /* USE_JUCE */
giuliomoro@136 24 };