2006-06-12 Wim Taymans <wim@fluendo.com>
+ * gst/gstbuffer.c: (gst_buffer_get_type), (gst_buffer_finalize),
+ (_gst_buffer_copy), (gst_buffer_is_metadata_writable),
+ (gst_subbuffer_finalize), (gst_buffer_create_sub),
+ (gst_buffer_is_span_fast), (gst_buffer_span):
+ Init _type for consistency.
+ Use _FLAGS macro to avoid type check.
+ Avoid unneeded type checks in subbufer code.
+
+2006-06-12 Wim Taymans <wim@fluendo.com>
+
* gst/gst.c: (gst_debug_help):
* gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
GType
gst_buffer_get_type (void)
{
- static GType _gst_buffer_type;
+ static GType _gst_buffer_type = 0;
if (G_UNLIKELY (_gst_buffer_type == 0)) {
static const GTypeInfo buffer_info = {
GST_CAT_LOG (GST_CAT_BUFFER, "finalize %p", buffer);
/* free our data */
- if (buffer->malloc_data) {
- g_free (buffer->malloc_data);
- }
+ g_free (buffer->malloc_data);
gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL);
}
mask = GST_BUFFER_FLAG_PREROLL | GST_BUFFER_FLAG_IN_CAPS |
GST_BUFFER_FLAG_DELTA_UNIT | GST_BUFFER_FLAG_DISCONT |
GST_BUFFER_FLAG_GAP;
- GST_MINI_OBJECT (copy)->flags |= GST_MINI_OBJECT (buffer)->flags & mask;
+ GST_MINI_OBJECT_FLAGS (copy) |= GST_MINI_OBJECT_FLAGS (buffer) & mask;
/* we simply copy everything from our parent */
copy->data = g_memdup (buffer->data, buffer->size);
gboolean
gst_buffer_is_metadata_writable (GstBuffer * buf)
{
- return (GST_MINI_OBJECT_REFCOUNT_VALUE (GST_MINI_OBJECT (buf)) == 1);
+ return (GST_MINI_OBJECT_REFCOUNT_VALUE (GST_MINI_OBJECT_CAST (buf)) == 1);
}
/**
#define GST_TYPE_SUBBUFFER (gst_subbuffer_get_type())
-#define GST_IS_SUBBUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SUBBUFFER))
-#define GST_SUBBUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SUBBUFFER, GstSubBuffer))
+#define GST_IS_SUBBUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SUBBUFFER))
+#define GST_SUBBUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SUBBUFFER, GstSubBuffer))
+#define GST_SUBBUFFER_CAST(obj) ((GstSubBuffer *)(obj))
struct _GstSubBuffer
{
{
gst_buffer_unref (buffer->parent);
- GST_MINI_OBJECT_CLASS (sub_parent_class)->finalize (GST_MINI_OBJECT (buffer));
+ GST_MINI_OBJECT_CLASS (sub_parent_class)->
+ finalize (GST_MINI_OBJECT_CAST (buffer));
}
static void
/* find real parent */
if (GST_IS_SUBBUFFER (buffer)) {
- parent = GST_SUBBUFFER (buffer)->parent;
+ parent = GST_SUBBUFFER_CAST (buffer)->parent;
} else {
parent = buffer;
}
/* it's only fast if we have subbuffers of the same parent */
return (GST_IS_SUBBUFFER (buf1) &&
GST_IS_SUBBUFFER (buf2) &&
- (GST_SUBBUFFER (buf1)->parent == GST_SUBBUFFER (buf2)->parent) &&
- ((buf1->data + buf1->size) == buf2->data));
+ (GST_SUBBUFFER_CAST (buf1)->parent == GST_SUBBUFFER_CAST (buf2)->parent)
+ && ((buf1->data + buf1->size) == buf2->data));
}
/**
/* if the two buffers have the same parent and are adjacent */
if (gst_buffer_is_span_fast (buf1, buf2)) {
- GstBuffer *parent = GST_SUBBUFFER (buf1)->parent;
+ GstBuffer *parent = GST_SUBBUFFER_CAST (buf1)->parent;
/* we simply create a subbuffer of the common parent */
newbuf = gst_buffer_create_sub (parent,