diff options
-rw-r--r-- | camerasrc/src/camerasrc.c | 116 | ||||
-rw-r--r-- | packaging/gst-plugins-camera-n4.spec | 2 |
2 files changed, 87 insertions, 31 deletions
diff --git a/camerasrc/src/camerasrc.c b/camerasrc/src/camerasrc.c index 0e68747..37e8df7 100644 --- a/camerasrc/src/camerasrc.c +++ b/camerasrc/src/camerasrc.c @@ -4140,6 +4140,7 @@ int camerasrc_tbm_alloc_buffer(camsrc_handle_t handle, int size, tbm_bo *bo, int /* For Query functionalities */ int camerasrc_read_basic_dev_info(camerasrc_dev_id_t dev_id, camerasrc_caps_info_t* caps_info) { + int ret = CAMERASRC_SUCCESS; int nread = 0; char* store_path = NULL; FILE *fp = NULL; @@ -4159,17 +4160,25 @@ int camerasrc_read_basic_dev_info(camerasrc_dev_id_t dev_id, camerasrc_caps_info fp = fopen(store_path, "rb"); if(fp) { - fseek(fp, 0, SEEK_SET); - nread = fread(caps_info, 1, sizeof(camerasrc_caps_info_t), fp); - camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_caps_info_t), nread); + if (fseek(fp, 0, SEEK_SET) < 0) + { + camsrc_error("fseek 0 failed[%d]", errno); + ret = CAMERASRC_ERR_INTERNAL; + } + else + { + nread = fread(caps_info, 1, sizeof(camerasrc_caps_info_t), fp); + camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_caps_info_t), nread); + ret = CAMERASRC_SUCCESS; + } fclose(fp); } else - return CAMERASRC_ERR_ALLOCATION; + ret = CAMERASRC_ERR_ALLOCATION; camsrc_info("leave"); - return CAMERASRC_SUCCESS; + return ret; } @@ -4177,6 +4186,7 @@ int camerasrc_read_misc_dev_info(camerasrc_dev_id_t dev_id, camerasrc_ctrl_list_ { camsrc_info("enter"); + int ret = CAMERASRC_SUCCESS; int nread = 0; FILE *fp = NULL; char* store_path = NULL; @@ -4194,22 +4204,33 @@ int camerasrc_read_misc_dev_info(camerasrc_dev_id_t dev_id, camerasrc_ctrl_list_ fp = fopen(store_path, "rb"); if(fp) { - fseek(fp, 0, SEEK_SET); - nread = fread(ctrl_info, 1, sizeof(camerasrc_ctrl_list_info_t), fp); - camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_ctrl_list_info_t), nread); + if (fseek(fp, 0, SEEK_SET) < 0) + { + camsrc_error("fseek 0 failed[%d]", errno); + ret = CAMERASRC_ERR_INTERNAL; + } + else + { + nread = fread(ctrl_info, 1, sizeof(camerasrc_ctrl_list_info_t), fp); + camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_ctrl_list_info_t), nread); + ret = CAMERASRC_SUCCESS; + } fclose(fp); } else - return CAMERASRC_ERR_ALLOCATION; + { + ret = CAMERASRC_ERR_ALLOCATION; + } camsrc_info("leave"); - return CAMERASRC_SUCCESS; + return ret; } int camerasrc_read_extra_dev_info(camerasrc_dev_id_t dev_id, camerasrc_extra_info_t* extra_info) { + int ret = CAMERASRC_SUCCESS; int nread = 0; FILE *fp = NULL; char* store_path = NULL; @@ -4229,22 +4250,31 @@ int camerasrc_read_extra_dev_info(camerasrc_dev_id_t dev_id, camerasrc_extra_inf fp = fopen(store_path, "rb"); if(fp) { - fseek(fp, 0, SEEK_SET); - nread = fread(extra_info, 1, sizeof(camerasrc_extra_info_t), fp); - camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_extra_info_t), nread); + if (fseek(fp, 0, SEEK_SET) < 0) + { + camsrc_error("fseek 0 failed[%d]", errno); + ret = CAMERASRC_ERR_INTERNAL; + } + else + { + nread = fread(extra_info, 1, sizeof(camerasrc_extra_info_t), fp); + camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_extra_info_t), nread); + ret = CAMERASRC_SUCCESS; + } fclose(fp); } else - return CAMERASRC_ERR_ALLOCATION; + ret = CAMERASRC_ERR_ALLOCATION; camsrc_info("leave"); - return CAMERASRC_SUCCESS; + return ret; } int camerasrc_write_basic_dev_info(camsrc_handle_t handle, camerasrc_caps_info_t* caps_info) { + int ret = CAMERASRC_SUCCESS; camerasrc_handle_t* p = NULL; char* store_path = NULL; FILE *fp = NULL; @@ -4280,21 +4310,30 @@ int camerasrc_write_basic_dev_info(camsrc_handle_t handle, camerasrc_caps_info_t fp = fopen(store_path, "wb"); if(fp) { - fseek(fp, 0, SEEK_SET); - nwrite = fwrite(caps_info, 1, sizeof(camerasrc_caps_info_t), fp); - camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_caps_info_t), nwrite); + if (fseek(fp, 0, SEEK_SET) < 0) + { + camsrc_error("fseek 0 failed[%d]", errno); + ret = CAMERASRC_ERR_INTERNAL; + } + else + { + nwrite = fwrite(caps_info, 1, sizeof(camerasrc_caps_info_t), fp); + camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_caps_info_t), nwrite); + ret = CAMERASRC_SUCCESS; + } fclose(fp); } else - return CAMERASRC_ERR_ALLOCATION; + ret = CAMERASRC_ERR_ALLOCATION; camsrc_info("leave"); - return CAMERASRC_SUCCESS; + return ret; } int camerasrc_write_misc_dev_info(camsrc_handle_t handle, camerasrc_ctrl_list_info_t* ctrl_info) { + int ret = CAMERASRC_SUCCESS; camerasrc_handle_t* p = NULL; camsrc_info("enter"); @@ -4330,21 +4369,30 @@ int camerasrc_write_misc_dev_info(camsrc_handle_t handle, camerasrc_ctrl_list_in fp = fopen(store_path, "wb"); if(fp) { - fseek(fp, 0, SEEK_SET); - nwrite = fwrite(ctrl_info, 1, sizeof(camerasrc_ctrl_list_info_t), fp); - camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_ctrl_list_info_t), nwrite); + if (fseek(fp, 0, SEEK_SET) < 0) + { + camsrc_error("fseek 0 failed[%d]", errno); + ret = CAMERASRC_ERR_INTERNAL; + } + else + { + nwrite = fwrite(ctrl_info, 1, sizeof(camerasrc_ctrl_list_info_t), fp); + camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_ctrl_list_info_t), nwrite); + ret = CAMERASRC_SUCCESS; + } fclose(fp); } else - return CAMERASRC_ERR_ALLOCATION; + ret = CAMERASRC_ERR_ALLOCATION; camsrc_info("leave"); - return CAMERASRC_SUCCESS; + return ret; } int camerasrc_write_extra_dev_info(camsrc_handle_t handle, camerasrc_extra_info_t* extra_info) { + int ret = CAMERASRC_SUCCESS; camerasrc_handle_t* p = NULL; camsrc_info("enter"); @@ -4380,16 +4428,24 @@ int camerasrc_write_extra_dev_info(camsrc_handle_t handle, camerasrc_extra_info_ fp = fopen(store_path, "wb"); if(fp) { - fseek(fp, 0, SEEK_SET); - nwrite = fwrite(extra_info, 1, sizeof(camerasrc_extra_info_t), fp); - camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_extra_info_t), nwrite); + if (fseek(fp, 0, SEEK_SET) < 0) + { + camsrc_error("fseek 0 failed[%d]", errno); + ret = CAMERASRC_ERR_INTERNAL; + } + else + { + nwrite = fwrite(extra_info, 1, sizeof(camerasrc_extra_info_t), fp); + camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_extra_info_t), nwrite); + ret = CAMERASRC_SUCCESS; + } fclose(fp); } else - return CAMERASRC_ERR_ALLOCATION; + ret = CAMERASRC_ERR_ALLOCATION; camsrc_info("leave"); - return CAMERASRC_SUCCESS; + return ret; } diff --git a/packaging/gst-plugins-camera-n4.spec b/packaging/gst-plugins-camera-n4.spec index baf7174..b0ab22a 100644 --- a/packaging/gst-plugins-camera-n4.spec +++ b/packaging/gst-plugins-camera-n4.spec @@ -1,6 +1,6 @@ Name: gst-plugins-camera-n4 Summary: GStreamer codec plugins package for N4 -Version: 0.0.7 +Version: 0.0.8 Release: 0 Group: Multimedia/Framework License: LGPL-2.1 |