warning fixes gst_object_set_name (name, NULL) uniquifies the name globally

Original commit message from CVS:
* warning fixes
* gst_object_set_name (name, NULL) uniquifies the name globally
- needs robusticizing
* gst_elementfactory_make can now take NULL as a second argument
This commit is contained in:
Andy Wingo 2002-02-20 21:31:16 +00:00
parent 7199c36c7f
commit 6ff6eb1017
10 changed files with 87 additions and 69 deletions

View file

@ -165,7 +165,6 @@ static void
gst_spider_identity_chain (GstPad *pad, GstBuffer *buf)
{
GstSpiderIdentity *ident;
GstPad *peerpad;
/* g_print ("chaining on pad %s:%s with buffer %p\n", GST_DEBUG_PAD_NAME (pad), buf); */
@ -188,7 +187,7 @@ gst_spider_identity_chain (GstPad *pad, GstBuffer *buf)
list = g_list_next (list);
if (conn->sink == ident && (GstElement *) conn->src != conn->current)
{
gst_element_set_eos (conn->src);
gst_element_set_eos (GST_ELEMENT (conn->src));
gst_pad_push (conn->src->src, gst_event_new (GST_EVENT_EOS));
}
}

View file

@ -237,6 +237,7 @@ init_post (void)
{
GLogLevelFlags llf;
gboolean showhelp = FALSE;
const gchar *plugin_path;
#ifndef GST_DISABLE_TRACE
GstTrace *gst_trace;
#endif
@ -259,11 +260,8 @@ init_post (void)
gst_autoplugfactory_get_type ();
#endif
/* check for ENV variables */
{
const gchar *plugin_path = g_getenv("GST_PLUGIN_PATH");
split_and_iterate (plugin_path, G_SEARCHPATH_SEPARATOR_S, add_path_func);
}
plugin_path = g_getenv("GST_PLUGIN_PATH");
split_and_iterate (plugin_path, G_SEARCHPATH_SEPARATOR_S, add_path_func);
_gst_cpu_initialize ();
_gst_props_initialize ();

View file

@ -198,7 +198,6 @@ static void
gst_bin_distribute_clocks (GstBin *bin)
{
GList *needing = NULL, *providing = NULL;
GstElement *provider;
GstClock *clock;
gst_bin_get_clock_elements (bin, &needing, &providing);
@ -632,8 +631,8 @@ gst_bin_set_state_type (GstBin * bin, GstElementState state, GType type)
{
GstBinClass *oclass;
GST_DEBUG (GST_CAT_STATES, "gst_bin_set_state_type(\"%s\",%d,%d)\n",
GST_ELEMENT_NAME (bin), state, type);
GST_DEBUG (GST_CAT_STATES, "gst_bin_set_state_type(\"%s\",%d,%s)\n",
GST_ELEMENT_NAME (bin), state, G_OBJECT_TYPE_NAME (type));
g_return_val_if_fail (bin != NULL, FALSE);
g_return_val_if_fail (GST_IS_BIN (bin), FALSE);

View file

@ -208,7 +208,6 @@ gst_element_set_name (GstElement *element, const gchar *name)
{
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (name != NULL);
gst_object_set_name (GST_OBJECT (element), name);
}
@ -277,8 +276,6 @@ gst_element_get_parent (GstElement *element)
void
gst_element_set_clock (GstElement *element, GstClock *clock)
{
GstElementClass *oclass;
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
@ -764,7 +761,7 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, GstCa
{
GList *pads;
GstPadTemplate *templ;
GstCaps *intersection, *templcaps;
GstCaps *templcaps;
GstPad *foundpad = NULL;
/* checks */
@ -1055,28 +1052,31 @@ gst_element_disconnect (GstElement *src, const gchar *srcpadname,
/**
* gst_element_disconnect_elements:
* @src: element 1
* @dest: element 2
* @src: source element
* @dest: sink element
*
* Disconnect all pads connecting the two elements.
* Disconnect all pads connecting the two elements in the direction src -> dest.
*/
void
gst_element_disconnect_elements (GstElement *src, GstElement *dest)
{
GstPad *src, *dst;
GList *srcpads, *destpads, *l;
GList *srcpads;
GstPad *pad;
g_return_if_fail (GST_IS_ELEMENT(src));
g_return_if_fail (GST_IS_ELEMENT(dest));
/* loop through the existing pads in the source */
srcpads = gst_element_get_pad_list (src);
destpads = gst_element_get_pad_list (dest);
for (; srcpads; srcpads=srcpads->next)
for (l=destpads; l; l=l->next)
if (GST_PAD_PEER ((GstPad*) srcpads->data) == (GstPad*) l->data)
gst_pad_disconnect ((GstPad*) srcpads->data, (GstPad*) l->data);
while (srcpads) {
pad = GST_PAD (srcpads->data);
if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
if (GST_OBJECT_PARENT (GST_PAD_PEER (pad)) == (GstObject*) dest)
gst_pad_disconnect (pad, GST_PAD_PEER (pad));
srcpads = g_list_next (srcpads);
}
}
static void
@ -1429,9 +1429,8 @@ static void
gst_element_dispose (GObject *object)
{
GstElement *element = GST_ELEMENT (object);
GList *pads, *test;
GList *pads;
GstPad *pad;
gint i;
GST_DEBUG_ELEMENT (GST_CAT_REFCOUNTING, element, "dispose\n");
@ -1487,7 +1486,6 @@ gst_element_save_thyself (GstObject *object,
gint nspecs, i;
GValue value = { 0, };
GstElement *element;
gchar *str;
g_return_val_if_fail (GST_IS_ELEMENT (object), parent);

View file

@ -196,10 +196,8 @@ gst_elementfactory_new (const gchar *name, GType type,
if (!factory->type)
factory->type = type;
else if (factory->type != type)
/* FIXME: g_critical is glib-2.0, not glib-1.2
g_critical ("`%s' requested type change (!)", name);
*/
g_warning ("`%s' requested type change (!)", name);
gst_object_set_name (GST_OBJECT (factory), name);
return factory;
@ -224,7 +222,6 @@ gst_elementfactory_create (GstElementFactory *factory,
GstElementClass *oclass;
g_return_val_if_fail(factory != NULL, NULL);
g_return_val_if_fail(name != NULL, NULL);
GST_DEBUG (GST_CAT_ELEMENTFACTORY,"creating element from factory \"%s\" with name \"%s\" and type %d\n",
GST_OBJECT_NAME (factory), name, factory->type);
@ -233,10 +230,7 @@ gst_elementfactory_create (GstElementFactory *factory,
return NULL;
if (factory->type == 0) {
/* FIXME: g_critical is glib-2.0, not glib-1.2
g_critical ("Factory for `%s' has no type",
*/
g_warning ("Factory for `%s' has no type",
gst_object_get_name (GST_OBJECT (factory)));
return NULL;
}
@ -279,7 +273,6 @@ gst_elementfactory_make (const gchar *factoryname, const gchar *name)
GstElement *element;
g_return_val_if_fail (factoryname != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
GST_DEBUG (GST_CAT_ELEMENTFACTORY, "gstelementfactory: make \"%s\" \"%s\"\n", factoryname, name);

View file

@ -46,6 +46,8 @@ enum {
};
GType _gst_object_type = 0;
static GHashTable *object_name_counts = NULL;
G_LOCK_DEFINE_STATIC (object_name_mutex);
typedef struct _GstSignalObject GstSignalObject;
typedef struct _GstSignalObjectClass GstSignalObjectClass;
@ -265,6 +267,36 @@ gst_object_finalize (GObject *object)
parent_class->finalize (object);
}
static void
gst_object_set_name_default (GstObject *object)
{
gint count;
gchar *name;
const gchar *type_name, *subname;
type_name = G_OBJECT_TYPE_NAME (object);
G_LOCK (object_name_mutex);
if (!object_name_counts)
object_name_counts = g_hash_table_new (g_str_hash, g_str_equal);
count = GPOINTER_TO_INT (g_hash_table_lookup (object_name_counts, type_name));
g_hash_table_insert (object_name_counts, g_strdup (type_name), GINT_TO_POINTER (++count));
G_UNLOCK (object_name_mutex);
/* GstFooSink -> sinkN */
subname = type_name + strlen (type_name) - 1;
while (g_ascii_islower (*subname) && subname > type_name)
subname--;
name = g_strdup_printf ("%s%d", subname, count);
*name = g_ascii_tolower (*name);
gst_object_set_name (object, name);
g_free (name);
}
/**
* gst_object_set_name:
* @object: GstObject to set the name of
@ -277,12 +309,14 @@ gst_object_set_name (GstObject *object, const gchar *name)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
g_return_if_fail (name != NULL);
if (object->name != NULL)
g_free (object->name);
object->name = g_strdup (name);
if (name != NULL)
object->name = g_strdup (name);
else
gst_object_set_name_default (object);
}
/**
@ -531,8 +565,6 @@ gst_object_restore_thyself (GstObject *object, xmlNodePtr self)
static void
gst_object_real_restore_thyself (GstObject *object, xmlNodePtr self)
{
GstObjectClass *oclass;
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
g_return_if_fail (self != NULL);

View file

@ -265,7 +265,7 @@ struct _GstGhostPadClass {
#define GST_PAD_REALIZE(pad) (GST_IS_REAL_PAD(pad) ? ((GstRealPad *)(pad)) : GST_GPAD_REALPAD(pad))
#define GST_PAD_DIRECTION(pad) GST_RPAD_DIRECTION(GST_PAD_REALIZE(pad))
#define GST_PAD_CAPS(pad) GST_RPAD_CAPS(GST_PAD_REALIZE(pad))
#define GST_PAD_PEER(pad) GST_RPAD_PEER(GST_PAD_REALIZE(pad))
#define GST_PAD_PEER(pad) GST_PAD_CAST(GST_RPAD_PEER(GST_PAD_REALIZE(pad)))
/* Some check functions (unused?) */
#define GST_PAD_IS_CONNECTED(pad) (GST_PAD_PEER(pad) != NULL)

View file

@ -41,7 +41,6 @@ struct _gst_parse_priv
guint bincount;
guint threadcount;
gint binlevel;
GHashTable *elementcounts;
gboolean verbose;
gboolean debug;
};
@ -75,20 +74,6 @@ dynamic_connect (GstElement * element, GstPad * newpad, gpointer data)
}
}
static gchar *
gst_parse_unique_name (const gchar * type, gst_parse_priv * priv)
{
gpointer tmp;
gint count;
tmp = g_hash_table_lookup (priv->elementcounts, type);
count = GPOINTER_TO_INT (tmp);
count++;
g_hash_table_insert (priv->elementcounts, g_strdup (type), GINT_TO_POINTER (count));
return g_strdup_printf ("%s%d", type, count - 1);
}
static gint
gst_parse_launchv_recurse (const gchar **argv, GstBin * parent, gst_parse_priv * priv)
{
@ -110,7 +95,6 @@ gst_parse_launchv_recurse (const gchar **argv, GstBin * parent, gst_parse_priv *
if (!priv) {
priv = g_new0 (gst_parse_priv, 1);
priv->elementcounts = g_hash_table_new (g_str_hash, g_str_equal);
}
priv->binlevel++;
@ -297,7 +281,8 @@ gst_parse_launchv_recurse (const gchar **argv, GstBin * parent, gst_parse_priv *
if (arg[0] == '(') {
/* create a bin and add it to the current parent */
element = gst_bin_new (g_strdup_printf ("bin%d", priv->bincount++));
priv->bincount++;
element = gst_elementfactory_make ("bin", NULL);
if (!element) {
fprintf (stderr, "Couldn't create a bin!\n");
return GST_PARSE_ERROR_CREATING_ELEMENT;
@ -305,7 +290,8 @@ gst_parse_launchv_recurse (const gchar **argv, GstBin * parent, gst_parse_priv *
GST_DEBUG (0, "CREATED bin %s\n", GST_ELEMENT_NAME (element));
} else if (arg[0] == '{') {
/* create a thread and add it to the current parent */
element = gst_thread_new (g_strdup_printf ("thread%d", priv->threadcount++));
priv->threadcount++;
element = gst_elementfactory_make ("thread", NULL);
if (!element) {
fprintf (stderr, "Couldn't create a thread!\n");
return GST_PARSE_ERROR_CREATING_ELEMENT;
@ -330,9 +316,7 @@ gst_parse_launchv_recurse (const gchar **argv, GstBin * parent, gst_parse_priv *
/* we have an element */
DEBUG ("attempting to create element '%s'\n", arg);
ptr = gst_parse_unique_name (arg, priv);
element = gst_elementfactory_make (arg, ptr);
g_free (ptr);
element = gst_elementfactory_make (arg, NULL);
if (!element) {
#ifndef GST_DISABLE_REGISTRY
fprintf (stderr,

View file

@ -65,7 +65,6 @@ _gst_plugin_initialize (void)
struct stat stat_buf;
#ifndef GST_DISABLE_REGISTRY
xmlDocPtr doc = NULL;
xmlNodePtr root;
#endif
main_module = g_module_open (NULL, G_MODULE_BIND_LAZY);
@ -692,7 +691,7 @@ gst_plugin_find_feature_func (GstPlugin *plugin, const gchar *name, GType type)
return NULL;
}
static GstPluginFeature*
G_GNUC_UNUSED static GstPluginFeature*
gst_plugin_find_feature (const gchar *name, GType type)
{
GList *plugins;

View file

@ -54,7 +54,7 @@ _gst_props_initialize (void)
static void
gst_props_debug_entry (GstPropsEntry *entry)
{
gchar *name = g_quark_to_string (entry->propid);
const gchar *name = g_quark_to_string (entry->propid);
switch (entry->propstype) {
case GST_PROPS_INT_ID:
@ -641,7 +641,6 @@ GstProps*
gst_props_copy (GstProps *props)
{
GstProps *new;
GList *properties;
if (props == NULL)
return NULL;
@ -910,6 +909,7 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
case GST_PROPS_INT_RANGE_ID:
return (entry2->data.int_range_data.min <= entry1->data.int_range_data.min &&
entry2->data.int_range_data.max >= entry1->data.int_range_data.max);
default:
}
break;
case GST_PROPS_FLOAT_RANGE_ID:
@ -918,6 +918,7 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
case GST_PROPS_FLOAT_RANGE_ID:
return (entry2->data.float_range_data.min <= entry1->data.float_range_data.min &&
entry2->data.float_range_data.max >= entry1->data.float_range_data.max);
default:
}
break;
case GST_PROPS_FOURCC_ID:
@ -925,8 +926,9 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
/* b <---> a */
case GST_PROPS_FOURCC_ID:
GST_DEBUG(GST_CAT_PROPERTIES,"\"%4.4s\" <--> \"%4.4s\" ?\n",
&entry2->data.fourcc_data, &entry1->data.fourcc_data);
(char*) &entry2->data.fourcc_data, (char*) &entry1->data.fourcc_data);
return (entry2->data.fourcc_data == entry1->data.fourcc_data);
default:
}
break;
case GST_PROPS_INT_ID:
@ -941,6 +943,7 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
case GST_PROPS_INT_ID:
GST_DEBUG(GST_CAT_PROPERTIES,"%d == %d ?\n",entry1->data.int_data,entry2->data.int_data);
return (entry2->data.int_data == entry1->data.int_data);
default:
}
break;
case GST_PROPS_FLOAT_ID:
@ -952,6 +955,7 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
/* b <---> a */
case GST_PROPS_FLOAT_ID:
return (entry2->data.float_data == entry1->data.float_data);
default:
}
break;
case GST_PROPS_BOOL_ID:
@ -959,6 +963,7 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
/* t <---> t */
case GST_PROPS_BOOL_ID:
return (entry2->data.bool_data == entry1->data.bool_data);
default:
}
case GST_PROPS_STRING_ID:
switch (entry2->propstype) {
@ -967,7 +972,9 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
GST_DEBUG(GST_CAT_PROPERTIES,"\"%s\" <--> \"%s\" ?\n",
entry2->data.string_data.string, entry1->data.string_data.string);
return (!strcmp (entry2->data.string_data.string, entry1->data.string_data.string));
default:
}
default:
}
return FALSE;
@ -1056,6 +1063,7 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
entry1 = entry2;
entry2 = temp;
}
default:
}
switch (entry1->propstype) {
@ -1129,6 +1137,7 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
entry1->data.int_range_data.max >= entry2->data.int_data) {
result = gst_props_entry_copy (entry2);
}
default:
}
break;
case GST_PROPS_FLOAT_RANGE_ID:
@ -1160,6 +1169,7 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
entry1->data.float_range_data.max >= entry2->data.float_data) {
result = gst_props_entry_copy (entry2);
}
default:
}
break;
case GST_PROPS_FOURCC_ID:
@ -1168,6 +1178,7 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
case GST_PROPS_FOURCC_ID:
if (entry1->data.fourcc_data == entry2->data.fourcc_data)
result = gst_props_entry_copy (entry1);
default:
}
break;
case GST_PROPS_INT_ID:
@ -1176,6 +1187,7 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
case GST_PROPS_INT_ID:
if (entry1->data.int_data == entry2->data.int_data)
result = gst_props_entry_copy (entry1);
default:
}
break;
case GST_PROPS_FLOAT_ID:
@ -1184,6 +1196,7 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
case GST_PROPS_FLOAT_ID:
if (entry1->data.float_data == entry2->data.float_data)
result = gst_props_entry_copy (entry1);
default:
}
break;
case GST_PROPS_BOOL_ID:
@ -1192,6 +1205,7 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
case GST_PROPS_BOOL_ID:
if (entry1->data.bool_data == entry2->data.bool_data)
result = gst_props_entry_copy (entry1);
default:
}
case GST_PROPS_STRING_ID:
switch (entry2->propstype) {
@ -1199,7 +1213,9 @@ gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
case GST_PROPS_STRING_ID:
if (!strcmp (entry1->data.string_data.string, entry2->data.string_data.string))
result = gst_props_entry_copy (entry1);
default:
}
default:
}
return result;