gstreamer_core/gst/gstinterface.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    49 
    49 
    50 
    50 
    51 GType
    51 GType
    52 gst_implements_interface_get_type (void)
    52 gst_implements_interface_get_type (void)
    53 {
    53 {
    54   static volatile gsize gst_interface_type = 0;
    54   static GType gst_interface_type = 0;
    55 
    55 
    56   if (g_once_init_enter (&gst_interface_type)) {
    56   if (!gst_interface_type) {
    57     GType _type;
       
    58     static const GTypeInfo gst_interface_info = {
    57     static const GTypeInfo gst_interface_info = {
    59       sizeof (GstImplementsInterfaceClass),
    58       sizeof (GstImplementsInterfaceClass),
    60       (GBaseInitFunc) gst_implements_interface_class_init,
    59       (GBaseInitFunc) gst_implements_interface_class_init,
    61       NULL,
    60       NULL,
    62       NULL,
    61       NULL,
    66       0,
    65       0,
    67       NULL,
    66       NULL,
    68       NULL
    67       NULL
    69     };
    68     };
    70 
    69 
    71     _type = g_type_register_static (G_TYPE_INTERFACE,
    70     gst_interface_type = g_type_register_static (G_TYPE_INTERFACE,
    72         "GstImplementsInterface", &gst_interface_info, 0);
    71         "GstImplementsInterface", &gst_interface_info, 0);
    73 
    72 
    74     g_type_interface_add_prerequisite (_type, GST_TYPE_ELEMENT);
    73     g_type_interface_add_prerequisite (gst_interface_type, GST_TYPE_ELEMENT);
    75     g_once_init_leave (&gst_interface_type, _type);
       
    76   }
    74   }
    77 
    75 
    78   return gst_interface_type;
    76   return gst_interface_type;
    79 }
    77 }
    80 
    78 
   188 
   186 
   189 
   187 
   190 gboolean
   188 gboolean
   191 gst_implements_interface_check (gpointer from, GType type)
   189 gst_implements_interface_check (gpointer from, GType type)
   192 {
   190 {
       
   191   GstImplementsInterface *iface;
       
   192 
   193   /* check cast, return FALSE if it fails, don't give a warning... */
   193   /* check cast, return FALSE if it fails, don't give a warning... */
   194   if (!G_TYPE_CHECK_INSTANCE_TYPE (from, type)) {
   194   if (!G_TYPE_CHECK_INSTANCE_TYPE (from, type)) {
   195     return FALSE;
   195     return FALSE;
   196   }
   196   }
       
   197 
       
   198   iface = G_TYPE_CHECK_INSTANCE_CAST (from, type, GstImplementsInterface);
   197 
   199 
   198   /* now, if we're an element (or derivative), is this thing
   200   /* now, if we're an element (or derivative), is this thing
   199    * actually implemented for real? */
   201    * actually implemented for real? */
   200   if (GST_IS_ELEMENT (from)) {
   202   if (GST_IS_ELEMENT (from)) {
   201     if (!gst_element_implements_interface (GST_ELEMENT (from), type)) {
   203     if (!gst_element_implements_interface (GST_ELEMENT (from), type)) {