+2005-04-20 Wim Taymans <wim@fluendo.com>
+
+ * gst/base/gstbasesink.c: (gst_basesink_base_init),
+ (gst_basesink_pad_getcaps), (gst_basesink_init),
+ (gst_basesink_chain_unlocked):
+ * gst/base/gsttypefindhelper.c: (helper_find_suggest),
+ (gst_type_find_helper):
+ * gst/elements/gsttypefindelement.c:
+ (gst_type_find_element_have_type), (gst_type_find_element_init),
+ (stop_typefinding), (gst_type_find_element_handle_event),
+ (find_suggest), (gst_type_find_element_chain),
+ (gst_type_find_element_checkgetrange),
+ (gst_type_find_element_getrange), (do_typefind),
+ (gst_type_find_element_activate):
+ * gst/gstbuffer.c: (_gst_buffer_sub_free),
+ (gst_buffer_default_free), (gst_buffer_default_copy),
+ (gst_buffer_set_caps):
+ * gst/gstcaps.c: (gst_caps_ref), (gst_caps_unref),
+ (gst_caps_replace):
+ * gst/gstmessage.c: (gst_message_new),
+ (gst_message_new_state_changed):
+ * gst/gstpad.c: (gst_pad_set_active), (gst_pad_peer_set_active),
+ (gst_pad_set_checkgetrange_function),
+ (gst_pad_link_prepare_filtered), (gst_pad_relink_filtered),
+ (gst_pad_set_caps), (gst_pad_check_pull_range),
+ (gst_pad_pull_range), (gst_static_pad_template_get_caps):
+ * gst/gstpad.h:
+ * gst/gsttypefind.c: (gst_type_find_register):
+ Make gst_caps_replace() work like other _replace() functions.
+ Use _caps_replace() where possible.
+ Make sure _message_new() initialises its field.
+ Add gst_static_pad_template_get_caps()
+
+
2005-04-18 Andy Wingo <wingo@pobox.com>
* gst/elements/gstfakesrc.c: s/ARG_/PROP_/.
result = gst_basesink_finish_preroll (basesink, pad, buf);
- DEBUG ("chain_unlocked %p after\n", basesink);
+ DEBUG ("chain_unlocked %p after, result %d\n", basesink, result);
switch (result) {
case PREROLL_QUEUEING:
GstTypeFindHelper *find = (GstTypeFindHelper *) data;
if (probability > find->best_probability) {
- gst_caps_replace (&find->caps, gst_caps_copy (caps));
+ GstCaps *copy = gst_caps_copy (caps);
+
+ gst_caps_replace (&find->caps, copy);
+ gst_caps_unref (copy);
find->best_probability = probability;
}
}
GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
- gst_caps_replace (&entry->caps, gst_caps_copy (caps));
+ gst_caps_replace (&entry->caps, (GstCaps *) caps);
}
}
GST_BUFFER_DATA (buffer) = NULL;
GST_BUFFER_SIZE (buffer) = 0;
- if (GST_BUFFER_CAPS (buffer))
- gst_caps_unref (GST_BUFFER_CAPS (buffer));
+ gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL);
_GST_DATA_DISPOSE (GST_DATA (buffer));
/* set to safe values */
GST_BUFFER_DATA (buffer) = NULL;
GST_BUFFER_SIZE (buffer) = 0;
- if (GST_BUFFER_CAPS (buffer))
- gst_caps_unref (GST_BUFFER_CAPS (buffer));
+ gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL);
_GST_DATA_DISPOSE (GST_DATA (buffer));
GST_BUFFER_PRIVATE (copy) = NULL;
if (GST_BUFFER_CAPS (buffer))
GST_BUFFER_CAPS (copy) = gst_caps_ref (GST_BUFFER_CAPS (buffer));
+ else
+ GST_BUFFER_CAPS (copy) = NULL;
return copy;
}
void
gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps)
{
- GstCaps *oldcaps;
-
g_return_if_fail (buffer != NULL);
- /* get old caps */
- oldcaps = GST_BUFFER_CAPS (buffer);
- /* ref new caps if any */
- if (caps)
- caps = gst_caps_ref (caps);
- /* set caps */
- GST_BUFFER_CAPS (buffer) = caps;
-
- /* unref old caps if any */
- if (oldcaps) {
- gst_caps_unref (oldcaps);
- }
+ gst_caps_replace (&GST_BUFFER_CAPS (buffer), caps);
}
/**
#include "gstatomic_impl.h"
#include <gst/gst.h>
-//#define DEBUG_REFCOUNT
+/* #define DEBUG_REFCOUNT */
#define CAPS_POISON(caps) G_STMT_START{ \
if (caps) { \
GST_CAT_LOG (GST_CAT_CAPS, "%p %d->%d", caps,
GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) + 1);
#endif
+ g_return_val_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0, NULL);
gst_atomic_int_inc (&caps->refcount);
gst_caps_unref (GstCaps * caps)
{
g_return_if_fail (caps != NULL);
- g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0);
#ifdef DEBUG_REFCOUNT
GST_CAT_LOG (GST_CAT_CAPS, "%p %d->%d", caps,
GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) - 1);
#endif
+ g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0);
+
/* if we ended up with the refcount at zero, free the caps */
if (gst_atomic_int_dec_and_test (&caps->refcount)) {
_gst_caps_free (caps);
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
- if (*caps)
- gst_caps_unref (*caps);
+ oldcaps = *caps;
+
+ if (newcaps)
+ gst_caps_ref (newcaps);
+
*caps = newcaps;
+
+ if (oldcaps)
+ gst_caps_unref (oldcaps);
}
/**
GST_MESSAGE_TYPE (message) = type;
GST_MESSAGE_TIMESTAMP (message) = G_GINT64_CONSTANT (0);
if (src) {
- gst_object_ref (src);
- GST_MESSAGE_SRC (message) = src;
+ GST_MESSAGE_SRC (message) = gst_object_ref (src);
+ } else {
+ GST_MESSAGE_SRC (message) = NULL;
}
+ message->structure = NULL;
return message;
}
GstStructure *s;
message = gst_message_new (GST_MESSAGE_STATE_CHANGED, src);
- s = gst_structure_new ("GstMessageError", "old-state", G_TYPE_INT, old,
- "new-state", G_TYPE_INT, new, NULL);
+
+ s = gst_structure_new ("GstMessageError", "old-state", G_TYPE_INT, (gint) old,
+ "new-state", G_TYPE_INT, (gint) new, NULL);
message->structure = s;
return message;
GstCaps *filtercopy;
filtercopy = gst_caps_copy (filtercaps);
- filtercopy = gst_caps_ref (filtercopy);
gst_caps_replace (&GST_PAD_APPFILTER (realsrc), filtercopy);
gst_caps_replace (&GST_PAD_APPFILTER (realsink), filtercopy);
+ gst_caps_unref (filtercopy);
} else {
gst_caps_replace (&GST_PAD_APPFILTER (realsrc), NULL);
gst_caps_replace (&GST_PAD_APPFILTER (realsink), NULL);
GstCaps *filtercopy;
filtercopy = gst_caps_copy (filtercaps);
- filtercopy = gst_caps_ref (filtercopy);
gst_caps_replace (&GST_PAD_APPFILTER (realsrc), filtercopy);
gst_caps_replace (&GST_PAD_APPFILTER (realsink), filtercopy);
+ gst_caps_unref (filtercopy);
} else {
gst_caps_replace (&GST_PAD_APPFILTER (realsrc), NULL);
gst_caps_replace (&GST_PAD_APPFILTER (realsink), NULL);
}
}
- if (GST_PAD_CAPS (pad))
- gst_caps_unref (GST_PAD_CAPS (pad));
+ if (GST_RPAD_CAPS (pad))
+ gst_caps_unref (GST_RPAD_CAPS (pad));
if (caps)
caps = gst_caps_ref (caps);
}
/**
+ * gst_static_pad_template_get_caps:
+ * @templ: a #GstStaticPadTemplate to get capabilities of.
+ *
+ * Gets the capabilities of the static pad template.
+ *
+ * Returns: the #GstCaps of the static pad template. If you need to keep a
+ * reference to the caps, take a ref (see gst_caps_ref ()).
+ */
+GstCaps *
+gst_static_pad_template_get_caps (GstStaticPadTemplate * templ)
+{
+ g_return_val_if_fail (templ, NULL);
+
+ return (GstCaps *) gst_static_caps_get (&templ->static_caps);
+}
+
+/**
* gst_pad_template_get_caps:
* @templ: a #GstPadTemplate to get capabilities of.
*
GstCaps *caps);
GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *pad_template);
+GstCaps* gst_static_pad_template_get_caps (GstStaticPadTemplate *templ);
GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
#ifndef GST_DISABLE_LOADSAVE
g_strfreev (factory->extensions);
factory->extensions = g_strdupv (extensions);
- gst_caps_replace (&factory->caps, gst_caps_copy (possible_caps));
+ gst_caps_replace (&factory->caps, (GstCaps *) possible_caps);
factory->function = func;
factory->user_data = data;
result = gst_basesink_finish_preroll (basesink, pad, buf);
- DEBUG ("chain_unlocked %p after\n", basesink);
+ DEBUG ("chain_unlocked %p after, result %d\n", basesink, result);
switch (result) {
case PREROLL_QUEUEING:
GstTypeFindHelper *find = (GstTypeFindHelper *) data;
if (probability > find->best_probability) {
- gst_caps_replace (&find->caps, gst_caps_copy (caps));
+ GstCaps *copy = gst_caps_copy (caps);
+
+ gst_caps_replace (&find->caps, copy);
+ gst_caps_unref (copy);
find->best_probability = probability;
}
}
GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
- gst_caps_replace (&entry->caps, gst_caps_copy (caps));
+ gst_caps_replace (&entry->caps, (GstCaps *) caps);
}
}