From f7a99e90470526bb28cc0c225f96490110094aed Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 10 Jan 2006 17:51:06 +0000 Subject: Merge Pierre's changes git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@445 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/polyplib-stream.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'polyp/polyplib-stream.c') 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; } -- cgit