From eaad1f4568ab1cf731aafe1cc28f4dffcc09d7a0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 12 Nov 2009 16:55:43 +0100 Subject: stream: improve transport_usec calculation Transport_usec contains the delay betweem the client and the server. When the client and the server have synchronized clocks we can calculate this by taking the difference between when the server generated a timing update and when we got the reply. Before this patch, the difference between when we generated the request and when the server generated the reply was used, which could seriously overestimate the transport delay when the server did a lot of work between receiving the request and generating the reply (such as opening the device). --- src/pulse/stream.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pulse/stream.c b/src/pulse/stream.c index 83aeef6a5..695bf6a16 100644 --- a/src/pulse/stream.c +++ b/src/pulse/stream.c @@ -1629,10 +1629,9 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command, if (pa_timeval_cmp(&local, &remote) <= 0 && pa_timeval_cmp(&remote, &now) <= 0) { /* local and remote seem to have synchronized clocks */ - if (o->stream->direction == PA_STREAM_PLAYBACK) - i->transport_usec = pa_timeval_diff(&remote, &local); - else - i->transport_usec = pa_timeval_diff(&now, &remote); + /* the transport time with synchronized clocks is the difference + * between when the server generated the reply and when we got it */ + i->transport_usec = pa_timeval_diff(&now, &remote); i->synchronized_clocks = TRUE; i->timestamp = remote; -- cgit v1.2.3