devicemonitor: keep order of providers and devices
authorWim Taymans <wtaymans@redhat.com>
Thu, 16 Jul 2015 15:25:24 +0000 (17:25 +0200)
committerWim Taymans <wtaymans@redhat.com>
Thu, 16 Jul 2015 16:54:50 +0000 (18:54 +0200)
The deviceproviders are added to the array sorted by their rank. Make
sure we keep this ordering when removing a provider.

We use _prepend to collect the devices, use g_list_reverse to get the
devices in the right order; sorted by rank and in the same order as
returned by the provider.

gst/gstdevicemonitor.c

index b055934..994263a 100644 (file)
@@ -209,7 +209,7 @@ gst_device_monitor_remove (GstDeviceMonitor * self, guint i)
   GstDeviceProvider *provider = g_ptr_array_index (self->priv->providers, i);
   GstBus *bus;
 
-  g_ptr_array_remove_index_fast (self->priv->providers, i);
+  g_ptr_array_remove_index (self->priv->providers, i);
 
   bus = gst_device_provider_get_bus (provider);
   g_signal_handlers_disconnect_by_func (bus, bus_sync_message, self);
@@ -324,7 +324,7 @@ again:
 
   GST_OBJECT_UNLOCK (monitor);
 
-  return devices;
+  return g_list_reverse (devices);
 }
 
 /**