From ccb2e93a3a79e46b5c8ebbb1311d10ed9508a1d0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 22 Jun 2006 13:51:19 +0000 Subject: [PATCH] gst/gstcaps.c: Fix crasher when passed NULL. Doc clarification. 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 | 18 ++++++++++++++++++ common | 2 +- gst/gstcaps.c | 22 ++++++++++++---------- gst/gstpipeline.c | 7 +++---- libs/gst/base/gstbasesrc.c | 3 ++- libs/gst/base/gstbasetransform.c | 24 ++++++++++-------------- 6 files changed, 46 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89cb177bec..d3af4f5707 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2006-06-22 Wim Taymans + + * 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 Patch by: Philip Jägenstedt diff --git a/common b/common index bbfa014696..123195d3bb 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit bbfa0146961f4ca61ddbca7b42360b5741a6354b +Subproject commit 123195d3bbcc0b6e1cf867d3a180685f8766a0be diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 1a426a91fa..2298cd90cb 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -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); + } } /** diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index 43ff757951..75888bd348 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -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. diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 7102cf5f6f..2032afe763 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -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)); diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 51562c6aca..ada3cf2169 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -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: