summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c28
1 files 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;