mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
dshowvideosrc: handle empty strings for device and device-name
The device and device-name properties should treat NULL and empty strings the same
This commit is contained in:
parent
73a84148d3
commit
8f7641bf3c
2 changed files with 15 additions and 15 deletions
|
@ -338,11 +338,12 @@ gst_dshow_getdevice_from_devicename (const GUID * device_category,
|
|||
GST_DEBUG ("Found device idx=%d: device-name='%s'",
|
||||
devidx, friendly_name);
|
||||
|
||||
if (!*device_name && devidx == *device_index) {
|
||||
if ((!*device_name || !**device_name) && devidx == *device_index) {
|
||||
g_free (*device_name);
|
||||
*device_name = g_strdup (friendly_name);
|
||||
}
|
||||
|
||||
if (*device_name && _stricmp (*device_name, friendly_name) == 0) {
|
||||
if ((*device_name && **device_name) && _stricmp (*device_name, friendly_name) == 0) {
|
||||
WCHAR *wszDisplayName = NULL;
|
||||
hres = moniker->GetDisplayName (NULL, NULL, &wszDisplayName);
|
||||
if (hres == S_OK && wszDisplayName) {
|
||||
|
|
|
@ -280,23 +280,21 @@ gst_dshowvideosrc_set_property (GObject * object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_DEVICE:
|
||||
{
|
||||
if (src->device) {
|
||||
const gchar *device = g_value_get_string (value);
|
||||
g_free (src->device);
|
||||
src->device = NULL;
|
||||
}
|
||||
if (g_value_get_string (value)) {
|
||||
src->device = g_strdup (g_value_get_string (value));
|
||||
if (device && strlen (device) != 0) {
|
||||
src->device = g_value_dup_string (value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROP_DEVICE_NAME:
|
||||
{
|
||||
if (src->device_name) {
|
||||
const gchar *device_name = g_value_get_string (value);
|
||||
g_free (src->device_name);
|
||||
src->device_name = NULL;
|
||||
}
|
||||
if (g_value_get_string (value)) {
|
||||
src->device_name = g_strdup (g_value_get_string (value));
|
||||
if (device_name && strlen (device_name) != 0) {
|
||||
src->device_name = g_value_dup_string (value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -356,9 +354,10 @@ gst_dshowvideosrc_create_capture_filter(GstDshowVideoSrc * src)
|
|||
gunichar2 *unidevice = NULL;
|
||||
|
||||
/* device will be used first, then device-name, then device-index */
|
||||
if (!src->device) {
|
||||
if (!src->device || src->device[0] == '\0') {
|
||||
GST_DEBUG_OBJECT (src, "No device set, will enumerate to match device-name or device-index");
|
||||
|
||||
g_free (src->device);
|
||||
src->device =
|
||||
gst_dshow_getdevice_from_devicename (&CLSID_VideoInputDeviceCategory,
|
||||
&src->device_name, &src->device_index);
|
||||
|
|
Loading…
Reference in a new issue