linux-v4l2: Disable properties when device is not there.

This adds helper function to disable/enable all properties which is
used in the device selected callback to enable/disable the properties
when the selected device is available/unavailable.
master
fryshorts 2014-10-25 17:55:02 +02:00 committed by jp9000
parent 3a85d662be
commit ac40408dfa
1 changed files with 27 additions and 1 deletions

View File

@ -219,6 +219,30 @@ static void v4l2_defaults(obs_data_t *settings)
obs_data_set_default_bool(settings, "system_timing", false);
}
/**
* Enable/Disable all properties for the source.
*
* @note A property that should be ignored can be specified
*
* @param props the source properties
* @param ignore ignore this property
* @param enable enable/disable all properties
*/
static void v4l2_props_set_enabled(obs_properties_t *props,
obs_property_t *ignore, bool enable)
{
if (!props)
return;
for (obs_property_t *prop = obs_properties_first(props); prop != NULL;
obs_property_next(&prop)) {
if (prop == ignore)
continue;
obs_property_set_enabled(prop, enable);
}
}
/*
* List available devices
*/
@ -461,9 +485,11 @@ static void v4l2_framerate_list(int dev, uint_fast32_t pixelformat,
static bool device_selected(obs_properties_t *props, obs_property_t *p,
obs_data_t *settings)
{
UNUSED_PARAMETER(p);
int dev = v4l2_open(obs_data_get_string(settings, "device_id"),
O_RDWR | O_NONBLOCK);
v4l2_props_set_enabled(props, p, (dev == -1) ? false : true);
if (dev == -1)
return false;