thread_inited = 0; | thread_inited = 0; | ||||
} | } | ||||
} | } | ||||
enum { ONE_BILLION = 1000000000 }; | |||||
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 | #endif | ||||
enum { ONE_BILLION = 1000000000 }; | |||||
#ifdef USE_PORTAUDIO | #ifdef USE_PORTAUDIO | ||||
#include "portaudio.h" | #include "portaudio.h" | ||||
} | } | ||||
#endif | #endif | ||||
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 | #endif | ||||
#include "wave.h" | #include "wave.h" | ||||
enum { ONE_BILLION = 1000000000 }; | |||||
enum { | enum { | ||||
/* return value */ | /* return value */ | ||||
PULSE_OK = 0, | PULSE_OK = 0, | ||||
} | } | ||||
#endif | #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 |
#include "wave.h" | #include "wave.h" | ||||
enum { ONE_BILLION = 1000000000 }; | |||||
#define SAMPLE_RATE 22050 | #define SAMPLE_RATE 22050 | ||||
#define SAMPLE_SIZE 16 | #define SAMPLE_SIZE 16 | ||||
} | } | ||||
#endif | #endif | ||||
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; | |||||
} |