wtay gstreamer: gstreamer/ gstreamer/libs/gst/base/

[email protected] Mon, 5 Jan 2009 07:43:07 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gstreamer
Changes by:     wtay
Date:           Mon Jan 05 2009  15:43:07 UTC

Log message:
* libs/gst/base/gstbasesink.c: (gst_base_sink_get_position_last),
(gst_base_sink_get_position_paused), (gst_base_sink_get_position):
Release the object lock before calling the query convert pad functions
to avoid deadlocks.

Modified files:
    .               : ChangeLog
    libs/gst/base   : gstbasesink.c

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.4213&r2=1.4214
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/libs/gst/base/gstbasesink.c.diff?r1=1.225&r2=1.226

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v
retrieving revision 1.4213
retrieving revision 1.4214
diff -u -d -r1.4213 -r1.4214
--- ChangeLog	5 Jan 2009 15:40:58 -0000	1.4213
+++ ChangeLog	5 Jan 2009 15:42:51 -0000	1.4214
@@ -1,5 +1,12 @@
 2009-01-05  Wim Taymans  <[email protected]>
 
+	* libs/gst/base/gstbasesink.c: (gst_base_sink_get_position_last),
+	(gst_base_sink_get_position_paused), (gst_base_sink_get_position):
+	Release the object lock before calling the query convert pad functions
+	to avoid deadlocks.
+
+2009-01-05  Wim Taymans  <[email protected]>
 	* gst/gstbus.c: (gst_bus_wakeup_main_context):
 	The lock order should be maincontext > OBJECT_LOCK so we need to release
 	the object lock when waking up the mainloop to avoid deadlocks.
Index: gstbasesink.c
RCS file: /cvs/gstreamer/gstreamer/libs/gst/base/gstbasesink.c,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -d -r1.225 -r1.226
--- gstbasesink.c	15 Dec 2008 12:47:59 -0000	1.225
+++ gstbasesink.c	5 Jan 2009 15:42:53 -0000	1.226
@@ -3629,7 +3629,7 @@
 /* get the end position of the last seen object, this is used
  * for EOS and for making sure that we don't report a position we
- * have not reached yet. */
+ * have not reached yet. With LOCK. */
 static gboolean
 gst_base_sink_get_position_last (GstBaseSink * basesink, GstFormat format,
     gint64 * cur)
@@ -3651,9 +3651,13 @@
   }
   if (*cur != -1 && oformat != format) {
-    /* convert to the target format if we need to */
+    GST_OBJECT_UNLOCK (basesink);
+    /* convert to the target format if we need to, release lock first */
     ret =
         gst_pad_query_convert (basesink->sinkpad, oformat, *cur, &format, cur);
+    if (!ret)
+      *cur = -1;
+    GST_OBJECT_LOCK (basesink);
   GST_DEBUG_OBJECT (basesink, "POSITION: %" GST_TIME_FORMAT,
@@ -3664,7 +3668,7 @@
 /* get the position when we are PAUSED, this is the stream time of the buffer
  * that prerolled. If no buffer is prerolled (we are still flushing), this
- * value will be -1. */
+ * value will be -1. With LOCK. */
 gst_base_sink_get_position_paused (GstBaseSink * basesink, GstFormat format,
@@ -3710,10 +3714,15 @@
           GST_TIME_ARGS (*cur));
     }
   res = (*cur != -1);
   if (res && oformat != format) {
     res =
+    if (!res)
   return res;
@@ -3774,10 +3783,13 @@
   base = GST_ELEMENT_CAST (basesink)->base_time;
   accum = basesink->segment.accum;
   rate = basesink->segment.rate * basesink->segment.applied_rate;
-  gst_base_sink_get_position_last (basesink, format, &last);
   latency = basesink->priv->latency;
   gst_object_ref (clock);
+  /* this function might release the LOCK */
+  gst_base_sink_get_position_last (basesink, format, &last);
   /* need to release the object lock before we can get the time, 
    * a clock might take the LOCK of the provider, which could be
    * a basesink subclass. */

------------------------------------------------------------------------------