X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/a87ba420698b7f58d8eaa9236bb01bf11558ed35..57baff51434924e73fce8043d13a29b2977dc93e:/src/pulsecore/rtclock.c diff --git a/src/pulsecore/rtclock.c b/src/pulsecore/rtclock.c index f33de830..56ab2ef0 100644 --- a/src/pulsecore/rtclock.c +++ b/src/pulsecore/rtclock.c @@ -27,9 +27,15 @@ #include #include #include +#include + +#ifdef HAVE_SYS_PRCTL_H +#include +#endif #include #include +#include #include "rtclock.h" @@ -89,6 +95,29 @@ pa_bool_t pa_rtclock_hrtimer(void) { #endif } +void pa_rtclock_hrtimer_enable(void) { +#ifdef PR_SET_TIMERSLACK + int slack_ns; + + if ((slack_ns = prctl(PR_GET_TIMERSLACK, 0, 0, 0, 0)) < 0) { + pa_log_info("PR_GET_TIMERSLACK/PR_SET_TIMERSLACK not supported."); + return; + } + + pa_log_debug("Timer slack set to %i us.", slack_ns/1000); + + slack_ns = 500000000; + + pa_log_debug("Setting timer slack to %i us.", slack_ns/1000); + + if (prctl(PR_SET_TIMERSLACK, slack_ns, 0, 0, 0) < 0) { + pa_log_warn("PR_SET_TIMERSLACK failed: %s", pa_cstrerror(errno)); + return; + } + +#endif +} + pa_usec_t pa_rtclock_usec(void) { struct timeval tv; @@ -115,3 +144,11 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) { return tv; } + +pa_usec_t pa_timespec_load(const struct timespec *ts) { + pa_assert(ts); + + return + (pa_usec_t) ts->tv_sec * PA_USEC_PER_SEC + + (pa_usec_t) ts->tv_nsec / PA_NSEC_PER_USEC; +}