summaryrefslogtreecommitdiffstats
path: root/src/dabOutput
diff options
context:
space:
mode:
Diffstat (limited to 'src/dabOutput')
-rw-r--r--src/dabOutput/dabOutput.h2
-rw-r--r--src/dabOutput/dabOutputSimul.cpp22
2 files changed, 12 insertions, 12 deletions
diff --git a/src/dabOutput/dabOutput.h b/src/dabOutput/dabOutput.h
index 6048d51..108fd3d 100644
--- a/src/dabOutput/dabOutput.h
+++ b/src/dabOutput/dabOutput.h
@@ -244,7 +244,7 @@ class DabOutputSimul : public DabOutput
#ifdef _WIN32
DWORD startTime_;
#else
- timeval startTime_;
+ struct timespec startTime_;
#endif
};
diff --git a/src/dabOutput/dabOutputSimul.cpp b/src/dabOutput/dabOutputSimul.cpp
index b40a757..2317750 100644
--- a/src/dabOutput/dabOutputSimul.cpp
+++ b/src/dabOutput/dabOutputSimul.cpp
@@ -49,7 +49,7 @@ int DabOutputSimul::Open(const char* name)
#ifdef _WIN32
startTime_ = GetTickCount();
#else
- gettimeofday(&startTime_, NULL);
+ clock_gettime(CLOCK_MONOTONIC, &startTime_);
#endif
return 0;
@@ -75,18 +75,18 @@ int DabOutputSimul::Write(void* buffer, int size)
}
this->startTime_ += 24;
#else
- timeval curTime;
- gettimeofday(&curTime, NULL);
- current = (1000000ul * curTime.tv_sec) + curTime.tv_usec;
- start = (1000000ul * this->startTime_.tv_sec) + this->startTime_.tv_usec;
- waiting = 24000ul - (current - start);
- if ((current - start) < 24000ul) {
- usleep(waiting);
+ struct timespec curTime;
+ clock_gettime(CLOCK_MONOTONIC, &curTime);
+ current = (1000000000ul * curTime.tv_sec) + curTime.tv_nsec;
+ start = (1000000000ul * this->startTime_.tv_sec) + this->startTime_.tv_nsec;
+ waiting = 24000000ul - (current - start);
+ if ((current - start) < 24000000ul) {
+ usleep(waiting / 1000);
}
- this->startTime_.tv_usec += 24000;
- if (this->startTime_.tv_usec >= 1000000) {
- this->startTime_.tv_usec -= 1000000;
+ this->startTime_.tv_nsec += 24000000;
+ if (this->startTime_.tv_nsec >= 1000000000) {
+ this->startTime_.tv_nsec -= 1000000000;
++this->startTime_.tv_sec;
}
#endif