diff options
author | Joshua M. Doe <oss@nvl.army.mil> | 2018-10-12 09:59:54 -0400 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-11-09 09:52:40 +0000 |
commit | 8f7641bf3c1d24f9d97150ffeba2ffd8f49299d6 (patch) | |
tree | 263dc57f88d87fbfd9936d7dfcba5c8df672378c /sys/dshowsrcwrapper | |
parent | 73a84148d31876042bf58bd9dd075348b5b48f42 (diff) | |
download | gstreamer-plugins-bad-8f7641bf3c1d24f9d97150ffeba2ffd8f49299d6.tar.gz |
dshowvideosrc: handle empty strings for device and device-name
The device and device-name properties should treat NULL and empty strings the same
Diffstat (limited to 'sys/dshowsrcwrapper')
-rw-r--r-- | sys/dshowsrcwrapper/gstdshow.cpp | 5 | ||||
-rw-r--r-- | sys/dshowsrcwrapper/gstdshowvideosrc.cpp | 25 |
2 files changed, 15 insertions, 15 deletions
diff --git a/sys/dshowsrcwrapper/gstdshow.cpp b/sys/dshowsrcwrapper/gstdshow.cpp index a7d78e574..a5aded785 100644 --- a/sys/dshowsrcwrapper/gstdshow.cpp +++ b/sys/dshowsrcwrapper/gstdshow.cpp @@ -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) { diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp index aa366d0de..c8cf511cd 100644 --- a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp +++ b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp @@ -280,23 +280,21 @@ gst_dshowvideosrc_set_property (GObject * object, guint prop_id, switch (prop_id) { case PROP_DEVICE: { - if (src->device) { - g_free (src->device); - src->device = NULL; - } - if (g_value_get_string (value)) { - src->device = g_strdup (g_value_get_string (value)); + const gchar *device = g_value_get_string (value); + g_free (src->device); + src->device = NULL; + if (device && strlen (device) != 0) { + src->device = g_value_dup_string (value); } break; } case PROP_DEVICE_NAME: { - if (src->device_name) { - 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)); + const gchar *device_name = g_value_get_string (value); + g_free (src->device_name); + src->device_name = NULL; + 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); |