From eb97ee97f8962f31d549a16ec57a349168861ba7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 27 Oct 2004 14:14:57 +0000 Subject: fix latency calculation git-svn-id: file:///home/lennart/svn/public/xmms-pulse/trunk@29 ef929aba-56e2-0310-84e0-b7573d389508 --- src/plugin.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/plugin.c b/src/plugin.c index d6f9430..60ddefc 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -281,15 +281,7 @@ static void request_func(struct pa_mainloop_api*api, struct pa_io_event *io, int break; case MESSAGE_LATENCY: - if (!context || !stream) - current_request->latency = 0; - else { - int negative; - current_request->latency = pa_stream_get_interpolated_latency(stream, &negative); - if (negative) - current_request->latency = 0; - } - + current_request->latency = context && stream ? pa_stream_get_interpolated_latency(stream, NULL) : 0; finish_request(1); break; @@ -483,18 +475,6 @@ static int polyp_free(void) { return ret; } -static int polyp_playing(void) { - struct request r; - - r.message = MESSAGE_LATENCY; - execute_request(&r); - - if (!r.success) - return 0; - - return r.value != 0; -} - static int polyp_get_written_time(void) { return (int) ((((double) written/pa_frame_size(&sample_spec))*1000)/sample_spec.rate); } @@ -515,6 +495,12 @@ static int polyp_get_output_time(void) { return ms > t ? 0 : t-ms; } +static int polyp_playing(void) { + + + return polyp_get_output_time() >= polyp_get_written_time(); +} + static void polyp_flush(int time) { struct request r; -- cgit