gst/: Make gst_caps_replace() work like other _replace() functions.

Original commit message from CVS:
* 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()
This commit is contained in:
Wim Taymans 2005-04-20 09:10:42 +00:00
parent 0aec4592b9
commit ee13415b38
13 changed files with 95 additions and 37 deletions

View file

@ -1,3 +1,37 @@
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_/.

View file

@ -669,7 +669,7 @@ gst_basesink_chain_unlocked (GstPad * pad, GstBuffer * buf)
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:

View file

@ -90,7 +90,10 @@ helper_find_suggest (gpointer data, guint probability, const GstCaps * caps)
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;
}
}

View file

@ -581,7 +581,7 @@ find_suggest (gpointer data, guint probability, const GstCaps * caps)
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);
}
}

View file

@ -74,8 +74,7 @@ _gst_buffer_sub_free (GstBuffer * buffer)
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));
@ -106,8 +105,7 @@ gst_buffer_default_free (GstBuffer * 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));
@ -167,6 +165,8 @@ gst_buffer_default_copy (GstBuffer * 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;
}
@ -297,22 +297,9 @@ gst_buffer_get_caps (GstBuffer * buffer)
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);
}
/**

View file

@ -27,7 +27,7 @@
#include "gstatomic_impl.h"
#include <gst/gst.h>
//#define DEBUG_REFCOUNT
/* #define DEBUG_REFCOUNT */
#define CAPS_POISON(caps) G_STMT_START{ \
if (caps) { \
@ -311,6 +311,7 @@ gst_caps_ref (GstCaps * 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);
@ -328,13 +329,14 @@ void
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);
@ -1472,14 +1474,22 @@ gst_caps_load_thyself (xmlNodePtr parent)
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);
}
/**

View file

@ -143,9 +143,11 @@ gst_message_new (GstMessageType type, GstObject * src)
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;
}
@ -266,8 +268,9 @@ gst_message_new_state_changed (GstObject * src, GstElementState old,
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;

View file

@ -1459,10 +1459,10 @@ gst_pad_link_prepare_filtered (GstPad * srcpad, GstPad * sinkpad,
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);
@ -1776,10 +1776,10 @@ gst_pad_relink_filtered (GstPad * srcpad, GstPad * sinkpad,
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);
@ -2155,8 +2155,8 @@ gst_pad_set_caps (GstPad * pad, GstCaps * caps)
}
}
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);
@ -3312,6 +3312,23 @@ gst_pad_template_new (const gchar * name_template,
return new;
}
/**
* 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.

View file

@ -601,6 +601,7 @@ GstPadTemplate* gst_pad_template_new (const gchar *name_template,
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

View file

@ -249,7 +249,7 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
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;

View file

@ -669,7 +669,7 @@ gst_basesink_chain_unlocked (GstPad * pad, GstBuffer * buf)
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:

View file

@ -90,7 +90,10 @@ helper_find_suggest (gpointer data, guint probability, const GstCaps * caps)
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;
}
}

View file

@ -581,7 +581,7 @@ find_suggest (gpointer data, guint probability, const GstCaps * caps)
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);
}
}