idsueyesrc: properly close camera handle if there's an error during opening and configuring

This commit is contained in:
Joshua M. Doe 2022-02-25 10:07:03 -05:00
parent 619ce5f132
commit 4836d595ce

View File

@ -504,7 +504,7 @@ gst_idsueyesrc_start (GstBaseSrc * bsrc)
if (!g_file_test (src->config_file, G_FILE_TEST_EXISTS)) { if (!g_file_test (src->config_file, G_FILE_TEST_EXISTS)) {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
("Camera file does not exist: %s", src->config_file), (NULL)); ("Camera file does not exist: %s", src->config_file), (NULL));
return FALSE; goto error;
} }
/* function requires Unicode */ /* function requires Unicode */
@ -533,7 +533,7 @@ gst_idsueyesrc_start (GstBaseSrc * bsrc)
} }
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
("Failed to load parameter file: %s", src->config_file), (NULL)); ("Failed to load parameter file: %s", src->config_file), (NULL));
return FALSE; goto error;
} }
} else { } else {
ret = ret =
@ -542,37 +542,42 @@ gst_idsueyesrc_start (GstBaseSrc * bsrc)
if (ret != IS_SUCCESS) { if (ret != IS_SUCCESS) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
("Failed to load parameters from EEPROM"), (NULL)); ("Failed to load parameters from EEPROM"), (NULL));
return FALSE; goto error;
} }
} }
gst_idsueyesrc_set_caps_from_camera (src); gst_idsueyesrc_set_caps_from_camera (src);
if (!src->caps) { if (!src->caps) {
return FALSE; goto error;
} }
if (!gst_idsueyesrc_alloc_memory (src)) { if (!gst_idsueyesrc_alloc_memory (src)) {
/* element error already sent */ /* element error already sent */
return FALSE; goto error;
} }
ret = is_SetDisplayMode (src->hCam, IS_SET_DM_DIB); ret = is_SetDisplayMode (src->hCam, IS_SET_DM_DIB);
if (ret != IS_SUCCESS) { if (ret != IS_SUCCESS) {
GST_ELEMENT_ERROR (src, STREAM, WRONG_TYPE, GST_ELEMENT_ERROR (src, STREAM, WRONG_TYPE,
("Failed to set display mode"), (NULL)); ("Failed to set display mode"), (NULL));
return FALSE; goto error;
} }
ret = is_InitImageQueue (src->hCam, 0); ret = is_InitImageQueue (src->hCam, 0);
if (ret != IS_SUCCESS) { if (ret != IS_SUCCESS) {
GST_ELEMENT_ERROR (src, STREAM, WRONG_TYPE, GST_ELEMENT_ERROR (src, STREAM, WRONG_TYPE,
("Failed to init image queue"), (NULL)); ("Failed to init image queue"), (NULL));
return FALSE; goto error;
} }
gst_idsueyesrc_set_framerate_exposure (src); gst_idsueyesrc_set_framerate_exposure (src);
return TRUE; return TRUE;
error:
ret = is_ExitCamera (src->hCam);
return FALSE;
} }
static gboolean static gboolean