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.master
parent
841f02be87
commit
0abf0f5740
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue