Skip to content

Commit

Permalink
gentlinterface: return the first available device if id == NULL
Browse files Browse the repository at this point in the history
Fix #953
  • Loading branch information
EmmanuelP committed Oct 28, 2024
1 parent ff96d8c commit 3a7bc36
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/arvgentlinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,34 @@ arv_gentl_interface_open_device (ArvInterface *interface, const char *device_id,
{
ArvGenTLInterfacePrivate *priv = arv_gentl_interface_get_instance_private(ARV_GENTL_INTERFACE (interface));
ArvDevice *device = NULL;
ArvGenTLInterfaceDeviceInfos *device_info = g_hash_table_lookup(priv->devices, device_id);
ArvGenTLInterfaceDeviceInfos *device_infos = NULL;

if (device_id == NULL) {
GList *device_list;

device_list = g_hash_table_get_values (priv->devices);
device_infos = device_list != NULL ? device_list->data : NULL;
g_list_free (device_list);
} else
device_infos = g_hash_table_lookup (priv->devices, device_id);

/* Refresh devices if the requested device is in the cache. */
if (device_info == NULL) {
if (device_infos == NULL) {
GList *device_list;

_discover(ARV_GENTL_INTERFACE(interface), NULL);
device_info = g_hash_table_lookup(priv->devices, device_id);
}

if (device_info) {
device = arv_gentl_device_new(device_info->system, device_info->interface, device_id, error);
}
if (device_id == NULL) {
device_list = g_hash_table_get_values (priv->devices);
device_infos = device_list != NULL ? device_list->data : NULL;
g_list_free (device_list);
} else
device_infos = g_hash_table_lookup (priv->devices, device_id);
}

if (device_infos)
device = arv_gentl_device_new (device_infos->system, device_infos->interface,
device_infos->id, error);

return device;
}
Expand Down

0 comments on commit 3a7bc36

Please sign in to comment.