miniobject: make queries a boxed type

More minionject stuff.
This commit is contained in:
Wim Taymans 2009-12-04 22:32:38 +01:00
parent 56a3364183
commit 317af67bc4
6 changed files with 67 additions and 74 deletions

View file

@ -21,6 +21,7 @@
#define __GST_CAPS_H__ #define __GST_CAPS_H__
#include <gst/gstconfig.h> #include <gst/gstconfig.h>
#include <gst/gstminiobject.h>
#include <gst/gststructure.h> #include <gst/gststructure.h>
#include <gst/glib-compat.h> #include <gst/glib-compat.h>
@ -91,7 +92,8 @@ typedef enum {
*/ */
#define GST_STATIC_CAPS(string) \ #define GST_STATIC_CAPS(string) \
{ \ { \
/* caps */ { 0, 0, (GstCapsFlags) 0, NULL, GST_PADDING_INIT }, \ /* miniobject */ { { 0, 0, 0, 0, NULL, NULL, NULL }, \
/* caps */ NULL, GST_PADDING_INIT }, \
/* string */ string, \ /* string */ string, \
GST_PADDING_INIT \ GST_PADDING_INIT \
} }

View file

@ -87,14 +87,6 @@
static GType _gst_event_type = 0; static GType _gst_event_type = 0;
void
_gst_event_initialize (void)
{
g_type_class_ref (gst_event_get_type ());
g_type_class_ref (gst_seek_flags_get_type ());
g_type_class_ref (gst_seek_type_get_type ());
}
typedef struct typedef struct
{ {
const gint type; const gint type;
@ -125,6 +117,19 @@ static GstEventQuarks event_quarks[] = {
{0, NULL, 0} {0, NULL, 0}
}; };
void
_gst_event_initialize (void)
{
gint i;
g_type_class_ref (gst_event_get_type ());
g_type_class_ref (gst_seek_flags_get_type ());
g_type_class_ref (gst_seek_type_get_type ());
for (i = 0; event_quarks[i].name; i++) {
event_quarks[i].quark = g_quark_from_static_string (event_quarks[i].name);
}
}
/** /**
* gst_event_type_get_name: * gst_event_type_get_name:
* @type: the event type * @type: the event type
@ -183,16 +188,6 @@ gst_event_type_get_flags (GstEventType type)
return ret; return ret;
} }
#define _do_init \
{ \
gint i; \
\
for (i = 0; event_quarks[i].name; i++) { \
event_quarks[i].quark = g_quark_from_static_string (event_quarks[i].name); \
} \
}
GType GType
gst_event_get_type (void) gst_event_get_type (void)
{ {

View file

@ -20,5 +20,6 @@ VOID:UINT,BOXED
VOID:UINT,POINTER VOID:UINT,POINTER
BOOLEAN:VOID BOOLEAN:VOID
BOOLEAN:POINTER BOOLEAN:POINTER
BOOLEAN:BOXED
POINTER:POINTER POINTER:POINTER
BOXED:BOXED BOXED:BOXED

View file

@ -60,19 +60,7 @@
#include "gstquark.h" #include "gstquark.h"
static void gst_message_finalize (GstMessage * message); static GType _gst_message_type = 0;
static GstMessage *_gst_message_copy (GstMessage * message);
void
_gst_message_initialize (void)
{
GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
/* 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 ());
}
typedef struct typedef struct
{ {
@ -112,6 +100,24 @@ static GstMessageQuarks message_quarks[] = {
{0, NULL, 0} {0, NULL, 0}
}; };
void
_gst_message_initialize (void)
{
gint i;
GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
/* 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 ());
for (i = 0; message_quarks[i].name; i++) {
message_quarks[i].quark =
g_quark_from_static_string (message_quarks[i].name);
}
}
/** /**
* gst_message_type_get_name: * gst_message_type_get_name:
* @type: the message type * @type: the message type
@ -152,38 +158,18 @@ gst_message_type_to_quark (GstMessageType type)
return 0; return 0;
} }
#define _do_init \ GType
{ \ gst_message_get_type (void)
gint i; \
\
for (i = 0; message_quarks[i].name; i++) { \
message_quarks[i].quark = \
g_quark_from_static_string (message_quarks[i].name); \
} \
}
G_DEFINE_TYPE_WITH_CODE (GstMessage, gst_message, GST_TYPE_MINI_OBJECT,
_do_init);
static void
gst_message_class_init (GstMessageClass * klass)
{ {
parent_class = g_type_class_peek_parent (klass); if (G_UNLIKELY (_gst_message_type == 0)) {
_gst_message_type = gst_mini_object_register ("GstMessage");
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_message_copy; }
klass->mini_object_class.finalize = return _gst_message_type;
(GstMiniObjectFinalizeFunction) gst_message_finalize;
} }
static void
gst_message_init (GstMessage * message)
{
GST_CAT_LOG (GST_CAT_MESSAGE, "new message %p", message);
GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
}
static void static void
gst_message_finalize (GstMessage * message) _gst_message_free (GstMessage * message)
{ {
g_return_if_fail (message != NULL); g_return_if_fail (message != NULL);
@ -205,7 +191,7 @@ gst_message_finalize (GstMessage * message)
gst_structure_free (message->structure); gst_structure_free (message->structure);
} }
/* GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (message)); */ g_slice_free (GstMessage, message);
} }
static GstMessage * static GstMessage *
@ -215,10 +201,13 @@ _gst_message_copy (GstMessage * message)
GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p", message); GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p", message);
copy = (GstMessage *) gst_mini_object_new (GST_TYPE_MESSAGE); copy = g_slice_new0 (GstMessage);
/* FIXME, need to copy relevant data from the miniobject. */ gst_mini_object_init (GST_MINI_OBJECT_CAST (copy),
//memcpy (copy, message, sizeof (GstMessage)); _gst_message_type, sizeof (GstMessage));
copy->mini_object.copy = (GstMiniObjectCopyFunction) _gst_message_copy;
copy->mini_object.free = (GstMiniObjectFreeFunction) _gst_message_free;
GST_MESSAGE_GET_LOCK (copy) = GST_MESSAGE_GET_LOCK (message); GST_MESSAGE_GET_LOCK (copy) = GST_MESSAGE_GET_LOCK (message);
GST_MESSAGE_COND (copy) = GST_MESSAGE_COND (message); GST_MESSAGE_COND (copy) = GST_MESSAGE_COND (message);
@ -260,7 +249,13 @@ gst_message_new_custom (GstMessageType type, GstObject * src,
{ {
GstMessage *message; GstMessage *message;
message = (GstMessage *) gst_mini_object_new (GST_TYPE_MESSAGE); message = g_slice_new0 (GstMessage);
gst_mini_object_init (GST_MINI_OBJECT_CAST (message),
_gst_message_type, sizeof (GstMessage));
message->mini_object.copy = (GstMiniObjectCopyFunction) _gst_message_copy;
message->mini_object.free = (GstMiniObjectFreeFunction) _gst_message_free;
GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s", GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
(src ? GST_OBJECT_NAME (src) : "NULL"), message, (src ? GST_OBJECT_NAME (src) : "NULL"), message,
@ -278,6 +273,7 @@ gst_message_new_custom (GstMessageType type, GstObject * src,
} }
message->structure = structure; message->structure = structure;
GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next (); GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
return message; return message;

View file

@ -140,7 +140,7 @@ gst_mini_object_copy (const GstMiniObject * mini_object)
g_return_val_if_fail (mini_object != NULL, NULL); g_return_val_if_fail (mini_object != NULL, NULL);
if (mini_object->copy) if (mini_object->copy)
copy = mo_class->copy (mini_object); copy = mini_object->copy (mini_object);
else else
copy = NULL; copy = NULL;

View file

@ -305,8 +305,7 @@ gst_pad_class_init (GstPadClass * klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (GstPadClass, have_data), G_STRUCT_OFFSET (GstPadClass, have_data),
_gst_do_pass_data_accumulator, _gst_do_pass_data_accumulator,
NULL, gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, NULL, gst_marshal_BOOLEAN__BOXED, G_TYPE_BOOLEAN, 1, G_TYPE_BOXED);
GST_TYPE_MINI_OBJECT);
pspec_caps = g_param_spec_boxed ("caps", "Caps", pspec_caps = g_param_spec_boxed ("caps", "Caps",
"The capabilities of the pad", GST_TYPE_CAPS, "The capabilities of the pad", GST_TYPE_CAPS,
@ -3639,8 +3638,8 @@ gst_pad_emit_have_data_signal (GstPad * pad, GstMiniObject * obj)
g_value_set_boolean (&ret, TRUE); g_value_set_boolean (&ret, TRUE);
g_value_init (&args[0], GST_TYPE_PAD); g_value_init (&args[0], GST_TYPE_PAD);
g_value_set_object (&args[0], pad); g_value_set_object (&args[0], pad);
g_value_init (&args[1], GST_TYPE_MINI_OBJECT); g_value_init (&args[1], G_TYPE_BOXED);
gst_value_set_mini_object (&args[1], obj); g_value_set_boxed (&args[1], obj);
if (GST_IS_EVENT (obj)) if (GST_IS_EVENT (obj))
detail = event_quark; detail = event_quark;
@ -3716,7 +3715,7 @@ gst_pad_chain_data_unchecked (GstPad * pad, gboolean is_buffer, void *data,
if (G_UNLIKELY (emit_signal)) { if (G_UNLIKELY (emit_signal)) {
cache = NULL; cache = NULL;
if (G_LIKELY (is_buffer)) { if (G_LIKELY (is_buffer)) {
if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT (data))) if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT_CAST (data)))
goto dropping; goto dropping;
} else { } else {
/* chain all groups in the buffer list one by one to avoid problems with /* chain all groups in the buffer list one by one to avoid problems with
@ -3953,7 +3952,7 @@ gst_pad_push_data (GstPad * pad, gboolean is_buffer, void *data,
if (G_LIKELY (is_buffer)) { if (G_LIKELY (is_buffer)) {
/* if the signal handler returned FALSE, it means we should just drop the /* if the signal handler returned FALSE, it means we should just drop the
* buffer */ * buffer */
if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT (data))) if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT_CAST (data)))
goto dropped; goto dropped;
} else { } else {
/* push all buffers in the list */ /* push all buffers in the list */
@ -4443,7 +4442,7 @@ gst_pad_get_range_unchecked (GstPad * pad, guint64 offset, guint size,
/* can only fire the signal if we have a valid buffer */ /* can only fire the signal if we have a valid buffer */
if (G_UNLIKELY (emit_signal) && (ret == GST_FLOW_OK)) { if (G_UNLIKELY (emit_signal) && (ret == GST_FLOW_OK)) {
if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT (*buffer))) if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT_CAST (*buffer)))
goto dropping; goto dropping;
} }
@ -4612,7 +4611,7 @@ gst_pad_pull_range (GstPad * pad, guint64 offset, guint size,
/* can only fire the signal if we have a valid buffer */ /* can only fire the signal if we have a valid buffer */
if (G_UNLIKELY (emit_signal)) { if (G_UNLIKELY (emit_signal)) {
if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT (*buffer))) if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT_CAST (*buffer)))
goto dropping; goto dropping;
} }
@ -4739,7 +4738,7 @@ gst_pad_push_event (GstPad * pad, GstEvent * event)
if (G_UNLIKELY (GST_PAD_DO_EVENT_SIGNALS (pad) > 0)) { if (G_UNLIKELY (GST_PAD_DO_EVENT_SIGNALS (pad) > 0)) {
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT (event))) if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT_CAST (event)))
goto dropping; goto dropping;
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);