[prev in list] [next in list] [prev in thread] [next in thread]
List: gstreamer-cvs
Subject: [gst-cvs] gst-plugins-good: shout2: use gstpoll for timeouts
From: wtay () kemper ! freedesktop ! org (Wim Taymans)
Date: 2009-11-28 18:25:05
Message-ID: 20091128182505.41A9210051 () kemper ! freedesktop ! org
[Download RAW message or body]
Module: gst-plugins-good
Branch: master
Commit: 4519bdc9833dc6d59135ef57873f45c273aee7b2
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=4519bdc9833dc6d59135ef57873f45c273aee7b2
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date: Sat Nov 28 19:23:26 2009 +0100
shout2: use gstpoll for timeouts
Use our own GstPoll based timeout instead of the shout sleep so that we can
interrupt when doing a state change and shutting down.
Fixes #602887
---
ext/shout2/gstshout2.c | 50 +++++++++++++++++++++++++++++++++++++++++++++--
ext/shout2/gstshout2.h | 2 +
2 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/ext/shout2/gstshout2.c b/ext/shout2/gstshout2.c
index 4a10317..61d25ba 100644
--- a/ext/shout2/gstshout2.c
+++ b/ext/shout2/gstshout2.c
@@ -89,6 +89,8 @@ static void gst_shout2send_init (GstShout2send * shout2send);
static void gst_shout2send_finalize (GstShout2send * shout2send);
static gboolean gst_shout2send_event (GstBaseSink * sink, GstEvent * event);
+static gboolean gst_shout2send_unlock (GstBaseSink * basesink);
+static gboolean gst_shout2send_unlock_stop (GstBaseSink * basesink);
static GstFlowReturn gst_shout2send_render (GstBaseSink * sink,
GstBuffer * buffer);
static gboolean gst_shout2send_start (GstBaseSink * basesink);
@@ -237,6 +239,9 @@ gst_shout2send_class_init (GstShout2sendClass * klass)
gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_shout2send_start);
gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_shout2send_stop);
+ gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_shout2send_unlock);
+ gstbasesink_class->unlock_stop =
+ GST_DEBUG_FUNCPTR (gst_shout2send_unlock_stop);
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_shout2send_render);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_shout2send_event);
}
@@ -249,6 +254,8 @@ gst_shout2send_init (GstShout2send * shout2send)
gst_pad_set_setcaps_function (GST_BASE_SINK_PAD (shout2send),
GST_DEBUG_FUNCPTR (gst_shout2send_setcaps));
+ shout2send->timer = gst_poll_new_timer ();
+
shout2send->ip = g_strdup (DEFAULT_IP);
shout2send->port = DEFAULT_PORT;
shout2send->password = g_strdup (DEFAULT_PASSWORD);
@@ -283,6 +290,8 @@ gst_shout2send_finalize (GstShout2send * shout2send)
gst_tag_list_free (shout2send->tags);
+ gst_poll_free (shout2send->timer);
+
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (shout2send));
}
@@ -585,11 +594,39 @@ gst_shout2send_stop (GstBaseSink * basesink)
return TRUE;
}
+static gboolean
+gst_shout2send_unlock (GstBaseSink * basesink)
+{
+ GstShout2send *sink;
+
+ sink = GST_SHOUT2SEND (basesink);
+
+ GST_DEBUG_OBJECT (basesink, "unlock");
+ gst_poll_set_flushing (sink->timer, TRUE);
+
+ return TRUE;
+}
+
+static gboolean
+gst_shout2send_unlock_stop (GstBaseSink * basesink)
+{
+ GstShout2send *sink;
+
+ sink = GST_SHOUT2SEND (basesink);
+
+ GST_DEBUG_OBJECT (basesink, "unlock_stop");
+ gst_poll_set_flushing (sink->timer, FALSE);
+
+ return TRUE;
+}
+
static GstFlowReturn
gst_shout2send_render (GstBaseSink * basesink, GstBuffer * buf)
{
GstShout2send *sink;
glong ret;
+ gint delay;
+ GstFlowReturn fret;
sink = GST_SHOUT2SEND (basesink);
@@ -600,9 +637,16 @@ gst_shout2send_render (GstBaseSink * basesink, GstBuffer * buf)
return GST_FLOW_ERROR;
}
- /* FIXME: do we want to do syncing here at all? (tpm) */
- /* GST_LOG_OBJECT (sink, "using libshout to sync"); */
- shout_sync (sink->conn);
+ delay = shout_delay (sink->conn);
+
+ GST_LOG_OBJECT (sink, "waiting %d msec", delay);
+ if (gst_poll_wait (sink->timer, 1000 * delay) == -1) {
+ GST_LOG_OBJECT (sink, "unlocked");
+
+ fret = gst_base_sink_wait_preroll (basesink);
+ if (fret != GST_FLOW_OK)
+ return fret;
+ }
GST_LOG_OBJECT (sink, "sending %u bytes of data", GST_BUFFER_SIZE (buf));
ret = shout_send (sink->conn, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
diff --git a/ext/shout2/gstshout2.h b/ext/shout2/gstshout2.h
index 3e1d917..6f97c77 100644
--- a/ext/shout2/gstshout2.h
+++ b/ext/shout2/gstshout2.h
@@ -42,6 +42,8 @@ struct _GstShout2send {
GstShout2SendProtocol protocol;
+ GstPoll *timer;
+
shout_t *conn;
gchar *ip;
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
gstreamer-cvs mailing list
gstreamer-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic