+2005-11-08 Wim Taymans <wim@fluendo.com>
+
+ * gst/base/gstbasesink.c: (gst_base_sink_preroll_queue_empty),
+ (gst_base_sink_do_sync), (gst_base_sink_handle_event),
+ (gst_base_sink_chain), (gst_base_sink_change_state):
+ * gst/base/gstbasesink.h:
+ * gst/base/gstbasesrc.h:
+ * gst/gstelement.h:
+ * gst/gstevent.h:
+ Avoid excessive typechecking in macros.
+
+ * gst/gstminiobject.c: (gst_mini_object_get_type),
+ (gst_mini_object_init), (gst_mini_object_new),
+ (gst_mini_object_free):
+ * gst/gstobject.c: (gst_object_class_init), (gst_object_init),
+ (gst_object_finalize):
+ Remove cruft code, optimize alloc_trace.
+
2005-11-07 Thomas Vander Stichele <thomas at apestaart dot org>
* docs/faq/gst-uninstalled:
gboolean is_buffer;
is_buffer = GST_IS_BUFFER (obj);
- if (is_buffer) {
+ if (G_LIKELY (is_buffer)) {
basesink->preroll_queued--;
basesink->buffers_queued--;
} else {
* inside the element. */
GST_PREROLL_UNLOCK (pad);
- if (is_buffer) {
+ if (G_LIKELY (is_buffer)) {
GST_DEBUG_OBJECT (basesink, "popped buffer %p", obj);
- ret = gst_base_sink_handle_buffer (basesink, GST_BUFFER (obj));
+ ret = gst_base_sink_handle_buffer (basesink, GST_BUFFER_CAST (obj));
} else {
GST_DEBUG_OBJECT (basesink, "popped event %p", obj);
- gst_base_sink_handle_event (basesink, GST_EVENT (obj));
+ gst_base_sink_handle_event (basesink, GST_EVENT_CAST (obj));
ret = GST_FLOW_OK;
}
GST_LOCK (basesink);
- base_time = GST_ELEMENT (basesink)->base_time;
+ base_time = GST_ELEMENT_CAST (basesink)->base_time;
GST_LOG_OBJECT (basesink,
"waiting for clock, base time %" GST_TIME_FORMAT
if (basesink->eos) {
/* ok, now we can post the message */
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
- gst_element_post_message (GST_ELEMENT (basesink),
- gst_message_new_eos (GST_OBJECT (basesink)));
+ gst_element_post_message (GST_ELEMENT_CAST (basesink),
+ gst_message_new_eos (GST_OBJECT_CAST (basesink)));
basesink->eos_queued = FALSE;
}
GST_PREROLL_UNLOCK (basesink->sinkpad);
goto done;
}
- result = gst_base_sink_handle_object (basesink, pad, GST_MINI_OBJECT (buf));
+ result =
+ gst_base_sink_handle_object (basesink, pad, GST_MINI_OBJECT_CAST (buf));
done:
gst_object_unref (basesink);
* just emptied. */
if (do_eos) {
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
- gst_element_post_message (GST_ELEMENT (basesink),
- gst_message_new_eos (GST_OBJECT (basesink)));
+ gst_element_post_message (GST_ELEMENT_CAST (basesink),
+ gst_message_new_eos (GST_OBJECT_CAST (basesink)));
}
} else if (!basesink->have_preroll) {
/* queue a commit_state */
#define GST_BASE_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SINK, GstBaseSinkClass))
#define GST_IS_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SINK))
#define GST_IS_BASE_SINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SINK))
+#define GST_BASE_SINK_CAST(obj) ((GstBaseSink *) (obj))
/**
* GST_BASE_SINK_CLOCK:
*
* Gives the pointer to the #GstClock object of the element.
*/
-#define GST_BASE_SINK_CLOCK(obj) (GST_BASE_SINK (obj)->clock)
+#define GST_BASE_SINK_CLOCK(obj) (GST_BASE_SINK_CAST (obj)->clock)
/**
* GST_BASE_SINK_PAD:
* @obj: base sink instance
*
* Gives the pointer to the #GstPad object of the element.
*/
-#define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK (obj)->sinkpad)
+#define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK_CAST (obj)->sinkpad)
typedef struct _GstBaseSink GstBaseSink;
typedef struct _GstBaseSinkClass GstBaseSinkClass;
#define GST_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SRC, GstBaseSrcClass))
#define GST_IS_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SRC))
#define GST_IS_BASE_SRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SRC))
+#define GST_BASE_SRC_CAST(obj) ((GstBaseSrc *)(obj))
/**
* GstBaseSrcFlags:
*
* Gives the pointer to the #GstPad object of the element.
*/
-#define GST_BASE_SRC_PAD(obj) (GST_BASE_SRC (obj)->srcpad)
+#define GST_BASE_SRC_PAD(obj) (GST_BASE_SRC_CAST (obj)->srcpad)
-#define GST_LIVE_GET_LOCK(elem) (GST_BASE_SRC(elem)->live_lock)
+#define GST_LIVE_GET_LOCK(elem) (GST_BASE_SRC_CAST(elem)->live_lock)
#define GST_LIVE_LOCK(elem) g_mutex_lock(GST_LIVE_GET_LOCK(elem))
#define GST_LIVE_TRYLOCK(elem) g_mutex_trylock(GST_LIVE_GET_LOCK(elem))
#define GST_LIVE_UNLOCK(elem) g_mutex_unlock(GST_LIVE_GET_LOCK(elem))
-#define GST_LIVE_GET_COND(elem) (GST_BASE_SRC(elem)->live_cond)
+#define GST_LIVE_GET_COND(elem) (GST_BASE_SRC_CAST(elem)->live_cond)
#define GST_LIVE_WAIT(elem) g_cond_wait (GST_LIVE_GET_COND (elem), GST_LIVE_GET_LOCK (elem))
#define GST_LIVE_TIMED_WAIT(elem, timeval) g_cond_timed_wait (GST_LIVE_GET_COND (elem), GST_LIVE_GET_LOCK (elem),\
timeval)
*
* This macro returns the current state of the element.
*/
-#define GST_STATE(obj) (GST_ELEMENT(obj)->current_state)
+#define GST_STATE(obj) (GST_ELEMENT_CAST(obj)->current_state)
/**
* GST_STATE_NEXT:
*
* This macro returns the next state of the element.
*/
-#define GST_STATE_NEXT(obj) (GST_ELEMENT(obj)->next_state)
+#define GST_STATE_NEXT(obj) (GST_ELEMENT_CAST(obj)->next_state)
/**
* GST_STATE_PENDING:
*
* This macro returns the currently pending state of the element.
*/
-#define GST_STATE_PENDING(obj) (GST_ELEMENT(obj)->pending_state)
+#define GST_STATE_PENDING(obj) (GST_ELEMENT_CAST(obj)->pending_state)
/**
* GST_STATE_RETURN:
*
* This macro returns the last state change return value.
*/
-#define GST_STATE_RETURN(obj) (GST_ELEMENT(obj)->last_return)
+#define GST_STATE_RETURN(obj) (GST_ELEMENT_CAST(obj)->last_return)
#define __GST_SIGN(val) ((val) < 0 ? -1 : ((val) > 0 ? 1 : 0))
/**
*
* Gets the name of the element.
*/
-#define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT(elem))
+#define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT_CAST(elem))
/**
* gst_element_set_name:
*
* Sets the name of the element, getting rid of the old name if there was one.
*/
-#define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT(elem),name)
+#define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT_CAST(elem),name)
/**
* gst_element_get_parent:
*
* Gets the parent of an element.
*/
-#define gst_element_get_parent(elem) gst_object_get_parent(GST_OBJECT(elem))
+#define gst_element_get_parent(elem) gst_object_get_parent(GST_OBJECT_CAST(elem))
/**
* gst_element_set_parent:
*
* Sets the parent of an element.
*/
-#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT(elem),parent)
+#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT_CAST(elem),parent)
/* clocking */
gboolean gst_element_requires_clock (GstElement *element);
#define GST_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EVENT, GstEventClass))
#define GST_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EVENT, GstEvent))
#define GST_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EVENT, GstEventClass))
+#define GST_EVENT_CAST(obj) ((GstEvent *)(obj))
/**
* GST_EVENT_TYPE:
*
* Get the #GstEventType of the event.
*/
-#define GST_EVENT_TYPE(event) (GST_EVENT(event)->type)
+#define GST_EVENT_TYPE(event) (GST_EVENT_CAST(event)->type)
/**
* GST_EVENT_TYPE_NAME:
*
* Get the #GstClockTime timestamp of the event.
*/
-#define GST_EVENT_TIMESTAMP(event) (GST_EVENT(event)->timestamp)
+#define GST_EVENT_TIMESTAMP(event) (GST_EVENT_CAST(event)->timestamp)
/**
* GST_EVENT_SRC:
*
* The source #GstObject that generated this event.
*/
-#define GST_EVENT_SRC(event) (GST_EVENT(event)->src)
+#define GST_EVENT_SRC(event) (GST_EVENT_CAST(event)->src)
/**
* GST_EVENT_IS_UPSTREAM:
*
* Copy the event using the event specific copy function.
*/
-#define gst_event_copy(ev) GST_EVENT (gst_mini_object_copy (GST_MINI_OBJECT (ev)))
+#define gst_event_copy(ev) GST_EVENT_CAST (gst_mini_object_copy (GST_MINI_OBJECT (ev)))
/* custom event */
GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure);
#ifndef GST_DISABLE_TRACE
#include "gsttrace.h"
+static GstAllocTrace *_gst_mini_object_trace;
#endif
#define DEBUG_REFCOUNT
_gst_mini_object_type = g_type_fundamental_next ();
g_type_register_fundamental (_gst_mini_object_type, "GstMiniObject",
&mini_object_info, &mini_object_fundamental_info, G_TYPE_FLAG_ABSTRACT);
+
+#ifndef GST_DISABLE_TRACE
+ _gst_mini_object_trace =
+ gst_alloc_trace_register (g_type_name (_gst_mini_object_type));
+#endif
}
return _gst_mini_object_type;
static void
gst_mini_object_init (GTypeInstance * instance, gpointer klass)
{
- GstMiniObject *mini_object = GST_MINI_OBJECT (instance);
+ GstMiniObject *mini_object = GST_MINI_OBJECT_CAST (instance);
mini_object->refcount = 1;
}
GstMiniObject *
gst_mini_object_new (GType type)
{
- //GstMiniObjectClass *klass;
GstMiniObject *mini_object;
-#if 0
- klass = g_type_class_peek_static (type);
- if (!klass) {
- g_warning ("cannot find class for type '%s'", g_type_name (type));
- return NULL;
- }
-#endif
/* we don't support dynamic types because they really aren't useful,
* and could cause refcount problems */
-
mini_object = (GstMiniObject *) g_type_create_instance (type);
#ifndef GST_DISABLE_TRACE
- {
- const gchar *name;
- GstAllocTrace *trace;
-
- name = g_type_name (type);
-
- trace = gst_alloc_trace_get (name);
- if (!trace) {
- trace = gst_alloc_trace_register (name);
- }
- gst_alloc_trace_new (trace, mini_object);
- }
+ gst_alloc_trace_new (_gst_mini_object_trace, mini_object);
#endif
return mini_object;
* object, else the finalize method recycled the object */
if (g_atomic_int_get (&mini_object->refcount) == 0) {
#ifndef GST_DISABLE_TRACE
- {
- const gchar *name;
- GstAllocTrace *trace;
-
- name = g_type_name (G_TYPE_FROM_CLASS (mo_class));
-
- trace = gst_alloc_trace_get (name);
- if (G_LIKELY (trace)) {
- gst_alloc_trace_free (trace, mini_object);
- } else {
- g_warning ("Untraced miniobject: (%s)%p", name, mini_object);
- }
- }
+ gst_alloc_trace_free (_gst_mini_object_trace, mini_object);
#endif
g_type_free_instance ((GTypeInstance *) mini_object);
}
#ifndef GST_DISABLE_TRACE
#include "gsttrace.h"
+static GstAllocTrace *_gst_object_trace;
#endif
#define DEBUG_REFCOUNT
static void gst_object_class_init (GstObjectClass * klass);
static void gst_object_init (GTypeInstance * instance, gpointer g_class);
-#ifndef GST_DISABLE_TRACE
-static GObject *gst_object_constructor (GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params);
-#endif
-
static void gst_object_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_object_get_property (GObject * object, guint prop_id,
parent_class = g_type_class_ref (G_TYPE_OBJECT);
+#ifndef GST_DISABLE_TRACE
+ _gst_object_trace = gst_alloc_trace_register (g_type_name (GST_TYPE_OBJECT));
+#endif
+
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_object_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_object_get_property);
gobject_class->dispose = gst_object_dispose;
gobject_class->finalize = gst_object_finalize;
-#ifndef GST_DISABLE_TRACE
- gobject_class->constructor = gst_object_constructor;
-#endif
}
static void
#endif
PATCH_REFCOUNT (object);
+#ifndef GST_DISABLE_TRACE
+ gst_alloc_trace_new (_gst_object_trace, object);
+#endif
+
object->flags = 0;
GST_OBJECT_FLAG_SET (object, GST_OBJECT_FLOATING);
}
-#ifndef GST_DISABLE_TRACE
-static GObject *
-gst_object_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam * construct_params)
-{
- const gchar *name;
- GstAllocTrace *trace;
- GObject *obj =
- G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties,
- construct_params);
-
- name = g_type_name (type);
-
- trace = gst_alloc_trace_get (name);
- if (!trace) {
- trace = gst_alloc_trace_register (name);
- }
- gst_alloc_trace_new (trace, obj);
-
- return obj;
-}
-#endif
/**
* gst_object_ref:
* @object: GstObject to reference
g_mutex_free (gstobject->lock);
#ifndef GST_DISABLE_TRACE
- {
- const gchar *name;
- GstAllocTrace *trace;
-
- name = g_type_name (G_OBJECT_TYPE (object));
- trace = gst_alloc_trace_get (name);
- g_assert (trace);
- gst_alloc_trace_free (trace, object);
- }
+ gst_alloc_trace_free (_gst_object_trace, object);
#endif
parent_class->finalize (object);
gboolean is_buffer;
is_buffer = GST_IS_BUFFER (obj);
- if (is_buffer) {
+ if (G_LIKELY (is_buffer)) {
basesink->preroll_queued--;
basesink->buffers_queued--;
} else {
* inside the element. */
GST_PREROLL_UNLOCK (pad);
- if (is_buffer) {
+ if (G_LIKELY (is_buffer)) {
GST_DEBUG_OBJECT (basesink, "popped buffer %p", obj);
- ret = gst_base_sink_handle_buffer (basesink, GST_BUFFER (obj));
+ ret = gst_base_sink_handle_buffer (basesink, GST_BUFFER_CAST (obj));
} else {
GST_DEBUG_OBJECT (basesink, "popped event %p", obj);
- gst_base_sink_handle_event (basesink, GST_EVENT (obj));
+ gst_base_sink_handle_event (basesink, GST_EVENT_CAST (obj));
ret = GST_FLOW_OK;
}
GST_LOCK (basesink);
- base_time = GST_ELEMENT (basesink)->base_time;
+ base_time = GST_ELEMENT_CAST (basesink)->base_time;
GST_LOG_OBJECT (basesink,
"waiting for clock, base time %" GST_TIME_FORMAT
if (basesink->eos) {
/* ok, now we can post the message */
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
- gst_element_post_message (GST_ELEMENT (basesink),
- gst_message_new_eos (GST_OBJECT (basesink)));
+ gst_element_post_message (GST_ELEMENT_CAST (basesink),
+ gst_message_new_eos (GST_OBJECT_CAST (basesink)));
basesink->eos_queued = FALSE;
}
GST_PREROLL_UNLOCK (basesink->sinkpad);
goto done;
}
- result = gst_base_sink_handle_object (basesink, pad, GST_MINI_OBJECT (buf));
+ result =
+ gst_base_sink_handle_object (basesink, pad, GST_MINI_OBJECT_CAST (buf));
done:
gst_object_unref (basesink);
* just emptied. */
if (do_eos) {
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
- gst_element_post_message (GST_ELEMENT (basesink),
- gst_message_new_eos (GST_OBJECT (basesink)));
+ gst_element_post_message (GST_ELEMENT_CAST (basesink),
+ gst_message_new_eos (GST_OBJECT_CAST (basesink)));
}
} else if (!basesink->have_preroll) {
/* queue a commit_state */
#define GST_BASE_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SINK, GstBaseSinkClass))
#define GST_IS_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SINK))
#define GST_IS_BASE_SINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SINK))
+#define GST_BASE_SINK_CAST(obj) ((GstBaseSink *) (obj))
/**
* GST_BASE_SINK_CLOCK:
*
* Gives the pointer to the #GstClock object of the element.
*/
-#define GST_BASE_SINK_CLOCK(obj) (GST_BASE_SINK (obj)->clock)
+#define GST_BASE_SINK_CLOCK(obj) (GST_BASE_SINK_CAST (obj)->clock)
/**
* GST_BASE_SINK_PAD:
* @obj: base sink instance
*
* Gives the pointer to the #GstPad object of the element.
*/
-#define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK (obj)->sinkpad)
+#define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK_CAST (obj)->sinkpad)
typedef struct _GstBaseSink GstBaseSink;
typedef struct _GstBaseSinkClass GstBaseSinkClass;
#define GST_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SRC, GstBaseSrcClass))
#define GST_IS_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SRC))
#define GST_IS_BASE_SRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SRC))
+#define GST_BASE_SRC_CAST(obj) ((GstBaseSrc *)(obj))
/**
* GstBaseSrcFlags:
*
* Gives the pointer to the #GstPad object of the element.
*/
-#define GST_BASE_SRC_PAD(obj) (GST_BASE_SRC (obj)->srcpad)
+#define GST_BASE_SRC_PAD(obj) (GST_BASE_SRC_CAST (obj)->srcpad)
-#define GST_LIVE_GET_LOCK(elem) (GST_BASE_SRC(elem)->live_lock)
+#define GST_LIVE_GET_LOCK(elem) (GST_BASE_SRC_CAST(elem)->live_lock)
#define GST_LIVE_LOCK(elem) g_mutex_lock(GST_LIVE_GET_LOCK(elem))
#define GST_LIVE_TRYLOCK(elem) g_mutex_trylock(GST_LIVE_GET_LOCK(elem))
#define GST_LIVE_UNLOCK(elem) g_mutex_unlock(GST_LIVE_GET_LOCK(elem))
-#define GST_LIVE_GET_COND(elem) (GST_BASE_SRC(elem)->live_cond)
+#define GST_LIVE_GET_COND(elem) (GST_BASE_SRC_CAST(elem)->live_cond)
#define GST_LIVE_WAIT(elem) g_cond_wait (GST_LIVE_GET_COND (elem), GST_LIVE_GET_LOCK (elem))
#define GST_LIVE_TIMED_WAIT(elem, timeval) g_cond_timed_wait (GST_LIVE_GET_COND (elem), GST_LIVE_GET_LOCK (elem),\
timeval)