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) {
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);
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);
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);
/* Let's save a system call */
if (!got_time) {
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
got_time = 1;
}
/* Let's save a system call */
if (!got_time) {
- gettimeofday(&now, NULL);
+ pa_gettimeofday(&now);
got_time = 1;
}
adjust_rates(u);
- gettimeofday(&n, NULL);
+ pa_gettimeofday(&n);
n.tv_sec += u->adjust_time;
u->sink->core->mainloop->time_restart(e, &n);
}
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);
}
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;
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 */
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);
request_latency(u);
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += LATENCY_INTERVAL;
m->time_restart(e, &ntv);
}
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);
pa_module_unload_unused(c);
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += UNLOAD_POLL_TIME;
m->time_restart(e, &ntv);
}
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);
}
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);
s->ipol_requested = 1;
}
- gettimeofday(&tv2, NULL);
+ pa_gettimeofday(&tv2);
pa_timeval_add(&tv2, LATENCY_IPOL_INTERVAL_USEC);
m->time_restart(e, &tv2);
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);
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 */
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);
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;
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
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);
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);
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
pa_scache_unload_unused(c);
- gettimeofday(&ntv, NULL);
+ pa_gettimeofday(&ntv);
ntv.tv_sec += UNLOAD_POLL_TIME;
m->time_restart(e, &ntv);
}
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);
}
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);
}
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) {
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);
}
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);