matroxsrc: properly close resources if initialization fails

This commit is contained in:
Joshua M. Doe 2020-08-13 14:50:51 -04:00
parent a17e6656ad
commit f2d021c519

View File

@ -497,7 +497,7 @@ gst_matroxsrc_start (GstBaseSrc * bsrc)
if (ret == M_NULL) { if (ret == M_NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, FAILED, GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
("Failed to allocate a MIL system"), (NULL)); ("Failed to allocate a MIL system"), (NULL));
return FALSE; goto error;
} }
/* create Digitizer */ /* create Digitizer */
@ -511,7 +511,7 @@ gst_matroxsrc_start (GstBaseSrc * bsrc)
if (ret == M_NULL) { if (ret == M_NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, FAILED, GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
("Failed to allocate a MIL digitizer"), (NULL)); ("Failed to allocate a MIL digitizer"), (NULL));
return FALSE; goto error;
} }
/* get format info and create caps */ /* get format info and create caps */
@ -597,7 +597,7 @@ gst_matroxsrc_start (GstBaseSrc * bsrc)
} else { } else {
GST_ELEMENT_ERROR (src, STREAM, WRONG_TYPE, GST_ELEMENT_ERROR (src, STREAM, WRONG_TYPE,
("Unknown or unsupported bit depth (%d).", bpp), (NULL)); ("Unknown or unsupported bit depth (%d).", bpp), (NULL));
return FALSE; goto error;
} }
} else if (n_bands == 3) { } else if (n_bands == 3) {
/* TODO: handle non-Solios color formats */ /* TODO: handle non-Solios color formats */
@ -634,11 +634,16 @@ gst_matroxsrc_start (GstBaseSrc * bsrc)
} else { } else {
GST_ELEMENT_ERROR (src, RESOURCE, FAILED, GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
("Failed to allocate a MIL buffer"), (NULL)); ("Failed to allocate a MIL buffer"), (NULL));
return FALSE; goto error;
} }
} }
return TRUE; return TRUE;
error:
gst_matroxsrc_reset (src);
return FALSE;
} }
static gboolean static gboolean