Commit 6c18c950 authored by Wim Taymans's avatar Wim Taymans

miniobject: more boxed type fixing

More miniobject fixing, leaks horribly somewhere..
parent 317af67b
......@@ -291,6 +291,8 @@ _gst_buffer_free (GstBuffer * buffer)
if (buffer->parent)
gst_buffer_unref (buffer->parent);
g_slice_free (GstBuffer, buffer);
}
/**
......
......@@ -206,6 +206,7 @@ gst_caps_new_empty (void)
GST_TYPE_CAPS, sizeof (GstCaps));
caps->mini_object.copy = (GstMiniObjectCopyFunction) _gst_caps_copy;
caps->mini_object.dispose = NULL;
caps->mini_object.free = (GstMiniObjectFreeFunction) _gst_caps_free;
caps->structs = g_ptr_array_new ();
......
......@@ -121,7 +121,8 @@ void
_gst_event_initialize (void)
{
gint i;
g_type_class_ref (gst_event_get_type ());
gst_event_get_type ();
g_type_class_ref (gst_seek_flags_get_type ());
g_type_class_ref (gst_seek_type_get_type ());
......
......@@ -110,7 +110,7 @@ _gst_message_initialize (void)
/* the GstMiniObject types need to be class_ref'd once before it can be
* done from multiple threads;
* see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
g_type_class_ref (gst_message_get_type ());
gst_message_get_type ();
for (i = 0; message_quarks[i].name; i++) {
message_quarks[i].quark =
......
......@@ -38,6 +38,8 @@
#include "gst/gstinfo.h"
#include <gobject/gvaluecollector.h>
#define GST_DISABLE_TRACE
#ifndef GST_DISABLE_TRACE
#include "gsttrace.h"
static GstAllocTrace *_gst_mini_object_trace;
......
......@@ -305,7 +305,7 @@ gst_pad_class_init (GstPadClass * klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (GstPadClass, have_data),
_gst_do_pass_data_accumulator,
NULL, gst_marshal_BOOLEAN__BOXED, G_TYPE_BOOLEAN, 1, G_TYPE_BOXED);
NULL, gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
pspec_caps = g_param_spec_boxed ("caps", "Caps",
"The capabilities of the pad", GST_TYPE_CAPS,
......
......@@ -72,8 +72,7 @@
GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
#define GST_CAT_DEFAULT gst_query_debug
static void gst_query_finalize (GstQuery * query);
static GstQuery *_gst_query_copy (GstQuery * query);
static GType _gst_query_type = 0;
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
static GList *_gst_queries = NULL;
......@@ -81,8 +80,6 @@ static GHashTable *_nick_to_query = NULL;
static GHashTable *_query_type_to_nick = NULL;
static guint32 _n_values = 1; /* we start from 1 because 0 reserved for NONE */
static GstMiniObjectClass *parent_class = NULL;
static GstQueryTypeDefinition standard_definitions[] = {
{GST_QUERY_POSITION, "position", "Current position", 0},
{GST_QUERY_DURATION, "duration", "Total duration", 0},
......@@ -126,7 +123,7 @@ _gst_query_initialize (void)
}
g_static_mutex_unlock (&mutex);
g_type_class_ref (gst_query_get_type ());
gst_query_get_type ();
}
/**
......@@ -165,56 +162,15 @@ gst_query_type_to_quark (GstQueryType query)
return def->quark;
}
G_DEFINE_TYPE (GstQuery, gst_query, GST_TYPE_MINI_OBJECT);
static void
gst_query_class_init (GstQueryClass * klass)
GType
gst_query_get_type (void)
{
parent_class = g_type_class_peek_parent (klass);
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
klass->mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_query_finalize;
}
static void
gst_query_init (GstQuery * query)
{
}
static void
gst_query_finalize (GstQuery * query)
{
g_return_if_fail (query != NULL);
if (query->structure) {
gst_structure_set_parent_refcount (query->structure, NULL);
gst_structure_free (query->structure);
if (G_UNLIKELY (_gst_query_type == 0)) {
_gst_query_type = gst_mini_object_register ("GstQuery");
}
/* GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (query)); */
return _gst_query_type;
}
static GstQuery *
_gst_query_copy (GstQuery * query)
{
GstQuery *copy;
copy = (GstQuery *) gst_mini_object_new (GST_TYPE_QUERY);
copy->type = query->type;
if (query->structure) {
copy->structure = gst_structure_copy (query->structure);
gst_structure_set_parent_refcount (copy->structure,
&query->mini_object.refcount);
}
return copy;
}
/**
* gst_query_type_register:
......@@ -353,24 +309,52 @@ gst_query_type_iterate_definitions (void)
return result;
}
static void
_gst_query_free (GstQuery * query)
{
g_return_if_fail (query != NULL);
if (query->structure) {
gst_structure_set_parent_refcount (query->structure, NULL);
gst_structure_free (query->structure);
}
g_slice_free (GstQuery, query);
}
static GstQuery *gst_query_new (GstQueryType type, GstStructure * structure);
static GstQuery *
_gst_query_copy (GstQuery * query)
{
GstQuery *copy;
copy = gst_query_new (query->type, query->structure);
return copy;
}
static GstQuery *
gst_query_new (GstQueryType type, GstStructure * structure)
{
GstQuery *query;
query = (GstQuery *) gst_mini_object_new (GST_TYPE_QUERY);
query = g_slice_new0 (GstQuery);
gst_mini_object_init (GST_MINI_OBJECT_CAST (query),
_gst_query_type, sizeof (GstQuery));
query->mini_object.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
query->mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
GST_DEBUG ("creating new query %p %d", query, type);
query->type = type;
query->structure = structure;
if (structure) {
query->structure = structure;
if (structure)
gst_structure_set_parent_refcount (query->structure,
&query->mini_object.refcount);
} else {
query->structure = NULL;
}
return query;
}
......
......@@ -1849,7 +1849,7 @@ gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag,
if (!gst_tag_list_copy_value (&v, list, tag))
return FALSE;
*value = (GstBuffer *) gst_value_dup_mini_object (&v);
*value = g_value_dup_boxed (&v);
g_value_unset (&v);
return (*value != NULL);
}
......@@ -1885,6 +1885,6 @@ gst_tag_list_get_buffer_index (const GstTagList * list,
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
return FALSE;
*value = (GstBuffer *) gst_value_dup_mini_object (v);
*value = g_value_dup_boxed (v);
return (*value != NULL);
}
......@@ -1720,8 +1720,8 @@ gst_value_deserialize_structure (GValue * dest, const gchar * s)
static gint
gst_value_compare_buffer (const GValue * value1, const GValue * value2)
{
GstBuffer *buf1 = GST_BUFFER (gst_value_get_mini_object (value1));
GstBuffer *buf2 = GST_BUFFER (gst_value_get_mini_object (value2));
GstBuffer *buf1 = GST_BUFFER_CAST (g_value_get_boxed (value1));
GstBuffer *buf2 = GST_BUFFER_CAST (g_value_get_boxed (value2));
if (GST_BUFFER_SIZE (buf1) != GST_BUFFER_SIZE (buf2))
return GST_VALUE_UNORDERED;
......
......@@ -505,7 +505,7 @@ gst_base_sink_class_init (GstBaseSinkClass * klass)
* Since: 0.10.15
*/
g_object_class_install_property (gobject_class, PROP_LAST_BUFFER,
gst_param_spec_mini_object ("last-buffer", "Last Buffer",
g_param_spec_boxed ("last-buffer", "Last Buffer",
"The last buffer received in the sink", GST_TYPE_BUFFER,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
......
......@@ -160,7 +160,7 @@ marshal_VOID__MINIOBJECT_OBJECT (GClosure * closure, GValue * return_value,
(marshalfunc_VOID__MINIOBJECT_OBJECT) (marshal_data ? marshal_data :
cc->callback);
callback (data1, gst_value_get_mini_object (param_values + 1),
callback (data1, g_value_get_boxed (param_values + 1),
g_value_get_object (param_values + 2), data2);
}
......
......@@ -251,7 +251,7 @@ marshal_VOID__MINIOBJECT_OBJECT (GClosure * closure, GValue * return_value,
(marshalfunc_VOID__MINIOBJECT_OBJECT) (marshal_data ? marshal_data :
cc->callback);
callback (data1, gst_value_get_mini_object (param_values + 1),
callback (data1, g_value_get_boxed (param_values + 1),
g_value_get_object (param_values + 2), data2);
}
......@@ -850,7 +850,7 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length,
", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %"
G_GINT64_FORMAT ", flags: %d) %p", GST_BUFFER_SIZE (buf), ts_str,
dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
GST_MINI_OBJECT (buf)->flags, buf);
GST_MINI_OBJECT_CAST (buf)->flags, buf);
GST_OBJECT_UNLOCK (src);
#if !GLIB_CHECK_VERSION(2,26,0)
......
......@@ -460,6 +460,7 @@ gst_file_src_get_property (GObject * object, guint prop_id, GValue * value,
}
}
#undef HAVE_MMAP
/***
* mmap code below
*/
......
......@@ -172,7 +172,7 @@ marshal_VOID__MINIOBJECT (GClosure * closure, GValue * return_value,
(marshalfunc_VOID__MINIOBJECT) (marshal_data ? marshal_data :
cc->callback);
callback (data1, gst_value_get_mini_object (param_values + 1), data2);
callback (data1, g_value_get_boxed (param_values + 1), data2);
}
static void
......
......@@ -451,7 +451,7 @@ gst_type_find_element_src_event (GstPad * pad, GstEvent * event)
if (typefind->mode != MODE_NORMAL) {
/* need to do more? */
gst_mini_object_unref (GST_MINI_OBJECT (event));
gst_mini_object_unref (GST_MINI_OBJECT_CAST (event));
return FALSE;
}
return gst_pad_push_event (typefind->sink, event);
......
......@@ -259,7 +259,7 @@ create_read_only_buffer (void)
{
GstBuffer *buf;
buf = (GstBuffer *) gst_mini_object_new (GST_TYPE_BUFFER);
buf = gst_buffer_new ();
/* assign some read-only data to the new buffer */
GST_BUFFER_DATA (buf) = (guint8 *) ro_memory;
......
......@@ -29,7 +29,7 @@ GST_START_TEST (test_copy)
buffer = gst_buffer_new_and_alloc (4);
copy = GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT (buffer)));
copy = GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT_CAST (buffer)));
fail_if (copy == NULL, "Copy of buffer returned NULL");
fail_unless (GST_BUFFER_SIZE (copy) == 4,
......@@ -44,7 +44,7 @@ GST_START_TEST (test_is_writable)
GstMiniObject *mobj;
buffer = gst_buffer_new_and_alloc (4);
mobj = GST_MINI_OBJECT (buffer);
mobj = GST_MINI_OBJECT_CAST (buffer);
fail_unless (gst_mini_object_is_writable (mobj),
"A buffer with one ref should be writable");
......@@ -70,7 +70,7 @@ GST_START_TEST (test_make_writable)
GstMiniObject *mobj, *mobj2, *mobj3;
buffer = gst_buffer_new_and_alloc (4);
mobj = GST_MINI_OBJECT (buffer);
mobj = GST_MINI_OBJECT_CAST (buffer);
mobj2 = gst_mini_object_make_writable (mobj);
fail_unless (GST_IS_BUFFER (mobj2), "make_writable did not return a buffer");
......@@ -123,7 +123,7 @@ GST_START_TEST (test_ref_threaded)
buffer = gst_buffer_new_and_alloc (4);
mobj = GST_MINI_OBJECT (buffer);
mobj = GST_MINI_OBJECT_CAST (buffer);
MAIN_START_THREADS (num_threads, thread_ref, mobj);
......@@ -175,21 +175,12 @@ GST_START_TEST (test_unref_threaded)
GST_END_TEST;
#if 0
/* ======== recycle test ======== */
static gint recycle_buffer_count = 10;
#define MY_TYPE_RECYCLE_BUFFER (my_recycle_buffer_get_type ())
#define MY_IS_RECYCLE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
MY_TYPE_RECYCLE_BUFFER))
#define MY_RECYCLE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
MY_TYPE_RECYCLE_BUFFER, MyRecycleBuffer))
#define MY_RECYCLE_BUFFER_CAST(obj) ((MyRecycleBuffer *) (obj))
typedef struct _MyBufferPool MyBufferPool;
typedef struct _MyRecycleBuffer MyRecycleBuffer;
typedef struct _MyRecycleBufferClass MyRecycleBufferClass;
struct _MyBufferPool
{
......@@ -198,18 +189,6 @@ struct _MyBufferPool
volatile gboolean is_closed;
};
struct _MyRecycleBuffer
{
GstBuffer buffer;
MyBufferPool *pool;
};
struct _MyRecycleBufferClass
{
GstBufferClass parent_class;
};
static void my_recycle_buffer_destroy (MyRecycleBuffer * buf);
static MyBufferPool *
......@@ -252,28 +231,10 @@ my_buffer_pool_drain_one (MyBufferPool * self)
return buf;
}
GType my_recycle_buffer_get_type (void);
G_DEFINE_TYPE (MyRecycleBuffer, my_recycle_buffer, GST_TYPE_BUFFER);
static void my_recycle_buffer_finalize (GstMiniObject * mini_object);
static void
my_recycle_buffer_class_init (MyRecycleBufferClass * klass)
{
GstMiniObjectClass *miniobject_class = GST_MINI_OBJECT_CLASS (klass);
miniobject_class->finalize = my_recycle_buffer_finalize;
}
static void
my_recycle_buffer_init (MyRecycleBuffer * self)
{
}
static void
my_recycle_buffer_finalize (GstMiniObject * mini_object)
{
MyRecycleBuffer *self = MY_RECYCLE_BUFFER_CAST (mini_object);
GstBuffer *self = GST_BUFFER_CAST (mini_object);
if (self->pool != NULL) {
my_buffer_pool_add (self->pool, GST_BUFFER_CAST (self));
......@@ -287,10 +248,11 @@ my_recycle_buffer_finalize (GstMiniObject * mini_object)
static GstBuffer *
my_recycle_buffer_new (MyBufferPool * pool)
{
MyRecycleBuffer *buf;
GstBuffer *buf;
buf = MY_RECYCLE_BUFFER (gst_mini_object_new (MY_TYPE_RECYCLE_BUFFER));
buf->pool = pool;
buf = gst_buffer_new ();
//buf->pool = pool;
return GST_BUFFER_CAST (buf);
}
......@@ -349,6 +311,7 @@ GST_START_TEST (test_recycle_threaded)
}
GST_END_TEST;
#endif
/* ======== value collection test ======== */
typedef struct _MyFoo
......@@ -383,7 +346,7 @@ my_foo_get_property (GObject * object, guint prop_id, GValue * value,
g_assert (prop_id == PROP_BUFFER);
new_buf = gst_buffer_new_and_alloc (1024);
gst_value_set_mini_object (value, GST_MINI_OBJECT (new_buf));
g_value_set_boxed (value, GST_MINI_OBJECT (new_buf));
gst_buffer_unref (new_buf);
}
......@@ -395,8 +358,7 @@ my_foo_set_property (GObject * object, guint prop_id, const GValue * value,
g_assert (prop_id == PROP_BUFFER);
mini_obj = gst_value_get_mini_object (value);
g_assert (GST_IS_MINI_OBJECT (mini_obj));
mini_obj = g_value_get_boxed (value);
g_assert (GST_IS_BUFFER (mini_obj));
#if 0
......@@ -418,7 +380,7 @@ my_foo_class_init (MyFooClass * klass)
gobject_klass->set_property = my_foo_set_property;
g_object_class_install_property (gobject_klass, PROP_BUFFER,
gst_param_spec_mini_object ("buffer", "Buffer",
g_param_spec_boxed ("buffer", "Buffer",
"a newly created GstBuffer", GST_TYPE_BUFFER, G_PARAM_READWRITE));
}
......@@ -462,7 +424,7 @@ gst_mini_object_suite (void)
tcase_add_test (tc_chain, test_make_writable);
tcase_add_test (tc_chain, test_ref_threaded);
tcase_add_test (tc_chain, test_unref_threaded);
tcase_add_test (tc_chain, test_recycle_threaded);
//tcase_add_test (tc_chain, test_recycle_threaded);
tcase_add_test (tc_chain, test_value_collection);
return s;
}
......
......@@ -44,7 +44,7 @@ data_probe (GstPad * pad, GstMiniObject * obj, gpointer data)
{
n_data_probes++;
GST_DEBUG_OBJECT (pad, "data probe %d", n_data_probes);
g_assert (GST_IS_MINI_OBJECT (obj));
g_assert (GST_IS_BUFFER (obj) || GST_IS_EVENT (obj));
g_assert (data == SPECIAL_POINTER (0));
return TRUE;
}
......@@ -133,7 +133,7 @@ static gboolean
data_probe_once (GstPad * pad, GstMiniObject * obj, guint * data)
{
n_data_probes_once++;
g_assert (GST_IS_MINI_OBJECT (obj));
g_assert (GST_IS_BUFFER (obj) || GST_IS_EVENT (obj));
gst_pad_remove_data_probe (pad, *data);
......
......@@ -118,7 +118,7 @@ GST_START_TEST (test_deserialize_buffer)
g_value_init (&value, GST_TYPE_BUFFER);
fail_unless (gst_value_deserialize (&value, "1234567890abcdef"));
/* does not increase the refcount */
buf = GST_BUFFER (gst_value_get_mini_object (&value));
buf = GST_BUFFER (g_value_get_boxed (&value));
ASSERT_MINI_OBJECT_REFCOUNT (buf, "buffer", 1);
/* does not increase the refcount */
......
......@@ -2,7 +2,6 @@ static GstCheckABIStruct list[] = {
{"GstBin", sizeof (GstBin), 336},
{"GstBinClass", sizeof (GstBinClass), 568},
{"GstBuffer", sizeof (GstBuffer), 120} ,
{"GstBufferClass", sizeof (GstBufferClass), 32} ,
{"GstBus", sizeof (GstBus), 152} ,
{"GstBusClass", sizeof (GstBusClass), 288} ,
{"GstCaps", sizeof (GstCaps), 56} ,
......@@ -15,7 +14,6 @@ static GstCheckABIStruct list[] = {
{"GstElementFactory", sizeof (GstElementFactory), 280} ,
{"GstElementFactoryClass", sizeof (GstElementFactoryClass), 304} ,
{"GstEvent", sizeof (GstEvent), 64} ,
{"GstEventClass", sizeof (GstEventClass), 64} ,
{"GstFormatDefinition", sizeof (GstFormatDefinition), 32} ,
{"GstIndexEntry", sizeof (GstIndexEntry), 32} ,
{"GstIndexGroup", sizeof (GstIndexGroup), 24} ,
......@@ -28,9 +26,7 @@ static GstCheckABIStruct list[] = {
{"GstImplementsInterfaceClass", sizeof (GstImplementsInterfaceClass), 56} ,
{"GstIterator", sizeof (GstIterator), 104} ,
{"GstMessage", sizeof (GstMessage), 104} ,
{"GstMessageClass", sizeof (GstMessageClass), 64} ,
{"GstMiniObject", sizeof (GstMiniObject), 24} ,
{"GstMiniObjectClass", sizeof (GstMiniObjectClass), 32} ,
{"GstObject", sizeof (GstObject), 80} ,
{"GstObjectClass", sizeof (GstObjectClass), 240} ,
{"GstPad", sizeof (GstPad), 368} ,
......@@ -47,7 +43,6 @@ static GstCheckABIStruct list[] = {
{"GstPluginFeatureClass", sizeof (GstPluginFeatureClass), 272} ,
{"GstQueryTypeDefinition", sizeof (GstQueryTypeDefinition), 32} ,
{"GstQuery", sizeof (GstQuery), 48} ,
{"GstQueryClass", sizeof (GstQueryClass), 64} ,
{"GstRegistry", sizeof (GstRegistry), 144} ,
{"GstRegistryClass", sizeof (GstRegistryClass), 288} ,
{"GstSegment", sizeof (GstSegment), 104} ,
......
......@@ -601,9 +601,6 @@ print_element_properties_info (GstElement * element)
gst_value_get_fraction_numerator (&value),
gst_value_get_fraction_denominator (&value));
} else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) {
n_print ("%-23.23s MiniObject of type \"%s\"", "",
g_type_name (param->value_type));
} else {
n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
g_type_name (param->value_type));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment