#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");
!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;
}
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)
if (codecFuncHandle)
dlclose(codecFuncHandle);
- return ret;
+ return FILEINFO_ERROR_FILE_INTERNAL;
}
static void _unload_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
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
#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
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
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
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
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