gst/gstcaps.c: Fix crasher when passed NULL. Doc clarification.
authorWim Taymans <wim.taymans@gmail.com>
Thu, 22 Jun 2006 13:51:19 +0000 (13:51 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Thu, 22 Jun 2006 13:51:19 +0000 (13:51 +0000)
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_replace):
Fix crasher when passed NULL. Doc clarification.
Optimize for the trivial case.
* gst/gstpipeline.c: (gst_pipeline_change_state):
Small cleanups.
* libs/gst/base/gstbasesrc.c: (gst_base_src_loop):
Small documentation cleanup.
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_buffer_alloc):
Don't use silly gst_pad_get_negotiated_caps, GST_PAD_CAPS
is what we need and it avoids a whole lot of redundant
refcount operations.

ChangeLog
common
gst/gstcaps.c
gst/gstpipeline.c
libs/gst/base/gstbasesrc.c
libs/gst/base/gstbasetransform.c

index 89cb177..d3af4f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2006-06-22  Wim Taymans  <wim@fluendo.com>
+
+       * gst/gstcaps.c: (gst_caps_replace):
+       Fix crasher when passed NULL. Doc clarification.
+       Optimize for the trivial case.
+
+       * gst/gstpipeline.c: (gst_pipeline_change_state):
+       Small cleanups.
+
+       * libs/gst/base/gstbasesrc.c: (gst_base_src_loop):
+       Small documentation cleanup.
+
+       * libs/gst/base/gstbasetransform.c:
+       (gst_base_transform_buffer_alloc):
+       Don't use silly gst_pad_get_negotiated_caps, GST_PAD_CAPS
+       is what we need and it avoids a whole lot of redundant 
+       refcount operations.
+
 2006-06-22  Tim-Philipp Müller  <tim at centricular dot net>
 
        Patch by: Philip Jägenstedt  <philip at lysator liu se>
diff --git a/common b/common
index bbfa014..123195d 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit bbfa0146961f4ca61ddbca7b42360b5741a6354b
+Subproject commit 123195d3bbcc0b6e1cf867d3a180685f8766a0be
index 1a426a9..2298cd9 100644 (file)
@@ -1560,26 +1560,28 @@ gst_caps_load_thyself (xmlNodePtr parent)
  * Replaces *caps with @newcaps.  Unrefs the #GstCaps in the location
  * pointed to by @caps, if applicable, then modifies @caps to point to
  * @newcaps. An additional ref on @newcaps is taken.
+ *
+ * This function does not take any locks so you might want to lock
+ * the object owning @caps pointer.
  */
 void
 gst_caps_replace (GstCaps ** caps, GstCaps * newcaps)
 {
   GstCaps *oldcaps;
 
-#if 0                           /* disable this, since too many plugins rely on undefined behavior */
-#ifdef USE_POISONING
-  //if (newcaps) CAPS_POISON (newcaps);
-#endif
-#endif
+  g_return_if_fail (caps != NULL);
+
   oldcaps = *caps;
 
-  if (newcaps)
-    gst_caps_ref (newcaps);
+  if (newcaps != oldcaps) {
+    if (newcaps)
+      gst_caps_ref (newcaps);
 
-  *caps = newcaps;
+    *caps = newcaps;
 
-  if (oldcaps)
-    gst_caps_unref (oldcaps);
+    if (oldcaps)
+      gst_caps_unref (oldcaps);
+  }
 }
 
 /**
index 43ff757..75888bd 100644 (file)
@@ -111,7 +111,6 @@ enum
   PROP_0,
   PROP_DELAY,
   PROP_AUTO_FLUSH_BUS
-      /* FILL ME */
 };
 
 #define GST_PIPELINE_GET_PRIVATE(obj)  \
@@ -320,7 +319,6 @@ gst_pipeline_get_property (GObject * object, guint prop_id,
  * A flushing seek also resets the stream time to 0 so that when
  * we go back to PLAYING after the seek, the base_time is recalculated
  * and redistributed to the elements.
- *
  */
 static gboolean
 do_pipeline_seek (GstElement * element, GstEvent * event)
@@ -506,8 +504,9 @@ gst_pipeline_change_state (GstElement * element, GstStateChange transition)
 
       if (need_reset)
         gst_pipeline_set_new_stream_time (pipeline, 0);
-    }
+
       break;
+    }
     case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
       break;
     case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
@@ -734,7 +733,7 @@ gst_pipeline_use_clock (GstPipeline * pipeline, GstClock * clock)
  * @clock: the clock to set
  *
  * Set the clock for @pipeline. The clock will be distributed
- * to all the elements managed by the pipeline.
+ * to all the elements managed by the pipeline. 
  *
  * Returns: TRUE if the clock could be set on the pipeline. FALSE if
  *   some element did not accept the clock.
index 7102cf5..2032afe 100644 (file)
@@ -1530,7 +1530,8 @@ pause:
           src->priv->last_sent_eos = TRUE;
         }
       } else {
-        /* for fatal errors we post an error message */
+        /* for fatal errors we post an error message, post the error
+         * first so the app knows about the error first. */
         GST_ELEMENT_ERROR (src, STREAM, FAILED,
             (_("Internal data flow error.")),
             ("streaming task paused, reason %s", reason));
index 51562c6..ada3cf2 100644 (file)
@@ -1041,32 +1041,31 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
         buf);
   } else {
     /* if we are configured, request a buffer with the src caps */
-    GstCaps *srccaps = gst_pad_get_negotiated_caps (trans->srcpad);
-    GstCaps *sinkcaps = gst_pad_get_negotiated_caps (trans->sinkpad);
+    GstCaps *srccaps;
+    GstCaps *sinkcaps;
 
+    srccaps = GST_PAD_CAPS (trans->srcpad);
     if (!srccaps)
       goto not_configured;
 
+    sinkcaps = GST_PAD_CAPS (trans->sinkpad);
     if (sinkcaps != NULL) {
       if (sinkcaps != caps || !gst_caps_is_equal (sinkcaps, caps)) {
         gst_caps_unref (sinkcaps);
         gst_caps_unref (srccaps);
         goto not_configured;
       }
-      gst_caps_unref (sinkcaps);
     }
 
     GST_DEBUG_OBJECT (trans, "calling transform_size");
     if (!gst_base_transform_transform_size (trans,
             GST_PAD_DIRECTION (pad), caps, size, srccaps, &new_size)) {
-      gst_caps_unref (srccaps);
       goto unknown_size;
     }
 
     res =
         gst_pad_alloc_buffer_and_set_caps (trans->srcpad, offset, new_size,
         srccaps, buf);
-    gst_caps_unref (srccaps);
   }
 
   if (res == GST_FLOW_OK && !trans->have_same_caps) {
@@ -1075,19 +1074,19 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
        the alloc_buffer served to transmit caps information but we can't use the
        buffer. fall through and allocate a buffer corresponding to our sink
        caps, if any */
-    GstCaps *sinkcaps = gst_pad_get_negotiated_caps (trans->sinkpad);
-    GstCaps *srccaps = gst_pad_get_negotiated_caps (trans->srcpad);
+    GstCaps *sinkcaps;
+    GstCaps *srccaps;
 
+    sinkcaps = GST_PAD_CAPS (trans->sinkpad);
     if (!sinkcaps)
       goto not_configured;
 
+    srccaps = GST_PAD_CAPS (trans->srcpad);
+
     if (!gst_base_transform_transform_size (trans,
             GST_PAD_DIRECTION (trans->srcpad), srccaps, GST_BUFFER_SIZE (*buf),
-            sinkcaps, &new_size)) {
-      gst_caps_unref (srccaps);
-      gst_caps_unref (sinkcaps);
+            sinkcaps, &new_size))
       goto unknown_size;
-    }
 
     gst_buffer_unref (*buf);
 
@@ -1095,9 +1094,6 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
     gst_buffer_set_caps (*buf, sinkcaps);
     GST_BUFFER_OFFSET (*buf) = offset;
     res = GST_FLOW_OK;
-
-    gst_caps_unref (srccaps);
-    gst_caps_unref (sinkcaps);
   }
 
 done: