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.
This commit is contained in:
Wim Taymans 2006-06-22 13:51:19 +00:00
parent 33d4367def
commit ccb2e93a3a
6 changed files with 46 additions and 30 deletions

View file

@ -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> 2006-06-22 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Philip Jägenstedt <philip at lysator liu se> Patch by: Philip Jägenstedt <philip at lysator liu se>

2
common

@ -1 +1 @@
Subproject commit bbfa0146961f4ca61ddbca7b42360b5741a6354b Subproject commit 123195d3bbcc0b6e1cf867d3a180685f8766a0be

View file

@ -1560,26 +1560,28 @@ gst_caps_load_thyself (xmlNodePtr parent)
* Replaces *caps with @newcaps. Unrefs the #GstCaps in the location * Replaces *caps with @newcaps. Unrefs the #GstCaps in the location
* pointed to by @caps, if applicable, then modifies @caps to point to * pointed to by @caps, if applicable, then modifies @caps to point to
* @newcaps. An additional ref on @newcaps is taken. * @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 void
gst_caps_replace (GstCaps ** caps, GstCaps * newcaps) gst_caps_replace (GstCaps ** caps, GstCaps * newcaps)
{ {
GstCaps *oldcaps; GstCaps *oldcaps;
#if 0 /* disable this, since too many plugins rely on undefined behavior */ g_return_if_fail (caps != NULL);
#ifdef USE_POISONING
//if (newcaps) CAPS_POISON (newcaps);
#endif
#endif
oldcaps = *caps; oldcaps = *caps;
if (newcaps) if (newcaps != oldcaps) {
gst_caps_ref (newcaps); if (newcaps)
gst_caps_ref (newcaps);
*caps = newcaps; *caps = newcaps;
if (oldcaps) if (oldcaps)
gst_caps_unref (oldcaps); gst_caps_unref (oldcaps);
}
} }
/** /**

View file

@ -111,7 +111,6 @@ enum
PROP_0, PROP_0,
PROP_DELAY, PROP_DELAY,
PROP_AUTO_FLUSH_BUS PROP_AUTO_FLUSH_BUS
/* FILL ME */
}; };
#define GST_PIPELINE_GET_PRIVATE(obj) \ #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 * 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 * we go back to PLAYING after the seek, the base_time is recalculated
* and redistributed to the elements. * and redistributed to the elements.
*
*/ */
static gboolean static gboolean
do_pipeline_seek (GstElement * element, GstEvent * event) do_pipeline_seek (GstElement * element, GstEvent * event)
@ -506,8 +504,9 @@ gst_pipeline_change_state (GstElement * element, GstStateChange transition)
if (need_reset) if (need_reset)
gst_pipeline_set_new_stream_time (pipeline, 0); gst_pipeline_set_new_stream_time (pipeline, 0);
}
break; break;
}
case GST_STATE_CHANGE_PAUSED_TO_PLAYING: case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break; break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED: case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
@ -734,7 +733,7 @@ gst_pipeline_use_clock (GstPipeline * pipeline, GstClock * clock)
* @clock: the clock to set * @clock: the clock to set
* *
* Set the clock for @pipeline. The clock will be distributed * 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 * Returns: TRUE if the clock could be set on the pipeline. FALSE if
* some element did not accept the clock. * some element did not accept the clock.

View file

@ -1530,7 +1530,8 @@ pause:
src->priv->last_sent_eos = TRUE; src->priv->last_sent_eos = TRUE;
} }
} else { } 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, GST_ELEMENT_ERROR (src, STREAM, FAILED,
(_("Internal data flow error.")), (_("Internal data flow error.")),
("streaming task paused, reason %s", reason)); ("streaming task paused, reason %s", reason));

View file

@ -1041,32 +1041,31 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
buf); buf);
} else { } else {
/* if we are configured, request a buffer with the src caps */ /* if we are configured, request a buffer with the src caps */
GstCaps *srccaps = gst_pad_get_negotiated_caps (trans->srcpad); GstCaps *srccaps;
GstCaps *sinkcaps = gst_pad_get_negotiated_caps (trans->sinkpad); GstCaps *sinkcaps;
srccaps = GST_PAD_CAPS (trans->srcpad);
if (!srccaps) if (!srccaps)
goto not_configured; goto not_configured;
sinkcaps = GST_PAD_CAPS (trans->sinkpad);
if (sinkcaps != NULL) { if (sinkcaps != NULL) {
if (sinkcaps != caps || !gst_caps_is_equal (sinkcaps, caps)) { if (sinkcaps != caps || !gst_caps_is_equal (sinkcaps, caps)) {
gst_caps_unref (sinkcaps); gst_caps_unref (sinkcaps);
gst_caps_unref (srccaps); gst_caps_unref (srccaps);
goto not_configured; goto not_configured;
} }
gst_caps_unref (sinkcaps);
} }
GST_DEBUG_OBJECT (trans, "calling transform_size"); GST_DEBUG_OBJECT (trans, "calling transform_size");
if (!gst_base_transform_transform_size (trans, if (!gst_base_transform_transform_size (trans,
GST_PAD_DIRECTION (pad), caps, size, srccaps, &new_size)) { GST_PAD_DIRECTION (pad), caps, size, srccaps, &new_size)) {
gst_caps_unref (srccaps);
goto unknown_size; goto unknown_size;
} }
res = res =
gst_pad_alloc_buffer_and_set_caps (trans->srcpad, offset, new_size, gst_pad_alloc_buffer_and_set_caps (trans->srcpad, offset, new_size,
srccaps, buf); srccaps, buf);
gst_caps_unref (srccaps);
} }
if (res == GST_FLOW_OK && !trans->have_same_caps) { 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 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 buffer. fall through and allocate a buffer corresponding to our sink
caps, if any */ caps, if any */
GstCaps *sinkcaps = gst_pad_get_negotiated_caps (trans->sinkpad); GstCaps *sinkcaps;
GstCaps *srccaps = gst_pad_get_negotiated_caps (trans->srcpad); GstCaps *srccaps;
sinkcaps = GST_PAD_CAPS (trans->sinkpad);
if (!sinkcaps) if (!sinkcaps)
goto not_configured; goto not_configured;
srccaps = GST_PAD_CAPS (trans->srcpad);
if (!gst_base_transform_transform_size (trans, if (!gst_base_transform_transform_size (trans,
GST_PAD_DIRECTION (trans->srcpad), srccaps, GST_BUFFER_SIZE (*buf), GST_PAD_DIRECTION (trans->srcpad), srccaps, GST_BUFFER_SIZE (*buf),
sinkcaps, &new_size)) { sinkcaps, &new_size))
gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps);
goto unknown_size; goto unknown_size;
}
gst_buffer_unref (*buf); 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_set_caps (*buf, sinkcaps);
GST_BUFFER_OFFSET (*buf) = offset; GST_BUFFER_OFFSET (*buf) = offset;
res = GST_FLOW_OK; res = GST_FLOW_OK;
gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps);
} }
done: done: