[Release version 0.10.37] Return NOT_SUPPORTED error when configure file is not existed 29/59429/1
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 15 Feb 2016 11:04:26 +0000 (20:04 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 15 Feb 2016 11:04:26 +0000 (20:04 +0900)
Change-Id: I25c5a1344449983bacd9777a307193113c39655f
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder_internal.h
src/mm_camcorder_configure.c
src/mm_camcorder_internal.c
src/mm_camcorder_util.c

index 447857e..c7a682d 100644 (file)
@@ -2,7 +2,7 @@
 
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.36
+Version:    0.10.37
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 6966d1b..bd92bee 100644 (file)
@@ -38,6 +38,7 @@
 #include <vconf.h>
 #include <gst/video/video-format.h>
 #include <ttrace.h>
+#include <errno.h>
 
 #include "mm_camcorder.h"
 #include "mm_debug.h"
index 6445d54..80eae5d 100644 (file)
@@ -893,61 +893,58 @@ void _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf** configu
 }
 
 
-int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char* ConfFile, camera_conf** configure_info)
+int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFile, camera_conf **configure_info)
 {
-       int ret         = MM_ERROR_NONE;
-       FILE* fd        = NULL;
-       charconf_path = NULL;
+       int ret = MM_ERROR_NONE;
+       FILE *fd = NULL;
+       char *conf_path = NULL;
 
-       _mmcam_dbg_log( "Opening...[%s]", ConfFile );
+       _mmcam_dbg_log("Opening...[%s]", ConfFile);
 
-       mmf_return_val_if_fail( ConfFile, FALSE );
+       mmf_return_val_if_fail(ConfFile, FALSE);
 
-       conf_path = (char*)malloc( strlen(ConfFile)+strlen(CONFIGURE_PATH)+3 );
-
-       if( conf_path == NULL )
-       {
-               _mmcam_dbg_err( "malloc failed." );
+       conf_path = (char *)malloc(strlen(ConfFile) + strlen(CONFIGURE_PATH) + 3);
+       if (conf_path == NULL) {
+               _mmcam_dbg_err("malloc failed.");
                return MM_ERROR_CAMCORDER_LOW_MEMORY;
        }
 
-       snprintf( conf_path, strlen(ConfFile)+strlen(CONFIGURE_PATH)+2, "%s/%s", CONFIGURE_PATH, ConfFile );
-       _mmcam_dbg_log( "Try open Configure File[%s]", conf_path );
+       snprintf(conf_path, strlen(ConfFile) + strlen(CONFIGURE_PATH) + 2, "%s/%s", CONFIGURE_PATH, ConfFile);
+       _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
 
-       fd = fopen( conf_path, "r" );
-       if( fd == NULL )
-       {
-               _mmcam_dbg_warn( "File open failed.[%s] retry...", conf_path );
-               snprintf( conf_path, strlen(ConfFile)+strlen(CONFIGURE_PATH_RETRY)+2, "%s/%s", CONFIGURE_PATH_RETRY, ConfFile );
-               _mmcam_dbg_log( "Try open Configure File[%s]", conf_path );
-               fd = fopen( conf_path, "r" );
-               if( fd == NULL )
-               {
-                       _mmcam_dbg_warn("open failed.[%s] But keep going... Type[%d]", conf_path, type);
+       fd = fopen(conf_path, "r");
+       if (fd == NULL) {
+               _mmcam_dbg_warn("File open failed.[%s] retry...", conf_path);
+               snprintf(conf_path, strlen(ConfFile) + strlen(CONFIGURE_PATH_RETRY) + 2, "%s/%s", CONFIGURE_PATH_RETRY, ConfFile);
+               _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
+               fd = fopen(conf_path, "r");
+               if (fd == NULL) {
+                       _mmcam_dbg_warn("open failed.[%s] errno [%d]", conf_path, errno);
                }
        }
 
-       if( fd != NULL )
-       {
-               ret = _mmcamcorder_conf_parse_info( handle, type, fd, configure_info );
-               fclose( fd );
-       }
-       else
-       {
-               ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
+       if (fd != NULL) {
+               ret = _mmcamcorder_conf_parse_info(handle, type, fd, configure_info);
+               fclose(fd);
+       } else {
+               if (errno == ENOENT) {
+                       ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+               } else {
+                       ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
+               }
        }
 
-       if( conf_path != NULL )
-       {
-               free( conf_path );
+       if (conf_path != NULL) {
+               free(conf_path);
                conf_path = NULL;
        }
 
-       _mmcam_dbg_log( "Leave..." );
+       _mmcam_dbg_log("Leave...");
 
        return ret;
 }
 
+
 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE* fd, camera_conf** configure_info)
 {
        const unsigned int BUFFER_NUM_DETAILS = 256;
index 519f09c..deaa15f 100644 (file)
@@ -261,12 +261,9 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
        }
 
        /* Get Camera Configure information from Camcorder INI file */
-       _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main);
-
-       if (!(hcamcorder->conf_main)) {
-               _mmcam_dbg_err( "Failed to get configure(main) info." );
-
-               ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
+       ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main);
+       if (ret != MM_ERROR_NONE) {
+               _mmcam_dbg_err("Failed to get configure(main) info.");
                goto _ERR_DEFAULT_VALUE_INIT;
        }
 
@@ -309,17 +306,15 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
 
                        _mmcam_dbg_log("videodev_type : [%d], ConfCtrlPath : [%s]", info->videodev_type, ConfCtrlFile);
 
-                       _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_CTRL, ConfCtrlFile, &hcamcorder->conf_ctrl);
+                       ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_CTRL, ConfCtrlFile, &hcamcorder->conf_ctrl);
+                       if (ret != MM_ERROR_NONE) {
+                               _mmcam_dbg_err("Failed to get configure(control) info.");
+                               goto _ERR_DEFAULT_VALUE_INIT;
+                       }
 /*
                        _mmcamcorder_conf_print_info(&hcamcorder->conf_main);
                        _mmcamcorder_conf_print_info(&hcamcorder->conf_ctrl);
 */
-                       if (!(hcamcorder->conf_ctrl)) {
-                               _mmcam_dbg_err( "Failed to get configure(control) info." );
-                               ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
-                               goto _ERR_DEFAULT_VALUE_INIT;
-                       }
-
                        ret = _mmcamcorder_init_convert_table((MMHandleType)hcamcorder);
                        if (ret != MM_ERROR_NONE) {
                                _mmcam_dbg_warn("converting table initialize error!!");
index c2540d8..79b3b3b 100644 (file)
@@ -30,7 +30,6 @@
 #include <sys/stat.h>
 #include <gst/video/video-info.h>
 #include <gio/gio.h>
-#include <errno.h>
 
 #include "mm_camcorder_internal.h"
 #include "mm_camcorder_util.h"