From: gb Date: Tue, 23 Mar 2010 17:12:40 +0000 (+0000) Subject: Add "destroy" signal. X-Git-Tag: 0.1.1~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e403f26bc53661bc95c9e0c350618b8b6f492342;p=platform%2Fupstream%2Fgstreamer-vaapi.git Add "destroy" signal. --- diff --git a/configure.ac b/configure.ac index a478004..cc3d591 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/docs/reference/libs/libs.types b/docs/reference/libs/libs.types index 3efeb0a..ebc148d 100644 --- a/docs/reference/libs/libs.types +++ b/docs/reference/libs/libs.types @@ -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 diff --git a/gst-libs/gst/vaapi/Makefile.am b/gst-libs/gst/vaapi/Makefile.am index 051ef82..8260bdb 100644 --- a/gst-libs/gst/vaapi/Makefile.am +++ b/gst-libs/gst/vaapi/Makefile.am @@ -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 diff --git a/gst-libs/gst/vaapi/gstvaapimarshal.list b/gst-libs/gst/vaapi/gstvaapimarshal.list new file mode 100644 index 0000000..5b76282 --- /dev/null +++ b/gst-libs/gst/vaapi/gstvaapimarshal.list @@ -0,0 +1 @@ +VOID:VOID diff --git a/gst-libs/gst/vaapi/gstvaapiobject.c b/gst-libs/gst/vaapi/gstvaapiobject.c index cee67b5..aad44fa 100644 --- a/gst-libs/gst/vaapi/gstvaapiobject.c +++ b/gst-libs/gst/vaapi/gstvaapiobject.c @@ -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; } /** diff --git a/gst-libs/gst/vaapi/gstvaapiobject.h b/gst-libs/gst/vaapi/gstvaapiobject.h index 45f1a6e..5fcd133 100644 --- a/gst-libs/gst/vaapi/gstvaapiobject.h +++ b/gst-libs/gst/vaapi/gstvaapiobject.h @@ -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 diff --git a/tests/test-surfaces.c b/tests/test-surfaces.c index d201bdb..fca9f6a 100644 --- a/tests/test-surfaces.c +++ b/tests/test-surfaces.c @@ -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);