mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-22 08:56:52 -05:00
core-rtclock: introduce pa_timespec_store() akin pa_timeval_store()
This commit is contained in:
parent
f7d38965b3
commit
fdec460661
2 changed files with 15 additions and 0 deletions
|
|
@ -151,6 +151,20 @@ pa_usec_t pa_timespec_load(const struct timespec *ts) {
|
||||||
(pa_usec_t) ts->tv_nsec / PA_NSEC_PER_USEC;
|
(pa_usec_t) ts->tv_nsec / PA_NSEC_PER_USEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v) {
|
||||||
|
pa_assert(ts);
|
||||||
|
|
||||||
|
if (PA_UNLIKELY(v == PA_USEC_INVALID)) {
|
||||||
|
ts->tv_sec = PA_INT_TYPE_MAX(time_t);
|
||||||
|
ts->tv_nsec = (long) (PA_NSEC_PER_SEC-1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ts->tv_sec = (time_t) (v / PA_USEC_PER_SEC);
|
||||||
|
ts->tv_nsec = (long) ((v % PA_USEC_PER_SEC) * PA_NSEC_PER_USEC);
|
||||||
|
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
|
static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ void pa_rtclock_hrtimer_enable(void);
|
||||||
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
|
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
|
||||||
|
|
||||||
pa_usec_t pa_timespec_load(const struct timespec *ts);
|
pa_usec_t pa_timespec_load(const struct timespec *ts);
|
||||||
|
struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v);
|
||||||
|
|
||||||
struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, pa_bool_t rtclock);
|
struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, pa_bool_t rtclock);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue