diff --git a/sys/mediafoundation/gstmfcaptureengine.cpp b/sys/mediafoundation/gstmfcaptureengine.cpp index 66107d4181..f72de4f223 100644 --- a/sys/mediafoundation/gstmfcaptureengine.cpp +++ b/sys/mediafoundation/gstmfcaptureengine.cpp @@ -827,22 +827,15 @@ gst_mf_capture_engine_new (GstMFSourceType type, gint device_index, const gchar * device_name, const gchar * device_path) { GstMFSourceObject *self; - gchar *name; - gchar *path; /* TODO: add more type */ g_return_val_if_fail (type == GST_MF_SOURCE_TYPE_VIDEO, NULL); - name = device_name ? g_strdup (device_name) : g_strdup (""); - path = device_path ? g_strdup (device_path) : g_strdup (""); - self = (GstMFSourceObject *) g_object_new (GST_TYPE_MF_CAPTURE_ENGINE, - "source-type", type, "device-index", device_index, "device-name", name, - "device-path", path, NULL); + "source-type", type, "device-index", device_index, "device-name", + device_name, "device-path", device_path, NULL); gst_object_ref_sink (self); - g_free (name); - g_free (path); if (!self->opened) { GST_WARNING_OBJECT (self, "Couldn't open device"); diff --git a/sys/mediafoundation/gstmfsourceobject.c b/sys/mediafoundation/gstmfsourceobject.c index 0bfbad1c5e..32457a40c6 100644 --- a/sys/mediafoundation/gstmfsourceobject.c +++ b/sys/mediafoundation/gstmfsourceobject.c @@ -384,13 +384,18 @@ gst_mf_source_object_thread_func (GstMFSourceObject * self) } #endif + GST_DEBUG_OBJECT (self, + "Requested device index: %d, name: \"%s\", path \"%s\"", + self->device_index, GST_STR_NULL (self->device_name), + GST_STR_NULL (self->device_path)); + for (iter = activate_list; iter; iter = g_list_next (iter)) { GstMFDeviceActivate *activate = (GstMFDeviceActivate *) iter->data; gboolean match; - if (self->device_path && strlen (self->device_path) > 0) { + if (self->device_path) { match = g_ascii_strcasecmp (activate->path, self->device_path) == 0; - } else if (self->device_name && strlen (self->device_name) > 0) { + } else if (self->device_name) { match = g_ascii_strcasecmp (activate->name, self->device_name) == 0; } else if (self->device_index >= 0) { match = activate->index == self->device_index; diff --git a/sys/mediafoundation/gstmfsourcereader.cpp b/sys/mediafoundation/gstmfsourcereader.cpp index 0f85030446..ff0ee98501 100644 --- a/sys/mediafoundation/gstmfsourcereader.cpp +++ b/sys/mediafoundation/gstmfsourcereader.cpp @@ -492,22 +492,15 @@ gst_mf_source_reader_new (GstMFSourceType type, gint device_index, const gchar * device_name, const gchar * device_path) { GstMFSourceObject *self; - gchar *name; - gchar *path; /* TODO: add more type */ g_return_val_if_fail (type == GST_MF_SOURCE_TYPE_VIDEO, NULL); - name = device_name ? g_strdup (device_name) : g_strdup (""); - path = device_path ? g_strdup (device_path) : g_strdup (""); - self = (GstMFSourceObject *) g_object_new (GST_TYPE_MF_SOURCE_READER, - "source-type", type, "device-index", device_index, "device-name", name, - "device-path", path, NULL); + "source-type", type, "device-index", device_index, "device-name", + device_name, "device-path", device_path, NULL); gst_object_ref_sink (self); - g_free (name); - g_free (path); if (!self->opened) { GST_WARNING_OBJECT (self, "Couldn't open device");