summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polyp/core.c2
-rw-r--r--polyp/glib-mainloop.c2
-rw-r--r--polyp/glib12-mainloop.c2
-rw-r--r--polyp/mainloop-test.c2
-rw-r--r--polyp/mainloop.c4
-rw-r--r--polyp/module-combine.c4
-rw-r--r--polyp/module-null-sink.c2
-rw-r--r--polyp/module-tunnel.c8
-rw-r--r--polyp/module.c4
-rw-r--r--polyp/pdispatch.c2
-rw-r--r--polyp/polyplib-stream.c10
-rw-r--r--polyp/protocol-esound.c2
-rw-r--r--polyp/protocol-native.c6
-rw-r--r--polyp/scache.c4
-rw-r--r--polyp/socket-client.c2
-rw-r--r--polyp/util.c10
-rw-r--r--polyp/util.h1
17 files changed, 38 insertions, 29 deletions
diff --git a/polyp/core.c b/polyp/core.c
index e2bebec2..539c6775 100644
--- a/polyp/core.c
+++ b/polyp/core.c
@@ -144,7 +144,7 @@ void pa_core_check_quit(struct pa_core *c) {
if (!c->quit_event && c->exit_idle_time >= 0 && pa_idxset_ncontents(c->clients) == 0) {
struct timeval tv;
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
tv.tv_sec+= c->exit_idle_time;
c->quit_event = c->mainloop->time_new(c->mainloop, &tv, quit_callback, c);
} else if (c->quit_event && pa_idxset_ncontents(c->clients) > 0) {
diff --git a/polyp/glib-mainloop.c b/polyp/glib-mainloop.c
index 809c0b0f..0f96a594 100644
--- a/polyp/glib-mainloop.c
+++ b/polyp/glib-mainloop.c
@@ -241,7 +241,7 @@ static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv)
struct timeval now;
assert(e && e->mainloop && !e->dead);
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
if (e->source) {
g_source_destroy(e->source);
g_source_unref(e->source);
diff --git a/polyp/glib12-mainloop.c b/polyp/glib12-mainloop.c
index 5f037347..c328471c 100644
--- a/polyp/glib12-mainloop.c
+++ b/polyp/glib12-mainloop.c
@@ -233,7 +233,7 @@ static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv)
struct timeval now;
assert(e && e->mainloop && !e->dead);
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
if (e->source != (guint) -1)
g_source_remove(e->source);
diff --git a/polyp/mainloop-test.c b/polyp/mainloop-test.c
index 0d40e76e..dd8f8137 100644
--- a/polyp/mainloop-test.c
+++ b/polyp/mainloop-test.c
@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
de = a->defer_new(a, dcb, NULL);
assert(de);
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
tv.tv_sec += 10;
te = a->time_new(a, &tv, tcb, NULL);
diff --git a/polyp/mainloop.c b/polyp/mainloop.c
index f6bb4145..a0d27827 100644
--- a/polyp/mainloop.c
+++ b/polyp/mainloop.c
@@ -457,7 +457,7 @@ static int calc_next_timeout(struct pa_mainloop *m) {
/* Let's save a system call */
if (!got_time) {
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
got_time = 1;
}
@@ -498,7 +498,7 @@ static int dispatch_timeout(struct pa_mainloop *m) {
/* Let's save a system call */
if (!got_time) {
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
got_time = 1;
}
diff --git a/polyp/module-combine.c b/polyp/module-combine.c
index ca79d7df..7283c554 100644
--- a/polyp/module-combine.c
+++ b/polyp/module-combine.c
@@ -157,7 +157,7 @@ static void time_callback(struct pa_mainloop_api*a, struct pa_time_event* e, con
adjust_rates(u);
- gettimeofday(&n, NULL);
+ pa_gettimeofday(&n);
n.tv_sec += u->adjust_time;
u->sink->core->mainloop->time_restart(e, &n);
}
@@ -363,7 +363,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
pa_log_warn(__FILE__": WARNING: no slave sinks specified.\n");
if (u->adjust_time > 0) {
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
tv.tv_sec += u->adjust_time;
u->time_event = c->mainloop->time_new(c->mainloop, &tv, time_callback, u);
}
diff --git a/polyp/module-null-sink.c b/polyp/module-null-sink.c
index fcac1ea4..6c7a44f2 100644
--- a/polyp/module-null-sink.c
+++ b/polyp/module-null-sink.c
@@ -117,7 +117,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
pa_sink_set_owner(u->sink, m);
u->sink->description = pa_sprintf_malloc("NULL sink");
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
u->time_event = c->mainloop->time_new(c->mainloop, &tv, time_callback, u);
u->block_size = pa_bytes_per_second(&ss) / 10;
diff --git a/polyp/module-tunnel.c b/polyp/module-tunnel.c
index 9da87b3d..749aebfa 100644
--- a/polyp/module-tunnel.c
+++ b/polyp/module-tunnel.c
@@ -284,7 +284,7 @@ static void stream_get_latency_callback(struct pa_pdispatch *pd, uint32_t comman
return;
}
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
if (pa_timeval_cmp(&local, &remote) < 0 && pa_timeval_cmp(&remote, &now)) {
/* local and remote seem to have synchronized clocks */
@@ -324,7 +324,7 @@ static void request_latency(struct userdata *u) {
pa_tagstruct_putu32(t, tag = u->ctag++);
pa_tagstruct_putu32(t, u->channel);
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
pa_tagstruct_put_timeval(t, &now);
pa_tagstruct_putu64(t, 0);
@@ -536,7 +536,7 @@ static void timeout_callback(struct pa_mainloop_api *m, struct pa_time_event*e,
request_latency(u);
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += LATENCY_INTERVAL;
m->time_restart(e, &ntv);
}
@@ -650,7 +650,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
pa_source_set_owner(u->source, m);
#endif
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += LATENCY_INTERVAL;
u->time_event = c->mainloop->time_new(c->mainloop, &ntv, timeout_callback, u);
diff --git a/polyp/module.c b/polyp/module.c
index aedaae02..0a3d569b 100644
--- a/polyp/module.c
+++ b/polyp/module.c
@@ -47,7 +47,7 @@ static void timeout_callback(struct pa_mainloop_api *m, struct pa_time_event*e,
pa_module_unload_unused(c);
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += UNLOAD_POLL_TIME;
m->time_restart(e, &ntv);
}
@@ -98,7 +98,7 @@ struct pa_module* pa_module_load(struct pa_core *c, const char *name, const char
if (!c->module_auto_unload_event) {
struct timeval ntv;
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += UNLOAD_POLL_TIME;
c->module_auto_unload_event = c->mainloop->time_new(c->mainloop, &ntv, timeout_callback, c);
}
diff --git a/polyp/pdispatch.c b/polyp/pdispatch.c
index 7a9e9c68..9e808756 100644
--- a/polyp/pdispatch.c
+++ b/polyp/pdispatch.c
@@ -245,7 +245,7 @@ void pa_pdispatch_register_reply(struct pa_pdispatch *pd, uint32_t tag, int time
r->userdata = userdata;
r->tag = tag;
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
tv.tv_sec += timeout;
r->time_event = pd->mainloop->time_new(pd->mainloop, &tv, timeout_callback, r);
diff --git a/polyp/polyplib-stream.c b/polyp/polyplib-stream.c
index 440217e7..d4480f8c 100644
--- a/polyp/polyplib-stream.c
+++ b/polyp/polyplib-stream.c
@@ -217,7 +217,7 @@ static void ipol_callback(struct pa_mainloop_api *m, struct pa_time_event *e, co
s->ipol_requested = 1;
}
- gettimeofday(&tv2, NULL);
+ pa_gettimeofday(&tv2);
pa_timeval_add(&tv2, LATENCY_IPOL_INTERVAL_USEC);
m->time_restart(e, &tv2);
@@ -256,7 +256,7 @@ void pa_create_stream_callback(struct pa_pdispatch *pd, uint32_t command, uint32
struct timeval tv;
pa_operation_unref(pa_stream_get_latency_info(s, NULL, NULL));
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
tv.tv_usec += LATENCY_IPOL_INTERVAL_USEC; /* every 100 ms */
assert(!s->ipol_event);
@@ -412,7 +412,7 @@ static void stream_get_latency_info_callback(struct pa_pdispatch *pd, uint32_t c
pa_context_fail(o->context, PA_ERROR_PROTOCOL);
goto finish;
} else {
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
if (pa_timeval_cmp(&local, &remote) < 0 && pa_timeval_cmp(&remote, &now)) {
/* local and remote seem to have synchronized clocks */
@@ -470,7 +470,7 @@ struct pa_operation* pa_stream_get_latency_info(struct pa_stream *s, void (*cb)(
pa_tagstruct_putu32(t, tag = s->context->ctag++);
pa_tagstruct_putu32(t, s->channel);
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
pa_tagstruct_put_timeval(t, &now);
pa_tagstruct_putu64(t, s->counter);
@@ -581,7 +581,7 @@ struct pa_operation* pa_stream_cork(struct pa_stream *s, int b, void (*cb) (stru
s->ipol_usec = pa_stream_get_interpolated_time(s);
else if (s->corked && !b)
/* Unpausing */
- gettimeofday(&s->ipol_timestamp, NULL);
+ pa_gettimeofday(&s->ipol_timestamp);
}
s->corked = b;
diff --git a/polyp/protocol-esound.c b/polyp/protocol-esound.c
index d99b721c..2af3cc81 100644
--- a/polyp/protocol-esound.c
+++ b/polyp/protocol-esound.c
@@ -1099,7 +1099,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
if (!c->authorized) {
struct timeval tv;
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
tv.tv_sec += AUTH_TIMEOUT;
c->auth_timeout_event = p->core->mainloop->time_new(p->core->mainloop, &tv, auth_timeout, c);
} else
diff --git a/polyp/protocol-native.c b/polyp/protocol-native.c
index 7e1a8894..90dbdaf5 100644
--- a/polyp/protocol-native.c
+++ b/polyp/protocol-native.c
@@ -928,7 +928,7 @@ static void command_get_playback_latency(struct pa_pdispatch *pd, uint32_t comma
pa_tagstruct_put_boolean(reply, pa_memblockq_is_readable(s->memblockq));
pa_tagstruct_putu32(reply, pa_memblockq_get_length(s->memblockq));
pa_tagstruct_put_timeval(reply, &tv);
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
pa_tagstruct_put_timeval(reply, &now);
pa_tagstruct_putu64(reply, counter);
pa_pstream_send_tagstruct(c->pstream, reply);
@@ -971,7 +971,7 @@ static void command_get_record_latency(struct pa_pdispatch *pd, uint32_t command
pa_tagstruct_put_boolean(reply, 0);
pa_tagstruct_putu32(reply, pa_memblockq_get_length(s->memblockq));
pa_tagstruct_put_timeval(reply, &tv);
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
pa_tagstruct_put_timeval(reply, &now);
pa_tagstruct_putu64(reply, counter);
pa_pstream_send_tagstruct(c->pstream, reply);
@@ -2024,7 +2024,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
if (!c->authorized) {
struct timeval tv;
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
tv.tv_sec += AUTH_TIMEOUT;
c->auth_timeout_event = p->core->mainloop->time_new(p->core->mainloop, &tv, auth_timeout, c);
} else
diff --git a/polyp/scache.c b/polyp/scache.c
index ccdc7185..143f9740 100644
--- a/polyp/scache.c
+++ b/polyp/scache.c
@@ -55,7 +55,7 @@ static void timeout_callback(struct pa_mainloop_api *m, struct pa_time_event*e,
pa_scache_unload_unused(c);
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += UNLOAD_POLL_TIME;
m->time_restart(e, &ntv);
}
@@ -165,7 +165,7 @@ int pa_scache_add_file_lazy(struct pa_core *c, const char *name, const char *fil
if (!c->scache_auto_unload_event) {
struct timeval ntv;
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += UNLOAD_POLL_TIME;
c->scache_auto_unload_event = c->mainloop->time_new(c->mainloop, &ntv, timeout_callback, c);
}
diff --git a/polyp/socket-client.c b/polyp/socket-client.c
index 21563d35..f02b74bd 100644
--- a/polyp/socket-client.c
+++ b/polyp/socket-client.c
@@ -377,7 +377,7 @@ static void start_timeout(struct pa_socket_client *c) {
assert(c);
assert(!c->timeout_event);
- gettimeofday(&tv, NULL);
+ pa_gettimeofday(&tv);
pa_timeval_add(&tv, CONNECT_TIMEOUT * 1000000);
c->timeout_event = c->mainloop->time_new(c->mainloop, &tv, timeout_cb, c);
}
diff --git a/polyp/util.c b/polyp/util.c
index ee3fa87d..699480af 100644
--- a/polyp/util.c
+++ b/polyp/util.c
@@ -302,6 +302,14 @@ char *pa_strlcpy(char *b, const char *s, size_t l) {
return b;
}
+int pa_gettimeofday(struct timeval *tv) {
+#ifdef HAVE_GETTIMEOFDAY
+ return gettimeofday(tv, NULL);
+#else
+#error "Platform lacks gettimeofday() or equivalent function."
+#endif
+}
+
/* Calculate the difference between the two specfified timeval
* timestamsps. */
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
@@ -351,7 +359,7 @@ int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) {
pa_usec_t pa_timeval_age(const struct timeval *tv) {
struct timeval now;
assert(tv);
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
return pa_timeval_diff(&now, tv);
}
diff --git a/polyp/util.h b/polyp/util.h
index 2cfc5f6e..745d8f0f 100644
--- a/polyp/util.h
+++ b/polyp/util.h
@@ -53,6 +53,7 @@ char *pa_get_home_dir(char *s, size_t l);
char *pa_path_get_filename(const char *p);
+int 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);