mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
Add "destroy" signal.
This commit is contained in:
parent
2e0112b882
commit
e403f26bc5
7 changed files with 96 additions and 1 deletions
|
@ -103,6 +103,7 @@ AM_CONDITIONAL([BUILD_GTK_DOC], [test "x$enable_gtk_doc" = "xyes"])
|
|||
AC_SUBST(GTKDOC_VERSION)
|
||||
|
||||
dnl Check for GLib
|
||||
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
|
||||
PKG_CHECK_MODULES([GLIB], [glib-2.0])
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
gst_vaapi_object_get_type
|
||||
gst_vaapi_surface_pool_get_type
|
||||
gst_vaapi_video_pool_get_type
|
||||
gst_vaapi_video_sink_get_type
|
||||
|
|
|
@ -11,6 +11,7 @@ libgstvaapi_source_c = \
|
|||
gstvaapiimage.c \
|
||||
gstvaapiimageformat.c \
|
||||
gstvaapiimagepool.c \
|
||||
gstvaapimarshal.c \
|
||||
gstvaapiobject.c \
|
||||
gstvaapisubpicture.c \
|
||||
gstvaapisurface.c \
|
||||
|
@ -112,3 +113,36 @@ libgstvaapi_x11_@GST_MAJORMINOR@_la_LIBADD = \
|
|||
|
||||
# Extra clean files so that maintainer-clean removes *everything*
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
# glib-genmarshal rules
|
||||
glib_marshal_list = gstvaapimarshal.list
|
||||
glib_marshal_prefix = gst_vaapi_marshal
|
||||
|
||||
marshal_h = $(glib_marshal_list:.list=.h)
|
||||
marshal_c = $(glib_marshal_list:.list=.c)
|
||||
|
||||
CLEANFILES = stamp-marshal
|
||||
DISTCLEANFILES = $(marshal_h) $(marshal_c)
|
||||
BUILT_SOURCES = $(marshal_h) $(marshal_c)
|
||||
EXTRA_DIST = $(srcdir)/$(glib_marshal_list)
|
||||
|
||||
stamp-marshal: $(glib_marshal_list)
|
||||
$(GLIB_GENMARSHAL) \
|
||||
--prefix=$(glib_marshal_prefix) \
|
||||
--header \
|
||||
$(srcdir)/$(glib_marshal_list) > xgen-mh \
|
||||
&& (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
|
||||
&& rm -f xgen-mh \
|
||||
&& echo timestamp > $(@F)
|
||||
|
||||
$(marshal_h): stamp-marshal
|
||||
@true
|
||||
|
||||
$(marshal_c): $(marshal_h)
|
||||
(echo "#include \"$(marshal_h)\"" ; \
|
||||
$(GLIB_GENMARSHAL) \
|
||||
--prefix=$(glib_marshal_prefix) \
|
||||
--body \
|
||||
$(srcdir)/$(glib_marshal_list)) > xgen-mc \
|
||||
&& cp xgen-mc $(marshal_c) \
|
||||
&& rm -f xgen-mc
|
||||
|
|
1
gst-libs/gst/vaapi/gstvaapimarshal.list
Normal file
1
gst-libs/gst/vaapi/gstvaapimarshal.list
Normal file
|
@ -0,0 +1 @@
|
|||
VOID:VOID
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "gstvaapiobject.h"
|
||||
|
||||
#include "gstvaapimarshal.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
@ -34,6 +34,7 @@ G_DEFINE_TYPE(GstVaapiObject, gst_vaapi_object, G_TYPE_OBJECT);
|
|||
|
||||
struct _GstVaapiObjectPrivate {
|
||||
GstVaapiDisplay *display;
|
||||
guint is_destroying : 1;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -42,6 +43,28 @@ enum {
|
|||
PROP_DISPLAY,
|
||||
};
|
||||
|
||||
enum {
|
||||
DESTROY,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint object_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
static void
|
||||
gst_vaapi_object_dispose(GObject *object)
|
||||
{
|
||||
GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv;
|
||||
|
||||
if (!priv->is_destroying) {
|
||||
priv->is_destroying = TRUE;
|
||||
g_signal_emit(object, object_signals[DESTROY], 0);
|
||||
priv->is_destroying = FALSE;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(gst_vaapi_object_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_object_finalize(GObject *object)
|
||||
{
|
||||
|
@ -102,6 +125,7 @@ gst_vaapi_object_class_init(GstVaapiObjectClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(GstVaapiObjectPrivate));
|
||||
|
||||
object_class->dispose = gst_vaapi_object_dispose;
|
||||
object_class->finalize = gst_vaapi_object_finalize;
|
||||
object_class->set_property = gst_vaapi_object_set_property;
|
||||
object_class->get_property = gst_vaapi_object_get_property;
|
||||
|
@ -119,6 +143,23 @@ gst_vaapi_object_class_init(GstVaapiObjectClass *klass)
|
|||
"The GstVaapiDisplay this object is bound to",
|
||||
GST_VAAPI_TYPE_DISPLAY,
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/**
|
||||
* GstVaapiObject::destroy:
|
||||
* @object: the object which received the signal
|
||||
*
|
||||
* The ::destroy signal is emitted when an object is destroyed,
|
||||
* when the user released the last reference to @object.
|
||||
*/
|
||||
object_signals[DESTROY] = g_signal_new(
|
||||
"destroy",
|
||||
G_TYPE_FROM_CLASS(object_class),
|
||||
G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(GstVaapiObjectClass, destroy),
|
||||
NULL, NULL,
|
||||
gst_vaapi_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0
|
||||
);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -128,6 +169,7 @@ gst_vaapi_object_init(GstVaapiObject *object)
|
|||
|
||||
object->priv = priv;
|
||||
priv->display = NULL;
|
||||
priv->is_destroying = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,12 +77,16 @@ struct _GstVaapiObject {
|
|||
|
||||
/**
|
||||
* GstVaapiObjectClass:
|
||||
* @destroy: signal class handler for #GstVaapiObject::destroy
|
||||
*
|
||||
* VA object base class.
|
||||
*/
|
||||
struct _GstVaapiObjectClass {
|
||||
/*< private >*/
|
||||
GObjectClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
void (*destroy)(GstVaapiObject *oject);
|
||||
};
|
||||
|
||||
GType
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
|
||||
#define MAX_SURFACES 4
|
||||
|
||||
static void
|
||||
gst_vaapi_object_destroy_cb(gpointer object, gpointer user_data)
|
||||
{
|
||||
g_print("Destroying GstVaapiObject %p\n", object);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -95,6 +101,12 @@ main(int argc, char *argv[])
|
|||
surfaces[i] = NULL;
|
||||
}
|
||||
|
||||
g_signal_connect(
|
||||
G_OBJECT(surface),
|
||||
"destroy",
|
||||
G_CALLBACK(gst_vaapi_object_destroy_cb), NULL
|
||||
);
|
||||
|
||||
/* Unref in random order to check objects are correctly refcounted */
|
||||
g_print("unref display\n");
|
||||
g_object_unref(display);
|
||||
|
|
Loading…
Reference in a new issue