summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-05-16 20:27:24 +0000
committerLennart Poettering <lennart@poettering.net>2006-05-16 20:27:24 +0000
commitcbf25c8c6021af9ff7cd8bafd82b6a13c56ff2d6 (patch)
tree51ca7873740f8bf017e04e6b6cc82e596e0b779a
parentabc19a8845b0b1e90284325b6e3d5a1664a1d8a5 (diff)
make use of new latency update callback
git-svn-id: file:///home/lennart/svn/public/gst-pulse/trunk@30 bb39ca4e-bce3-0310-b5d4-eea78a553289
-rw-r--r--src/polypsink.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/polypsink.c b/src/polypsink.c
index 02cb3d7..d3d03b0 100644
--- a/src/polypsink.c
+++ b/src/polypsink.c
@@ -303,6 +303,12 @@ static void gst_polypsink_stream_request_cb(pa_stream *s, size_t length, void *u
pa_threaded_mainloop_signal(polypsink->mainloop, 0);
}
+static void gst_polypsink_stream_latency_update_cb(pa_stream *s, void *userdata) {
+ GstPolypSink *polypsink = GST_POLYPSINK(userdata);
+
+ pa_threaded_mainloop_signal(polypsink->mainloop, 0);
+}
+
static gboolean gst_polypsink_open(GstAudioSink *asink) {
GstPolypSink *polypsink = GST_POLYPSINK(asink);
gchar *name = gst_polyp_client_name();
@@ -374,6 +380,7 @@ static gboolean gst_polypsink_prepare(GstAudioSink *asink, GstRingBufferSpec *sp
pa_stream_set_state_callback(polypsink->stream, gst_polypsink_stream_state_cb, polypsink);
pa_stream_set_write_callback(polypsink->stream, gst_polypsink_stream_request_cb, polypsink);
+ pa_stream_set_latency_update_callback(polypsink->stream, gst_polypsink_stream_latency_update_cb, polypsink);
memset(&buf_attr, 0, sizeof(buf_attr));
buf_attr.tlength = spec->segtotal*spec->segsize;
@@ -459,7 +466,7 @@ static guint gst_polypsink_write(GstAudioSink *asink, gpointer data, guint lengt
sum += l;
}
-
+
pa_threaded_mainloop_unlock(polypsink->mainloop);
return sum;
@@ -476,17 +483,18 @@ static guint gst_polypsink_delay(GstAudioSink *asink) {
pa_threaded_mainloop_lock(polypsink->mainloop);
- CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
-
- if (pa_stream_get_latency(polypsink->stream, &t, NULL) < 0) {
+ for (;;) {
+ CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
+
+ if (pa_stream_get_latency(polypsink->stream, &t, NULL) >= 0)
+ break;
if (pa_context_errno(polypsink->context) != PA_ERR_NODATA) {
GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_get_latency() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
goto unlock_and_fail;
}
- GST_WARNING("Not data while querying latency");
- t = 0;
+ pa_threaded_mainloop_wait(polypsink->mainloop);
}
pa_threaded_mainloop_unlock(polypsink->mainloop);
@@ -530,7 +538,7 @@ static void gst_polypsink_reset(GstAudioSink *asink) {
GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Flush failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
goto unlock_and_fail;
}
-
+
unlock_and_fail:
if (o) {