mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +00:00
libs: expose GstVaapiMiniObject APIs to all backends.
Make it possible to have all libgstvaapi backends (libs) access to a common GstVaapiMiniObject API and implementation. This is a minor step towards full exposure when needed, but restrict it to libgstvaapi at this time.
This commit is contained in:
parent
c2afdb4650
commit
fd775b4400
2 changed files with 56 additions and 12 deletions
|
@ -23,7 +23,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gstvaapiminiobject.h"
|
#include "gstvaapiminiobject.h"
|
||||||
|
|
||||||
static void
|
/* Ensure those symbols are actually defined in the resulting libraries */
|
||||||
|
#undef gst_vaapi_mini_object_ref
|
||||||
|
#undef gst_vaapi_mini_object_unref
|
||||||
|
#undef gst_vaapi_mini_object_replace
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -116,8 +121,7 @@ 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);
|
return gst_vaapi_mini_object_ref_internal (object);
|
||||||
return object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,8 +137,7 @@ 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))
|
gst_vaapi_mini_object_unref_internal (object);
|
||||||
gst_vaapi_mini_object_free (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,12 +163,12 @@ gst_vaapi_mini_object_replace (GstVaapiMiniObject ** old_object_ptr,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (new_object)
|
if (new_object)
|
||||||
gst_vaapi_mini_object_ref (new_object);
|
gst_vaapi_mini_object_ref_internal (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_internal (old_object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,27 +142,68 @@ struct _GstVaapiMiniObjectClass
|
||||||
GDestroyNotify finalize;
|
GDestroyNotify finalize;
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
|
||||||
GstVaapiMiniObject *
|
GstVaapiMiniObject *
|
||||||
gst_vaapi_mini_object_new0 (const GstVaapiMiniObjectClass * object_class);
|
gst_vaapi_mini_object_new0 (const GstVaapiMiniObjectClass * object_class);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GstVaapiMiniObject *
|
GstVaapiMiniObject *
|
||||||
gst_vaapi_mini_object_ref (GstVaapiMiniObject * object);
|
gst_vaapi_mini_object_ref (GstVaapiMiniObject * object);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
void
|
void
|
||||||
gst_vaapi_mini_object_unref (GstVaapiMiniObject * object);
|
gst_vaapi_mini_object_unref (GstVaapiMiniObject * object);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
#ifdef IN_LIBGSTVAAPI_CORE
|
||||||
|
#undef gst_vaapi_mini_object_ref
|
||||||
|
#define gst_vaapi_mini_object_ref(object) \
|
||||||
|
gst_vaapi_mini_object_ref_internal (object)
|
||||||
|
|
||||||
|
#undef gst_vaapi_mini_object_unref
|
||||||
|
#define gst_vaapi_mini_object_unref(object) \
|
||||||
|
gst_vaapi_mini_object_unref_internal (object)
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void
|
||||||
|
gst_vaapi_mini_object_free (GstVaapiMiniObject * object);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_mini_object_ref_internal:
|
||||||
|
* @object: a #GstVaapiMiniObject
|
||||||
|
*
|
||||||
|
* Atomically increases the reference count of the given @object by one.
|
||||||
|
* This is an internal function that does not do any run-time type check.
|
||||||
|
*
|
||||||
|
* Returns: The same @object argument
|
||||||
|
*/
|
||||||
|
static inline GstVaapiMiniObject *
|
||||||
|
gst_vaapi_mini_object_ref_internal (GstVaapiMiniObject * object)
|
||||||
|
{
|
||||||
|
g_atomic_int_inc (&object->ref_count);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_mini_object_unref_internal:
|
||||||
|
* @object: a #GstVaapiMiniObject
|
||||||
|
*
|
||||||
|
* Atomically decreases the reference count of the @object by one. If
|
||||||
|
* the reference count reaches zero, the object will be free'd.
|
||||||
|
*
|
||||||
|
* This is an internal function that does not do any run-time type check.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
gst_vaapi_mini_object_unref_internal (GstVaapiMiniObject * object)
|
||||||
|
{
|
||||||
|
if (g_atomic_int_dec_and_test (&object->ref_count))
|
||||||
|
gst_vaapi_mini_object_free (object);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_MINI_OBJECT_H */
|
#endif /* GST_VAAPI_MINI_OBJECT_H */
|
||||||
|
|
Loading…
Reference in a new issue