Change return value 77/232377/2
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 4 May 2020 01:06:10 +0000 (10:06 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 4 May 2020 01:44:02 +0000 (10:44 +0900)
Change-Id: If166672ee78e765b2b1831de1c3aa9f3ab4b9cd2
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
mm_file.c

index 50d0be5..7dcc15f 100644 (file)
--- a/mm_file.c
+++ b/mm_file.c
@@ -195,26 +195,11 @@ static int (*mmfile_format_get_frame_from_memory)(const void *data, unsigned int
 #ifdef __MMFILE_DYN_LOADING__
 static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
 {
-/*     static int dll_func_initialized = 0; //disabled */
-
-       int ret = 0;
-
-       /* Get from function argument */
        void *formatFuncHandle = NULL;
        void *codecFuncHandle = NULL;
 
-       /* disabled
-       if (dll_func_initialized) {
-               return 1;
-       }
-       */
-
        formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
-       if (!formatFuncHandle) {
-               debug_error(DEBUG, "error: %s %s\n", "libmmfile_formats.so open error", dlerror());
-               ret = 0;
-               goto exception;
-       }
+       mm_file_retvm_if_fails(DEBUG, formatFuncHandle, FILEINFO_ERROR_FILE_INTERNAL);
 
        mmfile_format_open                      = dlsym(formatFuncHandle, "mmfile_format_open");
        mmfile_format_read_stream       = dlsym(formatFuncHandle, "mmfile_format_read_stream");
@@ -229,17 +214,12 @@ static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
            !mmfile_format_close) {
 
                debug_error(DEBUG, "error: %s\n", "format function load error");
-               ret = 0;
                goto exception;
        }
 
-       /*closed at app termination.*/
-       /*dlclose (formatFuncHandle); */
-
        codecFuncHandle = dlopen(MMFILE_CODEC_SO_FILE_NAME, RTLD_LAZY | RTLD_GLOBAL);
        if (!codecFuncHandle) {
                debug_error(DEBUG, "error: %s\n", "libmmfile_codecs.so open error");
-               ret = 0;
                goto exception;
        }
 
@@ -249,19 +229,13 @@ static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
 
        if (!mmfile_codec_open || !mmfile_codec_decode || !mmfile_codec_close) {
                debug_error(DEBUG, "error: %s\n", "codec function load error");
-               ret = 0;
                goto exception;
        }
 
-       /*closed at app termination.*/
-       /*dlclose (codecFuncHandle); */
-
-/*     dll_func_initialized = 1; // disabled */
-
        pHandle->codecFuncHandle = codecFuncHandle;
        pHandle->formatFuncHandle = formatFuncHandle;
 
-       return 1;
+       return FILEINFO_ERROR_NONE;
 
 exception:
        if (formatFuncHandle)
@@ -270,7 +244,7 @@ exception:
        if (codecFuncHandle)
                dlclose(codecFuncHandle);
 
-       return ret;
+       return FILEINFO_ERROR_FILE_INTERNAL;
 }
 
 static void _unload_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
@@ -744,9 +718,9 @@ int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename)
        MMFILE_FUNC_HANDLE func_handle;
 
        ret = _load_dynamic_functions(&func_handle);
-       if (ret == 0) {
+       if (ret != FILEINFO_ERROR_NONE) {
                debug_error(DEBUG, "load library error\n");
-               return FILEINFO_ERROR_FILE_INTERNAL;
+               return ret;
        }
 #endif
 
@@ -828,9 +802,9 @@ static int __create_content_attrs(MMHandleType *contents_attrs, const char *file
 #endif
 
        ret = _load_dynamic_functions(&func_handle);
-       if (ret == 0) {
+       if (ret != FILEINFO_ERROR_NONE) {
                debug_error(DEBUG, "load library error\n");
-               return FILEINFO_ERROR_FILE_INTERNAL;
+               return ret;
        }
 
 #ifdef CHECK_TIME
@@ -905,9 +879,9 @@ int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *da
        MMFILE_FUNC_HANDLE func_handle;
 
        ret = _load_dynamic_functions(&func_handle);
-       if (ret == 0) {
+       if (ret != FILEINFO_ERROR_NONE) {
                debug_error(DEBUG, "load library error\n");
-               return FILEINFO_ERROR_FILE_INTERNAL;
+               return ret;
        }
 #endif
 
@@ -959,9 +933,9 @@ int mm_file_create_content_attrs_from_memory(MMHandleType *contents_attrs, const
        MMFILE_FUNC_HANDLE func_handle;
 
        ret = _load_dynamic_functions(&func_handle);
-       if (ret == 0) {
+       if (ret != FILEINFO_ERROR_NONE) {
                debug_error(DEBUG, "load library error\n");
-               return FILEINFO_ERROR_FILE_INTERNAL;
+               return ret;
        }
 #endif
 
@@ -1038,9 +1012,9 @@ int mm_file_get_stream_info(const char *filename, int *audio_stream_num, int *vi
        MMFILE_FUNC_HANDLE func_handle;
 
        ret = _load_dynamic_functions(&func_handle);
-       if (ret == 0) {
+       if (ret != FILEINFO_ERROR_NONE) {
                debug_error(DEBUG, "load library error\n");
-               return FILEINFO_ERROR_FILE_INTERNAL;
+               return ret;
        }
 #endif
 
@@ -1188,9 +1162,9 @@ int mm_file_check_uhqa(const char *filename, bool *is_uhqa)
        MMFILE_FUNC_HANDLE func_handle;
 
        ret = _load_dynamic_functions(&func_handle);
-       if (ret == 0) {
+       if (ret != FILEINFO_ERROR_NONE) {
                debug_error(DEBUG, "load library error\n");
-               return FILEINFO_ERROR_FILE_INTERNAL;
+               return ret;
        }
 #endif