summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-04-11 16:28:49 +0000
committerLennart Poettering <lennart@poettering.net>2008-04-11 16:28:49 +0000
commit919bd98dff2f4cd357fe89f9e4fbc202ee5dc409 (patch)
tree71dcda0095fb2b21b8596e5356fb7218acb0a1ef
parent566322ad30648317f9fbf2e5bd43f5862e68bc60 (diff)
add new API function pa_timeval_add()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2240 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r--src/pulse/timeval.c18
-rw-r--r--src/pulse/timeval.h6
2 files changed, 23 insertions, 1 deletions
diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c
index 70ceb71e..180e0159 100644
--- a/src/pulse/timeval.c
+++ b/src/pulse/timeval.c
@@ -148,6 +148,24 @@ struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) {
return tv;
}
+struct timeval* pa_timeval_sub(struct timeval *tv, pa_usec_t v) {
+ unsigned long secs;
+ pa_assert(tv);
+
+ secs = (unsigned long) (v/PA_USEC_PER_SEC);
+ tv->tv_sec -= secs;
+ v -= ((pa_usec_t) secs) * PA_USEC_PER_SEC;
+
+ if (tv->tv_usec >= (suseconds_t) v)
+ tv->tv_usec -= (suseconds_t) v;
+ else {
+ tv->tv_sec --;
+ tv->tv_usec = tv->tv_usec + PA_USEC_PER_SEC - v;
+ }
+
+ return tv;
+}
+
struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v) {
pa_assert(tv);
diff --git a/src/pulse/timeval.h b/src/pulse/timeval.h
index 65a0e513..315f4190 100644
--- a/src/pulse/timeval.h
+++ b/src/pulse/timeval.h
@@ -26,6 +26,7 @@
***/
#include <pulse/cdecl.h>
+#include <pulse/gccmacro.h>
#include <pulse/sample.h>
/** \file
@@ -54,7 +55,10 @@ int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) PA_GCC_PURE
pa_usec_t pa_timeval_age(const struct timeval *tv);
/** Add the specified time inmicroseconds to the specified timeval structure */
-struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) PA_GCC_PURE;
+struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v);
+
+/** Subtract the specified time inmicroseconds to the specified timeval structure. \since 0.9.11 */
+struct timeval* pa_timeval_sub(struct timeval *tv, pa_usec_t v);
/** Store the specified uec value in the timeval struct. \since 0.9.7 */
struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v);