[polypaudio-commits] r645 - in /trunk/src/polypcore: util.c util.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Thu Apr 6 16:31:41 PDT 2006
Author: lennart
Date: Fri Apr 7 01:31:40 2006
New Revision: 645
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=645&root=polypaudio&view=rev
Log:
change pa_gettimeofday() to return a pointer to the struct timeval*, instead of an int
Modified:
trunk/src/polypcore/util.c
trunk/src/polypcore/util.h
Modified: trunk/src/polypcore/util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/util.c?rev=645&root=polypaudio&r1=644&r2=645&view=diff
==============================================================================
--- trunk/src/polypcore/util.c (original)
+++ trunk/src/polypcore/util.c Fri Apr 7 01:31:40 2006
@@ -418,9 +418,11 @@
return b;
}
-int pa_gettimeofday(struct timeval *tv) {
+struct timeval *pa_gettimeofday(struct timeval *tv) {
#ifdef HAVE_GETTIMEOFDAY
- return gettimeofday(tv, NULL);
+ assert(tv);
+
+ return gettimeofday(tv, NULL) < 0 ? NULL : tv;
#elif defined(OS_IS_WIN32)
/*
* Copied from implementation by Steven Edwards (LGPL).
@@ -437,18 +439,18 @@
LARGE_INTEGER li;
__int64 t;
- if (tv) {
- GetSystemTimeAsFileTime(&ft);
- li.LowPart = ft.dwLowDateTime;
- li.HighPart = ft.dwHighDateTime;
- t = li.QuadPart; /* In 100-nanosecond intervals */
- t -= EPOCHFILETIME; /* Offset to the Epoch time */
- t /= 10; /* In microseconds */
- tv->tv_sec = (long)(t / 1000000);
- tv->tv_usec = (long)(t % 1000000);
- }
-
- return 0;
+ assert(tv);
+
+ GetSystemTimeAsFileTime(&ft);
+ li.LowPart = ft.dwLowDateTime;
+ li.HighPart = ft.dwHighDateTime;
+ t = li.QuadPart; /* In 100-nanosecond intervals */
+ t -= EPOCHFILETIME; /* Offset to the Epoch time */
+ t /= 10; /* In microseconds */
+ tv->tv_sec = (long)(t / 1000000);
+ tv->tv_usec = (long)(t % 1000000);
+
+ return tv;
#else
#error "Platform lacks gettimeofday() or equivalent function."
#endif
@@ -503,8 +505,8 @@
pa_usec_t pa_timeval_age(const struct timeval *tv) {
struct timeval now;
assert(tv);
- pa_gettimeofday(&now);
- return pa_timeval_diff(&now, tv);
+
+ return pa_timeval_diff(pa_gettimeofday(&now), tv);
}
/* Add the specified time inmicroseconds to the specified timeval structure */
Modified: trunk/src/polypcore/util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/util.h?rev=645&root=polypaudio&r1=644&r2=645&view=diff
==============================================================================
--- trunk/src/polypcore/util.h (original)
+++ trunk/src/polypcore/util.h Fri Apr 7 01:31:40 2006
@@ -55,7 +55,7 @@
const char *pa_path_get_filename(const char *p);
-int pa_gettimeofday(struct timeval *tv);
+struct timeval *pa_gettimeofday(struct timeval *tv);
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b);
int pa_timeval_cmp(const struct timeval *a, const struct timeval *b);
pa_usec_t pa_timeval_age(const struct timeval *tv);
More information about the pulseaudio-commits
mailing list