Revert "gst/parse: define pure-parser depending on bison version"
[platform/upstream/gstreamer.git] / gst / gstdevice.c
index ee92619..64f5ba5 100644 (file)
@@ -21,6 +21,7 @@
 
 /**
  * SECTION:gstdevice
+ * @title: GstDevice
  * @short_description: Object representing a device
  * @see_also: #GstDeviceProvider
  *
@@ -67,7 +68,7 @@ struct _GstDevicePrivate
 
 static guint signals[LAST_SIGNAL];
 
-G_DEFINE_ABSTRACT_TYPE (GstDevice, gst_device, GST_TYPE_OBJECT);
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GstDevice, gst_device, GST_TYPE_OBJECT);
 
 static void gst_device_get_property (GObject * object, guint property_id,
     GValue * value, GParamSpec * pspec);
@@ -81,8 +82,6 @@ gst_device_class_init (GstDeviceClass * klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  g_type_class_add_private (klass, sizeof (GstDevicePrivate));
-
   object_class->get_property = gst_device_get_property;
   object_class->set_property = gst_device_set_property;
   object_class->finalize = gst_device_finalize;
@@ -111,8 +110,7 @@ gst_device_class_init (GstDeviceClass * klass)
 static void
 gst_device_init (GstDevice * device)
 {
-  device->priv = G_TYPE_INSTANCE_GET_PRIVATE (device, GST_TYPE_DEVICE,
-      GstDevicePrivate);
+  device->priv = gst_device_get_instance_private (device);
 }
 
 static void
@@ -195,10 +193,11 @@ gst_device_set_property (GObject * object, guint prop_id,
  * @name: (allow-none): name of new element, or %NULL to automatically
  * create a unique name.
  *
- * Creates the element with all of the required paramaters set to use
+ * Creates the element with all of the required parameters set to use
  * this device.
  *
- * Returns: (transfer full): a new #GstElement configured to use this device
+ * Returns: (transfer floating) (nullable): a new #GstElement configured to use
+ * this device
  *
  * Since: 1.4
  */
@@ -206,13 +205,20 @@ GstElement *
 gst_device_create_element (GstDevice * device, const gchar * name)
 {
   GstDeviceClass *klass = GST_DEVICE_GET_CLASS (device);
+  GstElement *element = NULL;
 
   g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
 
   if (klass->create_element)
-    return klass->create_element (device, name);
-  else
-    return NULL;
+    element = klass->create_element (device, name);
+
+  /* Ensure that the reference is floating. Bindings might have a hard time
+   * making sure that the reference is indeed still floating after returning
+   * here */
+  if (element)
+    g_object_force_floating ((GObject *) element);
+
+  return element;
 }
 
 /**
@@ -221,7 +227,7 @@ gst_device_create_element (GstDevice * device, const gchar * name)
  *
  * Getter for the #GstCaps that this device supports.
  *
- * Returns: The #GstCaps supported by this device. Unref with
+ * Returns: (nullable): The #GstCaps supported by this device. Unref with
  * gst_caps_unref() when done.
  *
  * Since: 1.4
@@ -285,7 +291,7 @@ gst_device_get_device_class (GstDevice * device)
  *
  * Gets the extra properties of a device.
  *
- * Returns: The extra properties or %NULL when there are none.
+ * Returns: (nullable): The extra properties or %NULL when there are none.
  *          Free with gst_structure_free() after use.
  *
  * Since: 1.6
@@ -334,8 +340,8 @@ gst_device_reconfigure_element (GstDevice * device, GstElement * element)
 /**
  * gst_device_has_classesv:
  * @device: a #GstDevice
- * @classes: (array zero-terminated=1): a %NULL terminated array of classes to match, only match if all
- *   classes are matched
+ * @classes: (array zero-terminated=1): a %NULL terminated array of classes
+ *   to match, only match if all classes are matched
  *
  * Check if @factory matches all of the given classes
  *
@@ -352,20 +358,21 @@ gst_device_has_classesv (GstDevice * device, gchar ** classes)
     return TRUE;
 
   for (; classes[0]; classes++) {
+    const gchar *klass = classes[0];
     const gchar *found;
     guint len;
 
-    if (classes[0] == '\0')
+    if (*klass == '\0')
       continue;
 
-    found = strstr (device->priv->device_class, classes[0]);
+    found = strstr (device->priv->device_class, klass);
 
     if (!found)
       return FALSE;
     if (found != device->priv->device_class && *(found - 1) != '/')
       return FALSE;
 
-    len = strlen (classes[0]);
+    len = strlen (klass);
     if (found[len] != 0 && found[len] != '/')
       return FALSE;
   }
@@ -376,7 +383,7 @@ gst_device_has_classesv (GstDevice * device, gchar ** classes)
 /**
  * gst_device_has_classes:
  * @device: a #GstDevice
- * @classes: a "/" separate list of device classes to match, only match if
+ * @classes: a "/"-separated list of device classes to match, only match if
  *  all classes are matched
  *
  * Check if @device matches all of the given classes