summaryrefslogtreecommitdiffstats
path: root/polyp/polyplib-stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'polyp/polyplib-stream.c')
-rw-r--r--polyp/polyplib-stream.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/polyp/polyplib-stream.c b/polyp/polyplib-stream.c
index 6a73c608..b6a091b3 100644
--- a/polyp/polyplib-stream.c
+++ b/polyp/polyplib-stream.c
@@ -66,6 +66,7 @@ struct pa_stream *pa_stream_new(struct pa_context *c, const char *name, const st
s->counter = 0;
s->previous_time = 0;
+ s->previous_ipol_time = 0;
s->corked = 0;
s->interpolate = 0;
@@ -217,7 +218,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 +257,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 +413,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) <= 0) {
/* local and remote seem to have synchronized clocks */
@@ -470,7 +471,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 +582,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;
@@ -702,7 +703,7 @@ pa_usec_t pa_stream_get_time(struct pa_stream *s, const struct pa_latency_info *
usec = s->previous_time;
s->previous_time = usec;
-
+
return usec;
}
@@ -762,10 +763,11 @@ pa_usec_t pa_stream_get_interpolated_time(struct pa_stream *s) {
usec = s->ipol_usec + pa_timeval_age(&s->ipol_timestamp);
}
- if (usec < s->previous_time)
- usec = s->previous_time;
+ if (usec < s->previous_ipol_time)
+ usec = s->previous_ipol_time;
+
+ s->previous_ipol_time = usec;
- s->previous_time = usec;
return usec;
}