mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
gst/: Remove pre glib2.8 compatibility, fixes #340508
Original commit message from CVS: * gst/glib-compat.c: * gst/gst.c: (init_pre): * gst/gstobject.c: (gst_object_init), (gst_object_ref), (gst_object_unref), (gst_object_replace), (gst_object_dispose), (gst_object_dispatch_properties_changed): * gst/gstobject.h: * gst/gstregistryxml.c: (gst_registry_xml_read_cache): * gst/gststructure.c: (gst_structure_set_valist): * gst/gstvalue.c: (gst_date_get_type), (_gst_value_initialize): Remove pre glib2.8 compatibility, fixes #340508
This commit is contained in:
parent
f48364f5ff
commit
ef7f163300
8 changed files with 19 additions and 188 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2006-05-05 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/glib-compat.c:
|
||||
* gst/gst.c: (init_pre):
|
||||
* gst/gstobject.c: (gst_object_init), (gst_object_ref),
|
||||
(gst_object_unref), (gst_object_replace), (gst_object_dispose),
|
||||
(gst_object_dispatch_properties_changed):
|
||||
* gst/gstobject.h:
|
||||
* gst/gstregistryxml.c: (gst_registry_xml_read_cache):
|
||||
* gst/gststructure.c: (gst_structure_set_valist):
|
||||
* gst/gstvalue.c: (gst_date_get_type), (_gst_value_initialize):
|
||||
Remove pre glib2.8 compatibility, fixes #340508
|
||||
|
||||
2006-05-04 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/gsttaglist.h:
|
||||
|
|
|
@ -73,74 +73,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 8, 0)
|
||||
/**
|
||||
* g_mkdir_with_parents:
|
||||
* @pathname: a pathname in the GLib file name encoding
|
||||
* @mode: permissions to use for newly created directories
|
||||
*
|
||||
* Create a directory if it doesn't already exist. Create intermediate
|
||||
* parent directories as needed, too.
|
||||
*
|
||||
* Returns: 0 if the directory already exists, or was successfully
|
||||
* created. Returns -1 if an error occurred, with errno set.
|
||||
*
|
||||
* Since: 2.8
|
||||
*/
|
||||
int
|
||||
g_mkdir_with_parents (const gchar * pathname, int mode)
|
||||
{
|
||||
gchar *fn, *p;
|
||||
|
||||
if (pathname == NULL || *pathname == '\0') {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fn = g_strdup (pathname);
|
||||
|
||||
if (g_path_is_absolute (fn))
|
||||
p = (gchar *) g_path_skip_root (fn);
|
||||
else
|
||||
p = fn;
|
||||
|
||||
do {
|
||||
while (*p && !G_IS_DIR_SEPARATOR (*p))
|
||||
p++;
|
||||
|
||||
if (!*p)
|
||||
p = NULL;
|
||||
else
|
||||
*p = '\0';
|
||||
|
||||
if (!g_file_test (fn, G_FILE_TEST_EXISTS)) {
|
||||
if (g_mkdir (fn, mode) == -1) {
|
||||
int errno_save = errno;
|
||||
|
||||
g_free (fn);
|
||||
errno = errno_save;
|
||||
return -1;
|
||||
}
|
||||
} else if (!g_file_test (fn, G_FILE_TEST_IS_DIR)) {
|
||||
g_free (fn);
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
if (p) {
|
||||
*p++ = G_DIR_SEPARATOR;
|
||||
while (*p && G_IS_DIR_SEPARATOR (*p))
|
||||
p++;
|
||||
}
|
||||
}
|
||||
while (p);
|
||||
|
||||
g_free (fn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* gst_flags_get_first_value:
|
||||
* @flags_class: a #GFlagsClass
|
||||
|
|
11
gst/gst.c
11
gst/gst.c
|
@ -242,10 +242,6 @@ parse_debug_list (const gchar * list)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef GST_HAVE_GLIB_2_8
|
||||
#define G_OPTION_FLAG_NO_ARG 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* gst_init_get_option_group:
|
||||
*
|
||||
|
@ -463,17 +459,10 @@ split_and_iterate (const gchar * stringlist, gchar * separator, GFunc iterator,
|
|||
static gboolean
|
||||
init_pre (void)
|
||||
{
|
||||
#ifdef GST_HAVE_GLIB_2_8
|
||||
/* GStreamer was built against a GLib >= 2.8 and is therefore not doing
|
||||
* the refcount hack. Check that it isn't being run against an older GLib */
|
||||
if (glib_major_version < 2 ||
|
||||
(glib_major_version == 2 && glib_minor_version < 8)) {
|
||||
#else
|
||||
/* GStreamer was built against a GLib < 2.8 and is therefore doing
|
||||
* the refcount hack. Check that it isn't being run against a newer GLib */
|
||||
if (glib_major_version > 2 ||
|
||||
(glib_major_version == 2 && glib_minor_version >= 8)) {
|
||||
#endif
|
||||
g_warning ("GStreamer was compiled against GLib %d.%d.%d but is running"
|
||||
" against %d.%d.%d. This will cause reference counting issues",
|
||||
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
|
||||
|
|
|
@ -96,29 +96,6 @@ static GstAllocTrace *_gst_object_trace;
|
|||
#endif
|
||||
|
||||
#define DEBUG_REFCOUNT
|
||||
#ifndef GST_HAVE_GLIB_2_8
|
||||
#define REFCOUNT_HACK
|
||||
#endif
|
||||
|
||||
/* Refcount hack: since glib < 2.8 is not threadsafe, the glib refcounter can be
|
||||
* screwed up and the object can be freed unexpectedly. We use an evil hack
|
||||
* to work around this problem. We set the glib refcount to a high value so
|
||||
* that glib will never unref the object under realistic circumstances. Then
|
||||
* we use our own atomic refcounting to do proper MT safe refcounting.
|
||||
*
|
||||
* The hack has several side-effect. At first you should use
|
||||
* gst_object_ref/unref() whenever you can. Next when using
|
||||
* g_value_set/get_object(); you need to manually fix the refcount.
|
||||
*
|
||||
* A proper fix is of course to upgrade to glib 2.8
|
||||
*/
|
||||
#ifdef REFCOUNT_HACK
|
||||
#define PATCH_REFCOUNT(obj) ((GObject*)(obj))->ref_count = 100000;
|
||||
#define PATCH_REFCOUNT1(obj) ((GObject*)(obj))->ref_count = 1;
|
||||
#else
|
||||
#define PATCH_REFCOUNT(obj)
|
||||
#define PATCH_REFCOUNT1(obj)
|
||||
#endif
|
||||
|
||||
/* Object signals and args */
|
||||
enum
|
||||
|
@ -314,10 +291,6 @@ gst_object_init (GTypeInstance * instance, gpointer g_class)
|
|||
object->parent = NULL;
|
||||
object->name = NULL;
|
||||
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "%p new", object);
|
||||
#ifdef REFCOUNT_HACK
|
||||
gst_atomic_int_set (&object->refcount, 1);
|
||||
#endif
|
||||
PATCH_REFCOUNT (object);
|
||||
|
||||
#ifndef GST_DISABLE_TRACE
|
||||
gst_alloc_trace_new (_gst_object_trace, object);
|
||||
|
@ -344,27 +317,14 @@ gst_object_init (GTypeInstance * instance, gpointer g_class)
|
|||
gpointer
|
||||
gst_object_ref (gpointer object)
|
||||
{
|
||||
#ifdef REFCOUNT_HACK
|
||||
gint old;
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
|
||||
|
||||
#ifdef REFCOUNT_HACK
|
||||
old = g_atomic_int_exchange_and_add (&((GstObject *) object)->refcount, 1);
|
||||
# ifdef DEBUG_REFCOUNT
|
||||
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "%p ref %d->%d",
|
||||
object, old, old + 1);
|
||||
# endif
|
||||
PATCH_REFCOUNT (object);
|
||||
#else
|
||||
# ifdef DEBUG_REFCOUNT
|
||||
#ifdef DEBUG_REFCOUNT
|
||||
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "%p ref %d->%d",
|
||||
object,
|
||||
((GObject *) object)->ref_count, ((GObject *) object)->ref_count + 1);
|
||||
# endif
|
||||
g_object_ref (object);
|
||||
#endif
|
||||
g_object_ref (object);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
@ -383,27 +343,7 @@ gst_object_ref (gpointer object)
|
|||
void
|
||||
gst_object_unref (gpointer object)
|
||||
{
|
||||
#ifdef REFCOUNT_HACK
|
||||
gint old;
|
||||
#endif
|
||||
g_return_if_fail (GST_IS_OBJECT (object));
|
||||
|
||||
#ifdef REFCOUNT_HACK
|
||||
g_return_if_fail (GST_OBJECT_REFCOUNT_VALUE (object) > 0);
|
||||
|
||||
old = g_atomic_int_exchange_and_add (&((GstObject *) object)->refcount, -1);
|
||||
|
||||
# ifdef DEBUG_REFCOUNT
|
||||
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "%p unref %d->%d",
|
||||
object, old, old - 1);
|
||||
#endif
|
||||
if (G_UNLIKELY (old == 1)) {
|
||||
PATCH_REFCOUNT1 (object);
|
||||
g_object_unref (object);
|
||||
} else {
|
||||
PATCH_REFCOUNT (object);
|
||||
}
|
||||
#else
|
||||
g_return_if_fail (((GObject *) object)->ref_count > 0);
|
||||
|
||||
#ifdef DEBUG_REFCOUNT
|
||||
|
@ -412,7 +352,6 @@ gst_object_unref (gpointer object)
|
|||
((GObject *) object)->ref_count, ((GObject *) object)->ref_count - 1);
|
||||
#endif
|
||||
g_object_unref (object);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -471,19 +410,11 @@ gst_object_replace (GstObject ** oldobj, GstObject * newobj)
|
|||
g_return_if_fail (newobj == NULL || GST_IS_OBJECT (newobj));
|
||||
|
||||
#ifdef DEBUG_REFCOUNT
|
||||
#ifdef REFCOUNT_HACK
|
||||
GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %s (%d) with %s (%d)",
|
||||
*oldobj ? GST_STR_NULL (GST_OBJECT_NAME (*oldobj)) : "(NONE)",
|
||||
*oldobj ? GST_OBJECT_REFCOUNT_VALUE (*oldobj) : 0,
|
||||
newobj ? GST_STR_NULL (GST_OBJECT_NAME (newobj)) : "(NONE)",
|
||||
newobj ? GST_OBJECT_REFCOUNT_VALUE (newobj) : 0);
|
||||
#else
|
||||
GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %s (%d) with %s (%d)",
|
||||
*oldobj ? GST_STR_NULL (GST_OBJECT_NAME (*oldobj)) : "(NONE)",
|
||||
*oldobj ? G_OBJECT (*oldobj)->ref_count : 0,
|
||||
newobj ? GST_STR_NULL (GST_OBJECT_NAME (newobj)) : "(NONE)",
|
||||
newobj ? G_OBJECT (newobj)->ref_count : 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (G_LIKELY (*oldobj != newobj)) {
|
||||
|
@ -511,9 +442,6 @@ gst_object_dispose (GObject * object)
|
|||
GST_OBJECT_PARENT (object) = NULL;
|
||||
GST_OBJECT_UNLOCK (object);
|
||||
|
||||
/* need to patch refcount so it is finalized */
|
||||
PATCH_REFCOUNT1 (object);
|
||||
|
||||
parent_class->dispose (object);
|
||||
|
||||
return;
|
||||
|
@ -526,6 +454,7 @@ have_parent:
|
|||
"object instead of unreffing the object directly.\n",
|
||||
GST_OBJECT_NAME (object), GST_OBJECT_NAME (parent));
|
||||
GST_OBJECT_UNLOCK (object);
|
||||
/* ref the object again to revive it in this error case */
|
||||
object = gst_object_ref (object);
|
||||
return;
|
||||
}
|
||||
|
@ -576,15 +505,9 @@ gst_object_dispatch_properties_changed (GObject * object,
|
|||
|
||||
klass = GST_OBJECT_GET_CLASS (object);
|
||||
|
||||
#ifndef GST_HAVE_GLIB_2_8
|
||||
GST_CLASS_LOCK (klass);
|
||||
#endif
|
||||
|
||||
/* do the standard dispatching */
|
||||
PATCH_REFCOUNT (object);
|
||||
G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs,
|
||||
pspecs);
|
||||
PATCH_REFCOUNT (object);
|
||||
|
||||
gst_object = GST_OBJECT_CAST (object);
|
||||
name = gst_object_get_name (gst_object);
|
||||
|
@ -605,14 +528,9 @@ gst_object_dispatch_properties_changed (GObject * object,
|
|||
GST_CAT_LOG (GST_CAT_EVENT, "deep notification from %s to %s (%s)",
|
||||
debug_name, debug_parent_name, pspecs[i]->name);
|
||||
|
||||
/* not MT safe because of glib, fixed by taking class lock higher up */
|
||||
PATCH_REFCOUNT (parent);
|
||||
PATCH_REFCOUNT (object);
|
||||
g_signal_emit (parent, gst_object_signals[DEEP_NOTIFY],
|
||||
g_quark_from_string (pspecs[i]->name), GST_OBJECT_CAST (object),
|
||||
pspecs[i]);
|
||||
PATCH_REFCOUNT (parent);
|
||||
PATCH_REFCOUNT (object);
|
||||
}
|
||||
g_free (parent_name);
|
||||
|
||||
|
@ -621,10 +539,6 @@ gst_object_dispatch_properties_changed (GObject * object,
|
|||
gst_object_unref (old_parent);
|
||||
}
|
||||
g_free (name);
|
||||
|
||||
#ifndef GST_HAVE_GLIB_2_8
|
||||
GST_CLASS_UNLOCK (klass);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,6 @@ typedef enum
|
|||
GST_OBJECT_FLAG_LAST = (1<<4)
|
||||
} GstObjectFlags;
|
||||
|
||||
#ifdef GST_HAVE_GLIB_2_8
|
||||
/**
|
||||
* GST_OBJECT_REFCOUNT:
|
||||
* @obj: a #GstObject
|
||||
|
@ -76,11 +75,7 @@ typedef enum
|
|||
*
|
||||
* Get the reference count value of the object.
|
||||
*/
|
||||
#define GST_OBJECT_REFCOUNT_VALUE(obj) GST_OBJECT_REFCOUNT(obj)
|
||||
#else
|
||||
#define GST_OBJECT_REFCOUNT(obj) ((GST_OBJECT_CAST(obj))->refcount)
|
||||
#define GST_OBJECT_REFCOUNT_VALUE(obj) (g_atomic_int_get (&(GST_OBJECT_CAST(obj))->refcount))
|
||||
#endif /* GST_HAVE_GLIB_2_8 */
|
||||
#define GST_OBJECT_REFCOUNT_VALUE(obj) g_atomic_int_get (&GST_OBJECT_REFCOUNT(obj))
|
||||
|
||||
/* we do a GST_OBJECT_CAST to avoid type checking, better call these
|
||||
* function with a valid object! */
|
||||
|
@ -186,7 +181,7 @@ typedef struct _GstObjectClass GstObjectClass;
|
|||
|
||||
/**
|
||||
* GstObject:
|
||||
* @refcount: only used ifndef GST_HAVE_GLIB_2_8
|
||||
* @refcount: unused
|
||||
* @lock: object LOCK
|
||||
* @name: The name of the object
|
||||
* @name_prefix: used for debugging
|
||||
|
|
|
@ -466,9 +466,7 @@ load_plugin (xmlTextReaderPtr reader, GList ** feature_list)
|
|||
gboolean
|
||||
gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
|
||||
{
|
||||
#if GLIB_CHECK_VERSION(2,8,0)
|
||||
GMappedFile *mapped = NULL;
|
||||
#endif
|
||||
GTimer *timer;
|
||||
gdouble seconds;
|
||||
xmlTextReaderPtr reader = NULL;
|
||||
|
@ -483,7 +481,6 @@ gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
|
|||
|
||||
timer = g_timer_new ();
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,8,0)
|
||||
mapped = g_mapped_file_new (location, FALSE, NULL);
|
||||
if (mapped) {
|
||||
reader = xmlReaderForMemory (g_mapped_file_get_contents (mapped),
|
||||
|
@ -493,7 +490,6 @@ gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
|
|||
mapped = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (reader == NULL) {
|
||||
file = fopen (location, "r");
|
||||
|
@ -540,10 +536,8 @@ gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
|
|||
xmlFreeTextReader (reader);
|
||||
if (ret != 0) {
|
||||
GST_ERROR ("parsing registry cache: %s", location);
|
||||
#if GLIB_CHECK_VERSION(2,8,0)
|
||||
if (mapped)
|
||||
g_mapped_file_free (mapped);
|
||||
#endif
|
||||
if (file)
|
||||
fclose (file);
|
||||
g_timer_destroy (timer);
|
||||
|
@ -556,10 +550,8 @@ gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
|
|||
|
||||
GST_INFO ("loaded %s in %f seconds", location, seconds);
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,8,0)
|
||||
if (mapped)
|
||||
g_mapped_file_free (mapped);
|
||||
#endif
|
||||
|
||||
if (file)
|
||||
fclose (file);
|
||||
|
|
|
@ -480,12 +480,10 @@ gst_structure_set_valist (GstStructure * structure,
|
|||
|
||||
type = va_arg (varargs, GType);
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,8,0)
|
||||
if (type == G_TYPE_DATE) {
|
||||
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
|
||||
type = GST_TYPE_DATE;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_value_init (&field.value, type);
|
||||
G_VALUE_COLLECT (&field.value, varargs, 0, &err);
|
||||
|
|
|
@ -3792,7 +3792,7 @@ gst_date_get_type (void)
|
|||
/* Not using G_TYPE_DATE here on purpose, even if we could
|
||||
* if GLIB_CHECK_VERSION(2,8,0) was true: we don't want the
|
||||
* serialised strings to have different type strings depending
|
||||
* on what version is used, so FIXME in 0.11 when we
|
||||
* on what version is used, so FIXME when we
|
||||
* require GLib-2.8 */
|
||||
gst_date_type = g_boxed_type_register_static ("GstDate",
|
||||
(GBoxedCopyFunc) gst_date_copy, (GBoxedFreeFunc) g_date_free);
|
||||
|
@ -4023,14 +4023,12 @@ _gst_value_initialize (void)
|
|||
GST_TYPE_FRACTION_RANGE,
|
||||
gst_value_subtract_fraction_range_fraction_range);
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,8,0)
|
||||
/* see bug #317246, #64994, #65041 */
|
||||
{
|
||||
volatile GType date_type = G_TYPE_DATE;
|
||||
|
||||
g_type_name (date_type);
|
||||
}
|
||||
#endif
|
||||
|
||||
gst_value_register_union_func (G_TYPE_INT, GST_TYPE_INT_RANGE,
|
||||
gst_value_union_int_int_range);
|
||||
|
|
Loading…
Reference in a new issue