From 0abf0f5740f85b8fa1bb217f9cdc00b9486a6ceb Mon Sep 17 00:00:00 2001 From: fryshorts <leonhard@in-verted.de> Date: Mon, 15 Sep 2014 21:06:55 +0200 Subject: [PATCH] Do not explicitly set a default device in v4l2 input. This was added at a time where the source properties dialog did not pop up automatically on source creation. Now when the properties are displayed the first device in the select input will be selected by default if there was none already specified by the source settings. This will make the code cleaner and also save one redundant round of device enumeration. --- plugins/linux-v4l2/v4l2-input.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index 493b361e6..485705542 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -231,10 +231,11 @@ static void v4l2_defaults(obs_data_t settings) */ static void v4l2_device_list(obs_property_t prop, obs_data_t settings) { + UNUSED_PARAMETER(settings); + DIR *dirp; struct dirent *dp; struct dstr device; - bool first = true; dirp = opendir("/sys/class/video4linux"); if (!dirp) @@ -280,13 +281,6 @@ static void v4l2_device_list(obs_property_t prop, obs_data_t settings) obs_property_list_add_string(prop, (char *) video_cap.card, device.array); - - if (first) { - obs_data_set_string(settings, "device_id", - device.array); - first = false; - } - blog(LOG_INFO, "Found device '%s' at %s", video_cap.card, device.array); @@ -679,11 +673,6 @@ static void v4l2_update(void *vptr, obs_data_t settings) const char *new_device; new_device = obs_data_get_string(settings, "device_id"); - if (strlen(new_device) == 0) { - v4l2_device_list(NULL, settings); - new_device = obs_data_get_string(settings, "device_id"); - } - if (!data->set_device || strcmp(data->set_device, new_device) != 0) { if (data->set_device) bfree(data->set_device); -- GitLab