libs: re-indent all GstVaapiObject related source code.

Re-indent and provide additional minor cosmetical changes to the
GstVaapiMiniObject and GstVaapiObject source files.
This commit is contained in:
Gwenole Beauchesne 2014-12-02 14:15:49 +01:00
parent bee7460f35
commit c2afdb4650
5 changed files with 210 additions and 198 deletions

View file

@ -1,7 +1,7 @@
/* /*
* gstvaapiminiobject.c - A lightweight reference counted object * gstvaapiminiobject.c - A lightweight reference counted object
* *
* Copyright (C) 2012-2013 Intel Corporation * Copyright (C) 2012-2014 Intel Corporation
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com> * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -24,17 +24,17 @@
#include "gstvaapiminiobject.h" #include "gstvaapiminiobject.h"
static void static void
gst_vaapi_mini_object_free(GstVaapiMiniObject *object) gst_vaapi_mini_object_free (GstVaapiMiniObject * object)
{ {
const GstVaapiMiniObjectClass * const klass = object->object_class; const GstVaapiMiniObjectClass *const klass = object->object_class;
g_atomic_int_inc(&object->ref_count); g_atomic_int_inc (&object->ref_count);
if (klass->finalize) if (klass->finalize)
klass->finalize(object); klass->finalize (object);
if (G_LIKELY(g_atomic_int_dec_and_test(&object->ref_count))) if (G_LIKELY (g_atomic_int_dec_and_test (&object->ref_count)))
g_slice_free1(klass->size, object); g_slice_free1 (klass->size, object);
} }
/** /**
@ -52,20 +52,20 @@ gst_vaapi_mini_object_free(GstVaapiMiniObject *object)
* Returns: The newly allocated #GstVaapiMiniObject * Returns: The newly allocated #GstVaapiMiniObject
*/ */
GstVaapiMiniObject * GstVaapiMiniObject *
gst_vaapi_mini_object_new(const GstVaapiMiniObjectClass *object_class) gst_vaapi_mini_object_new (const GstVaapiMiniObjectClass * object_class)
{ {
GstVaapiMiniObject *object; GstVaapiMiniObject *object;
static const GstVaapiMiniObjectClass default_object_class = { static const GstVaapiMiniObjectClass default_object_class = {
.size = sizeof(GstVaapiMiniObject), .size = sizeof (GstVaapiMiniObject),
}; };
if (G_UNLIKELY(!object_class)) if (G_UNLIKELY (!object_class))
object_class = &default_object_class; object_class = &default_object_class;
g_return_val_if_fail(object_class->size >= sizeof(*object), NULL); g_return_val_if_fail (object_class->size >= sizeof (*object), NULL);
object = g_slice_alloc(object_class->size); object = g_slice_alloc (object_class->size);
if (!object) if (!object)
return NULL; return NULL;
@ -86,20 +86,20 @@ gst_vaapi_mini_object_new(const GstVaapiMiniObjectClass *object_class)
* Returns: The newly allocated #GstVaapiMiniObject * Returns: The newly allocated #GstVaapiMiniObject
*/ */
GstVaapiMiniObject * GstVaapiMiniObject *
gst_vaapi_mini_object_new0(const GstVaapiMiniObjectClass *object_class) gst_vaapi_mini_object_new0 (const GstVaapiMiniObjectClass * object_class)
{ {
GstVaapiMiniObject *object; GstVaapiMiniObject *object;
guint sub_size; guint sub_size;
object = gst_vaapi_mini_object_new(object_class); object = gst_vaapi_mini_object_new (object_class);
if (!object) if (!object)
return NULL; return NULL;
object_class = object->object_class; object_class = object->object_class;
sub_size = object_class->size - sizeof(*object); sub_size = object_class->size - sizeof (*object);
if (sub_size > 0) if (sub_size > 0)
memset(((guchar *)object) + sizeof(*object), 0, sub_size); memset (((guchar *) object) + sizeof (*object), 0, sub_size);
return object; return object;
} }
@ -112,11 +112,11 @@ gst_vaapi_mini_object_new0(const GstVaapiMiniObjectClass *object_class)
* Returns: The same @object argument * Returns: The same @object argument
*/ */
GstVaapiMiniObject * GstVaapiMiniObject *
gst_vaapi_mini_object_ref(GstVaapiMiniObject *object) gst_vaapi_mini_object_ref (GstVaapiMiniObject * object)
{ {
g_return_val_if_fail(object != NULL, NULL); g_return_val_if_fail (object != NULL, NULL);
g_atomic_int_inc(&object->ref_count); g_atomic_int_inc (&object->ref_count);
return object; return object;
} }
@ -128,13 +128,13 @@ gst_vaapi_mini_object_ref(GstVaapiMiniObject *object)
* the reference count reaches zero, the object will be free'd. * the reference count reaches zero, the object will be free'd.
*/ */
void void
gst_vaapi_mini_object_unref(GstVaapiMiniObject *object) gst_vaapi_mini_object_unref (GstVaapiMiniObject * object)
{ {
g_return_if_fail(object != NULL); g_return_if_fail (object != NULL);
g_return_if_fail(object->ref_count > 0); g_return_if_fail (object->ref_count > 0);
if (g_atomic_int_dec_and_test(&object->ref_count)) if (g_atomic_int_dec_and_test (&object->ref_count))
gst_vaapi_mini_object_free(object); gst_vaapi_mini_object_free (object);
} }
/** /**
@ -147,25 +147,25 @@ gst_vaapi_mini_object_unref(GstVaapiMiniObject *object)
* valid object. However, @new_object can be NULL. * valid object. However, @new_object can be NULL.
*/ */
void void
gst_vaapi_mini_object_replace(GstVaapiMiniObject **old_object_ptr, gst_vaapi_mini_object_replace (GstVaapiMiniObject ** old_object_ptr,
GstVaapiMiniObject *new_object) GstVaapiMiniObject * new_object)
{ {
GstVaapiMiniObject *old_object; GstVaapiMiniObject *old_object;
g_return_if_fail(old_object_ptr != NULL); g_return_if_fail (old_object_ptr != NULL);
old_object = g_atomic_pointer_get((gpointer *)old_object_ptr); old_object = g_atomic_pointer_get ((gpointer *) old_object_ptr);
if (old_object == new_object) if (old_object == new_object)
return; return;
if (new_object) if (new_object)
gst_vaapi_mini_object_ref(new_object); gst_vaapi_mini_object_ref (new_object);
while (!g_atomic_pointer_compare_and_exchange((gpointer *)old_object_ptr, while (!g_atomic_pointer_compare_and_exchange ((gpointer *) old_object_ptr,
old_object, new_object)) old_object, new_object))
old_object = g_atomic_pointer_get((gpointer *)old_object_ptr); old_object = g_atomic_pointer_get ((gpointer *) old_object_ptr);
if (old_object) if (old_object)
gst_vaapi_mini_object_unref(old_object); gst_vaapi_mini_object_unref (old_object);
} }

View file

@ -1,7 +1,7 @@
/* /*
* gstvaapiminiobject.h - A lightweight reference counted object * gstvaapiminiobject.h - A lightweight reference counted object
* *
* Copyright (C) 2012-2013 Intel Corporation * Copyright (C) 2012-2014 Intel Corporation
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com> * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -38,7 +38,16 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* Casts the @object to a #GstVaapiMiniObject * Casts the @object to a #GstVaapiMiniObject
*/ */
#define GST_VAAPI_MINI_OBJECT(object) \ #define GST_VAAPI_MINI_OBJECT(object) \
((GstVaapiMiniObject *)(object)) ((GstVaapiMiniObject *) (object))
/**
* GST_VAAPI_MINI_OBJECT_PTR:
* @object_ptr: a pointer #GstVaapiMiniObject
*
* Casts the @object_ptr to a pointer to #GstVaapiMiniObject
*/
#define GST_VAAPI_MINI_OBJECT_PTR(object_ptr) \
((GstVaapiMiniObject **) (object_ptr))
/** /**
* GST_VAAPI_MINI_OBJECT_CLASS: * GST_VAAPI_MINI_OBJECT_CLASS:
@ -47,7 +56,7 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* Casts the @klass to a #GstVaapiMiniObjectClass * Casts the @klass to a #GstVaapiMiniObjectClass
*/ */
#define GST_VAAPI_MINI_OBJECT_CLASS(klass) \ #define GST_VAAPI_MINI_OBJECT_CLASS(klass) \
((GstVaapiMiniObjectClass *)(klass)) ((GstVaapiMiniObjectClass *) (klass))
/** /**
* GST_VAAPI_MINI_OBJECT_GET_CLASS: * GST_VAAPI_MINI_OBJECT_GET_CLASS:
@ -56,7 +65,7 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* Retrieves the #GstVaapiMiniObjectClass associated with the @object * Retrieves the #GstVaapiMiniObjectClass associated with the @object
*/ */
#define GST_VAAPI_MINI_OBJECT_GET_CLASS(object) \ #define GST_VAAPI_MINI_OBJECT_GET_CLASS(object) \
(GST_VAAPI_MINI_OBJECT(object)->object_class) (GST_VAAPI_MINI_OBJECT (object)->object_class)
/** /**
* GST_VAAPI_MINI_OBJECT_FLAGS: * GST_VAAPI_MINI_OBJECT_FLAGS:
@ -65,7 +74,7 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* The entire set of flags for the @object * The entire set of flags for the @object
*/ */
#define GST_VAAPI_MINI_OBJECT_FLAGS(object) \ #define GST_VAAPI_MINI_OBJECT_FLAGS(object) \
(GST_VAAPI_MINI_OBJECT(object)->flags) (GST_VAAPI_MINI_OBJECT (object)->flags)
/** /**
* GST_VAAPI_MINI_OBJECT_FLAG_IS_SET: * GST_VAAPI_MINI_OBJECT_FLAG_IS_SET:
@ -75,7 +84,7 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* Checks whether the given @flag is set * Checks whether the given @flag is set
*/ */
#define GST_VAAPI_MINI_OBJECT_FLAG_IS_SET(object, flag) \ #define GST_VAAPI_MINI_OBJECT_FLAG_IS_SET(object, flag) \
((GST_VAAPI_MINI_OBJECT_FLAGS(object) & (flag)) != 0) ((GST_VAAPI_MINI_OBJECT_FLAGS (object) & (flag)) != 0)
/** /**
* GST_VAAPI_MINI_OBJECT_FLAG_SET: * GST_VAAPI_MINI_OBJECT_FLAG_SET:
@ -85,7 +94,7 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* This macro sets the given bits * This macro sets the given bits
*/ */
#define GST_VAAPI_MINI_OBJECT_FLAG_SET(object, flags) \ #define GST_VAAPI_MINI_OBJECT_FLAG_SET(object, flags) \
(GST_VAAPI_MINI_OBJECT_FLAGS(object) |= (flags)) (GST_VAAPI_MINI_OBJECT_FLAGS (object) |= (flags))
/** /**
* GST_VAAPI_MINI_OBJECT_FLAG_UNSET: * GST_VAAPI_MINI_OBJECT_FLAG_UNSET:
@ -95,7 +104,7 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* This macro unsets the given bits. * This macro unsets the given bits.
*/ */
#define GST_VAAPI_MINI_OBJECT_FLAG_UNSET(object, flags) \ #define GST_VAAPI_MINI_OBJECT_FLAG_UNSET(object, flags) \
(GST_VAAPI_MINI_OBJECT_FLAGS(object) &= ~(flags)) (GST_VAAPI_MINI_OBJECT_FLAGS (object) &= ~(flags))
/** /**
* GstVaapiMiniObject: * GstVaapiMiniObject:
@ -108,7 +117,8 @@ typedef struct _GstVaapiMiniObjectClass GstVaapiMiniObjectClass;
* A #GstVaapiMiniObject represents a minimal reference counted data * A #GstVaapiMiniObject represents a minimal reference counted data
* structure that can hold a set of flags and user-provided data. * structure that can hold a set of flags and user-provided data.
*/ */
struct _GstVaapiMiniObject { struct _GstVaapiMiniObject
{
/*< private >*/ /*< private >*/
gconstpointer object_class; gconstpointer object_class;
volatile gint ref_count; volatile gint ref_count;
@ -125,31 +135,33 @@ struct _GstVaapiMiniObject {
* defines the size of the #GstVaapiMiniObject and utility function to * defines the size of the #GstVaapiMiniObject and utility function to
* dispose child objects * dispose child objects
*/ */
struct _GstVaapiMiniObjectClass { struct _GstVaapiMiniObjectClass
{
/*< protected >*/
guint size; guint size;
GDestroyNotify finalize; GDestroyNotify finalize;
}; };
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiMiniObject * GstVaapiMiniObject *
gst_vaapi_mini_object_new(const GstVaapiMiniObjectClass *object_class); gst_vaapi_mini_object_new (const GstVaapiMiniObjectClass * object_class);
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiMiniObject * GstVaapiMiniObject *
gst_vaapi_mini_object_new0(const GstVaapiMiniObjectClass *object_class); gst_vaapi_mini_object_new0 (const GstVaapiMiniObjectClass * object_class);
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiMiniObject * GstVaapiMiniObject *
gst_vaapi_mini_object_ref(GstVaapiMiniObject *object); gst_vaapi_mini_object_ref (GstVaapiMiniObject * object);
G_GNUC_INTERNAL G_GNUC_INTERNAL
void void
gst_vaapi_mini_object_unref(GstVaapiMiniObject *object); gst_vaapi_mini_object_unref (GstVaapiMiniObject * object);
G_GNUC_INTERNAL G_GNUC_INTERNAL
void void
gst_vaapi_mini_object_replace(GstVaapiMiniObject **old_object_ptr, gst_vaapi_mini_object_replace (GstVaapiMiniObject ** old_object_ptr,
GstVaapiMiniObject *new_object); GstVaapiMiniObject * new_object);
G_END_DECLS G_END_DECLS

View file

@ -42,24 +42,23 @@
#undef gst_vaapi_object_replace #undef gst_vaapi_object_replace
static void static void
gst_vaapi_object_finalize(GstVaapiObject *object) gst_vaapi_object_finalize (GstVaapiObject * object)
{ {
const GstVaapiObjectClass * const klass = const GstVaapiObjectClass *const klass = GST_VAAPI_OBJECT_GET_CLASS (object);
GST_VAAPI_OBJECT_GET_CLASS(object);
if (klass->finalize) if (klass->finalize)
klass->finalize(object); klass->finalize (object);
gst_vaapi_display_replace(&object->display, NULL); gst_vaapi_display_replace (&object->display, NULL);
} }
void void
gst_vaapi_object_class_init(GstVaapiObjectClass *klass, guint size) gst_vaapi_object_class_init (GstVaapiObjectClass * klass, guint size)
{ {
GstVaapiMiniObjectClass * const object_class = GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS(klass); GST_VAAPI_MINI_OBJECT_CLASS (klass);
object_class->size = size; object_class->size = size;
object_class->finalize = (GDestroyNotify)gst_vaapi_object_finalize; object_class->finalize = (GDestroyNotify) gst_vaapi_object_finalize;
} }
/** /**
@ -77,26 +76,27 @@ gst_vaapi_object_class_init(GstVaapiObjectClass *klass, guint size)
* Returns: The newly allocated #GstVaapiObject * Returns: The newly allocated #GstVaapiObject
*/ */
gpointer gpointer
gst_vaapi_object_new(const GstVaapiObjectClass *klass, GstVaapiDisplay *display) gst_vaapi_object_new (const GstVaapiObjectClass * klass,
GstVaapiDisplay * display)
{ {
const GstVaapiMiniObjectClass * const object_class = const GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS(klass); GST_VAAPI_MINI_OBJECT_CLASS (klass);
GstVaapiObject *object; GstVaapiObject *object;
guint sub_size; guint sub_size;
g_return_val_if_fail(klass != NULL, NULL); g_return_val_if_fail (klass != NULL, NULL);
g_return_val_if_fail(display != NULL, NULL); g_return_val_if_fail (display != NULL, NULL);
object = (GstVaapiObject *)gst_vaapi_mini_object_new(object_class); object = (GstVaapiObject *) gst_vaapi_mini_object_new (object_class);
if (!object) if (!object)
return NULL; return NULL;
object->display = gst_vaapi_display_ref(display); object->display = gst_vaapi_display_ref (display);
object->object_id = VA_INVALID_ID; object->object_id = VA_INVALID_ID;
sub_size = object_class->size - sizeof(*object); sub_size = object_class->size - sizeof (*object);
if (sub_size > 0) if (sub_size > 0)
memset(((guchar *)object) + sizeof(*object), 0, sub_size); memset (((guchar *) object) + sizeof (*object), 0, sub_size);
if (klass && klass->init) if (klass && klass->init)
klass->init (object); klass->init (object);
@ -112,9 +112,9 @@ gst_vaapi_object_new(const GstVaapiObjectClass *klass, GstVaapiDisplay *display)
* Returns: The same @object argument * Returns: The same @object argument
*/ */
gpointer gpointer
gst_vaapi_object_ref(gpointer object) gst_vaapi_object_ref (gpointer object)
{ {
return gst_vaapi_object_ref_internal(object); return gst_vaapi_object_ref_internal (object);
} }
/** /**
@ -125,9 +125,9 @@ gst_vaapi_object_ref(gpointer object)
* the reference count reaches zero, the object will be free'd. * the reference count reaches zero, the object will be free'd.
*/ */
void void
gst_vaapi_object_unref(gpointer object) gst_vaapi_object_unref (gpointer object)
{ {
gst_vaapi_object_unref_internal(object); gst_vaapi_object_unref_internal (object);
} }
/** /**
@ -140,9 +140,9 @@ gst_vaapi_object_unref(gpointer object)
* valid object. However, @new_object can be NULL. * valid object. However, @new_object can be NULL.
*/ */
void void
gst_vaapi_object_replace(gpointer old_object_ptr, gpointer new_object) gst_vaapi_object_replace (gpointer old_object_ptr, gpointer new_object)
{ {
gst_vaapi_object_replace_internal(old_object_ptr, new_object); gst_vaapi_object_replace_internal (old_object_ptr, new_object);
} }
/** /**
@ -154,11 +154,11 @@ gst_vaapi_object_replace(gpointer old_object_ptr, gpointer new_object)
* Return value: the parent #GstVaapiDisplay object * Return value: the parent #GstVaapiDisplay object
*/ */
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_object_get_display(GstVaapiObject *object) gst_vaapi_object_get_display (GstVaapiObject * object)
{ {
g_return_val_if_fail(object != NULL, NULL); g_return_val_if_fail (object != NULL, NULL);
return GST_VAAPI_OBJECT_DISPLAY(object); return GST_VAAPI_OBJECT_DISPLAY (object);
} }
/** /**
@ -170,11 +170,11 @@ gst_vaapi_object_get_display(GstVaapiObject *object)
* unlocked by the other thread. * unlocked by the other thread.
*/ */
void void
gst_vaapi_object_lock_display(GstVaapiObject *object) gst_vaapi_object_lock_display (GstVaapiObject * object)
{ {
g_return_if_fail(object != NULL); g_return_if_fail (object != NULL);
GST_VAAPI_OBJECT_LOCK_DISPLAY(object); GST_VAAPI_OBJECT_LOCK_DISPLAY (object);
} }
/** /**
@ -186,11 +186,11 @@ gst_vaapi_object_lock_display(GstVaapiObject *object)
* display itself. * display itself.
*/ */
void void
gst_vaapi_object_unlock_display(GstVaapiObject *object) gst_vaapi_object_unlock_display (GstVaapiObject * object)
{ {
g_return_if_fail(object != NULL); g_return_if_fail (object != NULL);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(object); GST_VAAPI_OBJECT_UNLOCK_DISPLAY (object);
} }
/** /**
@ -202,9 +202,9 @@ gst_vaapi_object_unlock_display(GstVaapiObject *object)
* Return value: the #GstVaapiID of the @object * Return value: the #GstVaapiID of the @object
*/ */
GstVaapiID GstVaapiID
gst_vaapi_object_get_id(GstVaapiObject *object) gst_vaapi_object_get_id (GstVaapiObject * object)
{ {
g_return_val_if_fail(object != NULL, 0); g_return_val_if_fail (object != NULL, 0);
return GST_VAAPI_OBJECT_ID(object); return GST_VAAPI_OBJECT_ID (object);
} }

View file

@ -31,7 +31,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_VAAPI_OBJECT(obj) \ #define GST_VAAPI_OBJECT(obj) \
((GstVaapiObject *)(obj)) ((GstVaapiObject *) (obj))
typedef struct _GstVaapiObject GstVaapiObject; typedef struct _GstVaapiObject GstVaapiObject;
@ -42,7 +42,7 @@ typedef struct _GstVaapiObject GstVaapiObject;
* Macro that evaluates to the #GstVaapiDisplay the @object is bound to. * Macro that evaluates to the #GstVaapiDisplay the @object is bound to.
*/ */
#define GST_VAAPI_OBJECT_DISPLAY(object) \ #define GST_VAAPI_OBJECT_DISPLAY(object) \
gst_vaapi_object_get_display(GST_VAAPI_OBJECT(object)) gst_vaapi_object_get_display (GST_VAAPI_OBJECT (object))
/** /**
* GST_VAAPI_OBJECT_ID: * GST_VAAPI_OBJECT_ID:
@ -51,28 +51,28 @@ typedef struct _GstVaapiObject GstVaapiObject;
* Macro that evaluates to the #GstVaapiID contained in @object. * Macro that evaluates to the #GstVaapiID contained in @object.
*/ */
#define GST_VAAPI_OBJECT_ID(object) \ #define GST_VAAPI_OBJECT_ID(object) \
gst_vaapi_object_get_id(GST_VAAPI_OBJECT(object)) gst_vaapi_object_get_id (GST_VAAPI_OBJECT (object))
gpointer gpointer
gst_vaapi_object_ref(gpointer object); gst_vaapi_object_ref (gpointer object);
void void
gst_vaapi_object_unref(gpointer object); gst_vaapi_object_unref (gpointer object);
void void
gst_vaapi_object_replace(gpointer old_object_ptr, gpointer new_object); gst_vaapi_object_replace (gpointer old_object_ptr, gpointer new_object);
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_object_get_display(GstVaapiObject *object); gst_vaapi_object_get_display (GstVaapiObject * object);
void void
gst_vaapi_object_lock_display(GstVaapiObject *object); gst_vaapi_object_lock_display (GstVaapiObject * object);
void void
gst_vaapi_object_unlock_display(GstVaapiObject *object); gst_vaapi_object_unlock_display (GstVaapiObject * object);
GstVaapiID GstVaapiID
gst_vaapi_object_get_id(GstVaapiObject *object); gst_vaapi_object_get_id (GstVaapiObject * object);
G_END_DECLS G_END_DECLS

View file

@ -32,50 +32,37 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_VAAPI_OBJECT_CLASS(klass) \ #define GST_VAAPI_OBJECT_CLASS(klass) \
((GstVaapiObjectClass *)(klass)) ((GstVaapiObjectClass *) (klass))
#define GST_VAAPI_IS_OBJECT_CLASS(klass) \ #define GST_VAAPI_IS_OBJECT_CLASS(klass) \
((klass) != NULL) ((klass) != NULL)
#define GST_VAAPI_OBJECT_GET_CLASS(object) \ #define GST_VAAPI_OBJECT_GET_CLASS(object) \
GST_VAAPI_OBJECT_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(object)) GST_VAAPI_OBJECT_CLASS (GST_VAAPI_MINI_OBJECT_GET_CLASS (object))
typedef struct _GstVaapiObjectClass GstVaapiObjectClass; typedef struct _GstVaapiObjectClass GstVaapiObjectClass;
typedef void (*GstVaapiObjectInitFunc) (GstVaapiObject *object); typedef void (*GstVaapiObjectInitFunc) (GstVaapiObject * object);
typedef void (*GstVaapiObjectFinalizeFunc) (GstVaapiObject *object); typedef void (*GstVaapiObjectFinalizeFunc) (GstVaapiObject * object);
#define GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(TN, t_n, code) \ #define GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(TN, t_n, code) \
static inline const GstVaapiObjectClass * \ static inline const GstVaapiObjectClass * \
G_PASTE(t_n,_class)(void) \ G_PASTE(t_n,_class) (void) \
{ \ { \
static G_PASTE(TN,Class) g_class; \ static G_PASTE(TN,Class) g_class; \
static gsize g_class_init = FALSE; \ static gsize g_class_init = FALSE; \
\ \
if (g_once_init_enter(&g_class_init)) { \ if (g_once_init_enter (&g_class_init)) { \
GstVaapiObjectClass * const klass = \ GstVaapiObjectClass * const klass = \
GST_VAAPI_OBJECT_CLASS(&g_class); \ GST_VAAPI_OBJECT_CLASS (&g_class); \
gst_vaapi_object_class_init(klass, sizeof(TN)); \ gst_vaapi_object_class_init (klass, sizeof(TN)); \
code; \ code; \
klass->finalize = (GstVaapiObjectFinalizeFunc) \ klass->finalize = (GstVaapiObjectFinalizeFunc) \
G_PASTE(t_n,_finalize); \ G_PASTE(t_n,_finalize); \
g_once_init_leave(&g_class_init, TRUE); \ g_once_init_leave (&g_class_init, TRUE); \
} \ } \
return GST_VAAPI_OBJECT_CLASS(&g_class); \ return GST_VAAPI_OBJECT_CLASS (&g_class); \
} }
#define GST_VAAPI_OBJECT_DEFINE_CLASS(TN, t_n) \ #define GST_VAAPI_OBJECT_DEFINE_CLASS(TN, t_n) \
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(TN, t_n, /**/) GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (TN, t_n, /**/)
/**
* GST_VAAPI_OBJECT_DISPLAY:
* @object: a #GstVaapiObject
*
* Macro that evaluates to the #GstVaapiDisplay the @object is bound to.
* This is an internal macro that does not do any run-time type check.
*/
#undef GST_VAAPI_OBJECT_DISPLAY
#define GST_VAAPI_OBJECT_DISPLAY(object) \
GST_VAAPI_OBJECT(object)->display
/** /**
* GST_VAAPI_OBJECT_ID: * GST_VAAPI_OBJECT_ID:
@ -86,7 +73,18 @@ G_PASTE(t_n,_class)(void) \
*/ */
#undef GST_VAAPI_OBJECT_ID #undef GST_VAAPI_OBJECT_ID
#define GST_VAAPI_OBJECT_ID(object) \ #define GST_VAAPI_OBJECT_ID(object) \
GST_VAAPI_OBJECT(object)->object_id (GST_VAAPI_OBJECT (object)->object_id)
/**
* GST_VAAPI_OBJECT_DISPLAY:
* @object: a #GstVaapiObject
*
* Macro that evaluates to the #GstVaapiDisplay the @object is bound to.
* This is an internal macro that does not do any run-time type check.
*/
#undef GST_VAAPI_OBJECT_DISPLAY
#define GST_VAAPI_OBJECT_DISPLAY(object) \
(GST_VAAPI_OBJECT (object)->display)
/** /**
* GST_VAAPI_OBJECT_DISPLAY_X11: * GST_VAAPI_OBJECT_DISPLAY_X11:
@ -97,7 +95,7 @@ G_PASTE(t_n,_class)(void) \
* and requires #include "gstvaapidisplay_x11_priv.h" * and requires #include "gstvaapidisplay_x11_priv.h"
*/ */
#define GST_VAAPI_OBJECT_DISPLAY_X11(object) \ #define GST_VAAPI_OBJECT_DISPLAY_X11(object) \
GST_VAAPI_DISPLAY_X11_CAST(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_X11_CAST (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_DISPLAY_GLX: * GST_VAAPI_OBJECT_DISPLAY_GLX:
@ -108,7 +106,7 @@ G_PASTE(t_n,_class)(void) \
* and requires #include "gstvaapidisplay_glx_priv.h". * and requires #include "gstvaapidisplay_glx_priv.h".
*/ */
#define GST_VAAPI_OBJECT_DISPLAY_GLX(object) \ #define GST_VAAPI_OBJECT_DISPLAY_GLX(object) \
GST_VAAPI_DISPLAY_GLX_CAST(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_GLX_CAST (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_DISPLAY_WAYLAND: * GST_VAAPI_OBJECT_DISPLAY_WAYLAND:
@ -119,7 +117,7 @@ G_PASTE(t_n,_class)(void) \
* type check and requires #include "gstvaapidisplay_wayland_priv.h" * type check and requires #include "gstvaapidisplay_wayland_priv.h"
*/ */
#define GST_VAAPI_OBJECT_DISPLAY_WAYLAND(object) \ #define GST_VAAPI_OBJECT_DISPLAY_WAYLAND(object) \
GST_VAAPI_DISPLAY_WAYLAND_CAST(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_WAYLAND_CAST (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_VADISPLAY: * GST_VAAPI_OBJECT_VADISPLAY:
@ -130,7 +128,7 @@ G_PASTE(t_n,_class)(void) \
* and requires #include "gstvaapidisplay_priv.h". * and requires #include "gstvaapidisplay_priv.h".
*/ */
#define GST_VAAPI_OBJECT_VADISPLAY(object) \ #define GST_VAAPI_OBJECT_VADISPLAY(object) \
GST_VAAPI_DISPLAY_VADISPLAY(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_VADISPLAY (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_XDISPLAY: * GST_VAAPI_OBJECT_XDISPLAY:
@ -141,7 +139,7 @@ G_PASTE(t_n,_class)(void) \
* and requires #include "gstvaapidisplay_x11_priv.h". * and requires #include "gstvaapidisplay_x11_priv.h".
*/ */
#define GST_VAAPI_OBJECT_XDISPLAY(object) \ #define GST_VAAPI_OBJECT_XDISPLAY(object) \
GST_VAAPI_DISPLAY_XDISPLAY(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_XDISPLAY (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_XSCREEN: * GST_VAAPI_OBJECT_XSCREEN:
@ -152,7 +150,7 @@ G_PASTE(t_n,_class)(void) \
* and requires #include "gstvaapidisplay_x11_priv.h". * and requires #include "gstvaapidisplay_x11_priv.h".
*/ */
#define GST_VAAPI_OBJECT_XSCREEN(object) \ #define GST_VAAPI_OBJECT_XSCREEN(object) \
GST_VAAPI_DISPLAY_XSCREEN(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_XSCREEN (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_WL_DISPLAY: * GST_VAAPI_OBJECT_WL_DISPLAY:
@ -163,7 +161,7 @@ G_PASTE(t_n,_class)(void) \
* and requires #include "gstvaapidisplay_wayland_priv.h". * and requires #include "gstvaapidisplay_wayland_priv.h".
*/ */
#define GST_VAAPI_OBJECT_WL_DISPLAY(object) \ #define GST_VAAPI_OBJECT_WL_DISPLAY(object) \
GST_VAAPI_DISPLAY_WL_DISPLAY(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_WL_DISPLAY (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_LOCK_DISPLAY: * GST_VAAPI_OBJECT_LOCK_DISPLAY:
@ -173,7 +171,7 @@ G_PASTE(t_n,_class)(void) \
* This is an internal macro that does not do any run-time type check. * This is an internal macro that does not do any run-time type check.
*/ */
#define GST_VAAPI_OBJECT_LOCK_DISPLAY(object) \ #define GST_VAAPI_OBJECT_LOCK_DISPLAY(object) \
GST_VAAPI_DISPLAY_LOCK(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_LOCK (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GST_VAAPI_OBJECT_UNLOCK_DISPLAY: * GST_VAAPI_OBJECT_UNLOCK_DISPLAY:
@ -183,14 +181,15 @@ G_PASTE(t_n,_class)(void) \
* This is an internal macro that does not do any run-time type check. * This is an internal macro that does not do any run-time type check.
*/ */
#define GST_VAAPI_OBJECT_UNLOCK_DISPLAY(object) \ #define GST_VAAPI_OBJECT_UNLOCK_DISPLAY(object) \
GST_VAAPI_DISPLAY_UNLOCK(GST_VAAPI_OBJECT_DISPLAY(object)) GST_VAAPI_DISPLAY_UNLOCK (GST_VAAPI_OBJECT_DISPLAY (object))
/** /**
* GstVaapiObject: * GstVaapiObject:
* *
* VA object base. * VA object base.
*/ */
struct _GstVaapiObject { struct _GstVaapiObject
{
/*< private >*/ /*< private >*/
GstVaapiMiniObject parent_instance; GstVaapiMiniObject parent_instance;
@ -203,7 +202,8 @@ struct _GstVaapiObject {
* *
* VA object base class. * VA object base class.
*/ */
struct _GstVaapiObjectClass { struct _GstVaapiObjectClass
{
/*< private >*/ /*< private >*/
GstVaapiMiniObjectClass parent_class; GstVaapiMiniObjectClass parent_class;
@ -212,44 +212,44 @@ struct _GstVaapiObjectClass {
}; };
void void
gst_vaapi_object_class_init(GstVaapiObjectClass *klass, guint size); gst_vaapi_object_class_init (GstVaapiObjectClass * klass, guint size);
gpointer gpointer
gst_vaapi_object_new(const GstVaapiObjectClass *klass, gst_vaapi_object_new (const GstVaapiObjectClass * klass,
GstVaapiDisplay *display); GstVaapiDisplay * display);
/* Inline reference counting for core libgstvaapi library */ /* Inline reference counting for core libgstvaapi library */
#ifdef IN_LIBGSTVAAPI_CORE #ifdef IN_LIBGSTVAAPI_CORE
static inline gpointer static inline gpointer
gst_vaapi_object_ref_internal(gpointer object) gst_vaapi_object_ref_internal (gpointer object)
{ {
return gst_vaapi_mini_object_ref(object); return gst_vaapi_mini_object_ref (object);
} }
static inline void static inline void
gst_vaapi_object_unref_internal(gpointer object) gst_vaapi_object_unref_internal (gpointer object)
{ {
gst_vaapi_mini_object_unref(object); gst_vaapi_mini_object_unref (object);
} }
static inline void static inline void
gst_vaapi_object_replace_internal(gpointer old_object_ptr, gpointer new_object) gst_vaapi_object_replace_internal (gpointer old_object_ptr, gpointer new_object)
{ {
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)old_object_ptr, gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) old_object_ptr,
new_object); new_object);
} }
#undef gst_vaapi_object_ref #undef gst_vaapi_object_ref
#define gst_vaapi_object_ref(object) \ #define gst_vaapi_object_ref(object) \
gst_vaapi_object_ref_internal((object)) gst_vaapi_object_ref_internal ((object))
#undef gst_vaapi_object_unref #undef gst_vaapi_object_unref
#define gst_vaapi_object_unref(object) \ #define gst_vaapi_object_unref(object) \
gst_vaapi_object_unref_internal((object)) gst_vaapi_object_unref_internal ((object))
#undef gst_vaapi_object_replace #undef gst_vaapi_object_replace
#define gst_vaapi_object_replace(old_object_ptr, new_object) \ #define gst_vaapi_object_replace(old_object_ptr, new_object) \
gst_vaapi_object_replace_internal((old_object_ptr), (new_object)) gst_vaapi_object_replace_internal ((old_object_ptr), (new_object))
#endif #endif
G_END_DECLS G_END_DECLS