gstpad: Probes that return HANDLED can reset the data info field
[platform/upstream/gstreamer.git] / gst / gstdevicemonitor.c
index add267e..088eb4c 100644 (file)
@@ -121,7 +121,8 @@ enum
   PROP_SHOW_ALL = 1,
 };
 
-G_DEFINE_TYPE (GstDeviceMonitor, gst_device_monitor, GST_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE (GstDeviceMonitor, gst_device_monitor,
+    GST_TYPE_OBJECT);
 
 static void gst_device_monitor_dispose (GObject * object);
 
@@ -182,8 +183,6 @@ gst_device_monitor_class_init (GstDeviceMonitorClass * klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  g_type_class_add_private (klass, sizeof (GstDeviceMonitorPrivate));
-
   object_class->get_property = gst_device_monitor_get_property;
   object_class->set_property = gst_device_monitor_set_property;
   object_class->dispose = gst_device_monitor_dispose;
@@ -235,22 +234,25 @@ bus_sync_message (GstBus * bus, GstMessage * message,
 {
   GstMessageType type = GST_MESSAGE_TYPE (message);
 
-  if (type == GST_MESSAGE_DEVICE_ADDED || type == GST_MESSAGE_DEVICE_REMOVED) {
-    gboolean matches;
+  if (type == GST_MESSAGE_DEVICE_ADDED || type == GST_MESSAGE_DEVICE_REMOVED ||
+      type == GST_MESSAGE_DEVICE_CHANGED) {
+    gboolean matches = TRUE;
     GstDevice *device;
     GstDeviceProvider *provider;
 
     if (type == GST_MESSAGE_DEVICE_ADDED)
       gst_message_parse_device_added (message, &device);
-    else
+    else if (type == GST_MESSAGE_DEVICE_REMOVED)
       gst_message_parse_device_removed (message, &device);
+    else
+      gst_message_parse_device_changed (message, &device, NULL);
 
     GST_OBJECT_LOCK (monitor);
     provider =
         GST_DEVICE_PROVIDER (gst_object_get_parent (GST_OBJECT (device)));
     if (is_provider_hidden (monitor, monitor->priv->hidden, provider)) {
       matches = FALSE;
-    } else if (monitor->priv->filters->len) {
+    } else {
       guint i;
 
       for (i = 0; i < monitor->priv->filters->len; i++) {
@@ -265,8 +267,6 @@ bus_sync_message (GstBus * bus, GstMessage * message,
         if (matches)
           break;
       }
-    } else {
-      matches = TRUE;
     }
     GST_OBJECT_UNLOCK (monitor);
 
@@ -282,8 +282,7 @@ bus_sync_message (GstBus * bus, GstMessage * message,
 static void
 gst_device_monitor_init (GstDeviceMonitor * self)
 {
-  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
-      GST_TYPE_DEVICE_MONITOR, GstDeviceMonitorPrivate);
+  self->priv = gst_device_monitor_get_instance_private (self);
 
   self->priv->show_all = DEFAULT_SHOW_ALL;
 
@@ -344,7 +343,7 @@ gst_device_monitor_dispose (GObject * object)
  * Gets a list of devices from all of the relevant monitors. This may actually
  * probe the hardware if the monitor is not currently started.
  *
- * Returns: (transfer full) (element-type GstDevice): a #GList of
+ * Returns: (transfer full) (element-type GstDevice) (nullable): a #GList of
  *   #GstDevice
  *
  * Since: 1.4
@@ -364,13 +363,13 @@ gst_device_monitor_get_devices (GstDeviceMonitor * monitor)
   if (monitor->priv->filters->len == 0) {
     GST_OBJECT_UNLOCK (monitor);
     GST_WARNING_OBJECT (monitor, "No filters have been set");
-    return FALSE;
+    return NULL;
   }
 
   if (monitor->priv->providers->len == 0) {
     GST_OBJECT_UNLOCK (monitor);
     GST_WARNING_OBJECT (monitor, "No providers match the current filters");
-    return FALSE;
+    return NULL;
   }
 
 again: