summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-10-27 01:13:45 +0000
committerLennart Poettering <lennart@poettering.net>2004-10-27 01:13:45 +0000
commit478e071a8364997e165d0a118e10d73bd0dcaad5 (patch)
tree550052ccfd3d2dd66715943b065c4466383b235d
parentdaa3f005069ce5d87d530c2b65f400402d73166d (diff)
make use of latency interpolation
git-svn-id: file:///home/lennart/svn/public/xmms-pulse/trunk@28 ef929aba-56e2-0310-84e0-b7573d389508
-rw-r--r--src/plugin.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 1ff894e..d6f9430 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -194,7 +194,7 @@ static void context_state_callback(struct pa_context *c, void *userdata) {
assert(stream);
pa_stream_set_state_callback(stream, stream_state_callback, NULL);
- pa_stream_connect_playback(stream, NULL, NULL, 0, current_request->volume);
+ pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_LATENCY, current_request->volume);
break;
default:
@@ -218,18 +218,6 @@ static void context_success_callback(struct pa_context *c, int success, void *us
finish_request(!!success);
}
-static void latency_callback(struct pa_stream *s, const struct pa_latency_info* i, void *userdata) {
- assert(s == stream && s);
- assert(current_request && current_request->message == MESSAGE_LATENCY);
- if (i) {
- current_request->latency = i->buffer_usec + i->sink_usec + i->transport_usec;
- current_request->value = i->playing;
-
-/* g_message("%0.0f latency", (double) current_request->latency); */
- }
- finish_request(!!i);
-}
-
static void request_func(struct pa_mainloop_api*api, struct pa_io_event *io, int fd, enum pa_io_event_flags f, void *userdata) {
char x;
@@ -293,11 +281,16 @@ static void request_func(struct pa_mainloop_api*api, struct pa_io_event *io, int
break;
case MESSAGE_LATENCY:
- if (!context || !stream) {
+ if (!context || !stream)
current_request->latency = 0;
- finish_request(1);
- } else
- pa_operation_unref(pa_stream_get_latency(stream, latency_callback, NULL));
+ else {
+ int negative;
+ current_request->latency = pa_stream_get_interpolated_latency(stream, &negative);
+ if (negative)
+ current_request->latency = 0;
+ }
+
+ finish_request(1);
break;
case MESSAGE_WRITABLE: