mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-03 14:59:52 +00:00
Move the clock_gettime2 and add_time_in_ms implementation to event.c to avoid code duplication.
This commit is contained in:
@@ -44,8 +44,6 @@
|
||||
#endif
|
||||
#include "wave.h"
|
||||
|
||||
enum { ONE_BILLION = 1000000000 };
|
||||
|
||||
enum {
|
||||
/* return value */
|
||||
PULSE_OK = 0,
|
||||
@@ -669,32 +667,3 @@ void *wave_test_get_write_buffer()
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef USE_PORTAUDIO
|
||||
|
||||
void clock_gettime2(struct timespec *ts)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (!ts)
|
||||
return;
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
ts->tv_nsec = tv.tv_usec*1000;
|
||||
}
|
||||
|
||||
void add_time_in_ms(struct timespec *ts, int time_in_ms)
|
||||
{
|
||||
if (!ts)
|
||||
return;
|
||||
|
||||
uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms;
|
||||
while (t_ns >= ONE_BILLION) {
|
||||
ts->tv_sec += 1;
|
||||
t_ns -= ONE_BILLION;
|
||||
}
|
||||
ts->tv_nsec = (long int)t_ns;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user