}
static void rawmidi_perform_ctl_ioctl(guint card_id, long request, void *data,
- const char *req_label, GError **error)
+ const char *req_label, int *ctl_fd, GError **error)
{
unsigned int length;
char *sysname;
if (ioctl(fd, request, data) < 0)
generate_file_error_fmt(error, errno, "ioctl(%s)", req_label);
- close(fd);
+ // The caller is responsible for closing the file descriptor.
+ if (ctl_fd != NULL)
+ *ctl_fd = fd;
+ else
+ close(fd);
err_device:
udev_device_unref(dev);
err_ctx:
g_return_if_fail(entry_count != NULL);
g_return_if_fail(error == NULL || *error == NULL);
- rawmidi_perform_ctl_ioctl(card, SNDRV_CTL_IOCTL_RAWMIDI_INFO, &info, "RAWMIDI_INFO", error);
+ rawmidi_perform_ctl_ioctl(card, SNDRV_CTL_IOCTL_RAWMIDI_INFO, &info, "RAWMIDI_INFO", NULL, error);
if (*error != NULL)
return;
info->stream = direction;
info->card = card_id;
- rawmidi_perform_ctl_ioctl(card_id, SNDRV_CTL_IOCTL_RAWMIDI_INFO, info, "RAWMIDI_INFO", error);
+ rawmidi_perform_ctl_ioctl(card_id, SNDRV_CTL_IOCTL_RAWMIDI_INFO, info, "RAWMIDI_INFO", NULL, error);
if (*error != NULL)
g_object_unref(*substream_info);
}
{
guint data = subdevice_id;
rawmidi_perform_ctl_ioctl(card_id, SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE,
- &data, "RAWMIDI_PREFER_SUBDEVICE", error);
+ &data, "RAWMIDI_PREFER_SUBDEVICE", NULL, error);
}