Remove global extern variable - mmcam_log_level 61/255361/2 accepted/tizen/unified/20210319.140954 submit/tizen/20210318.073807
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 17 Mar 2021 10:21:06 +0000 (19:21 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 17 Mar 2021 11:12:49 +0000 (20:12 +0900)
[Version] 0.10.230
[Issue Type] SAM Improvement

Change-Id: If8ac0fb1fef56fed49a021d71c3afafeecb97f47
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder.h
src/include/mm_camcorder_attribute.h
src/include/mm_camcorder_util.h
src/mm_camcorder.c
src/mm_camcorder_attribute.c
src/mm_camcorder_internal.c
src/mm_camcorder_util.c

index 2e82404..e43fd53 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.229
+Version:    0.10.230
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index fb90c14..0f625a4 100644 (file)
@@ -1329,11 +1329,6 @@ extern "C" {
  */
 #define MMCAM_PLATFORM_PRIVILEGE_CAMERA         "platform-privilege-camera"
 
-/**
- * Log level
- */
-#define MMCAM_LOG_LEVEL                         "log-level"
-
 
 /*=======================================================================================
 | ENUM DEFINITIONS                                                                     |
@@ -3432,6 +3427,9 @@ int mm_camcorder_check_codec_fileformat_compatibility(const char *codec_type, in
 /* external storage state management */
 int mm_camcorder_manage_external_storage_state(MMHandleType camcorder, int storage_state);
 
+/* get log level */
+int mm_camcorder_get_log_level(void);
+
 /**
        @}
  */
index b4c1b77..953ff80 100644 (file)
@@ -191,7 +191,6 @@ typedef enum {
        MM_CAM_SUPPORT_USER_BUFFER,
        MM_CAM_USER_BUFFER_FD,
        MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
-       MM_CAM_LOG_LEVEL,
        MM_CAM_STROBE_BRIGHTNESS,
        MM_CAM_ATTRIBUTE_NUM
 } MMCamcorderAttrsID;
index 0ade9f9..fb8f09d 100644 (file)
@@ -37,7 +37,7 @@ extern "C" {
 /*=======================================================================================
 | GLOBAL DEFINITIONS AND DECLARATIONS FOR CAMCORDER                                    |
 ========================================================================================*/
-extern int mmcam_log_level;
+
 
 /*=======================================================================================
 | MACRO DEFINITIONS                                                                    |
@@ -49,37 +49,37 @@ extern int mmcam_log_level;
 /* log */
 #define MMCAM_LOG_CRITICAL(format, args...) \
        do { \
-               if (mmcam_log_level >= MM_CAMCORDER_LOG_LEVEL_CRITICAL) \
+               if (_mmcamcorder_get_log_level() >= MM_CAMCORDER_LOG_LEVEL_CRITICAL) \
                        SLOGF(format, ##args); \
        } while (0)
 
 #define MMCAM_LOG_ERROR(format, args...) \
        do { \
-               if (mmcam_log_level >= MM_CAMCORDER_LOG_LEVEL_ERROR) \
+               if (_mmcamcorder_get_log_level() >= MM_CAMCORDER_LOG_LEVEL_ERROR) \
                        SLOGE(format, ##args); \
        } while (0)
 
 #define MMCAM_LOG_WARNING(format, args...) \
        do { \
-               if (mmcam_log_level >= MM_CAMCORDER_LOG_LEVEL_WARNING) \
+               if (_mmcamcorder_get_log_level() >= MM_CAMCORDER_LOG_LEVEL_WARNING) \
                        SLOGW(format, ##args); \
        } while (0)
 
 #define MMCAM_LOG_INFO(format, args...) \
        do { \
-               if (mmcam_log_level >= MM_CAMCORDER_LOG_LEVEL_INFO) \
+               if (_mmcamcorder_get_log_level() >= MM_CAMCORDER_LOG_LEVEL_INFO) \
                        SLOGI(format, ##args); \
        } while (0)
 
 #define MMCAM_LOG_DEBUG(format, args...) \
        do { \
-               if (mmcam_log_level >= MM_CAMCORDER_LOG_LEVEL_DEBUG) \
+               if (_mmcamcorder_get_log_level() >= MM_CAMCORDER_LOG_LEVEL_DEBUG) \
                        SLOGD(format, ##args); \
        } while (0)
 
 #define MMCAM_LOG_VERBOSE(format, args...) \
        do { \
-               if (mmcam_log_level >= MM_CAMCORDER_LOG_LEVEL_VERBOSE) \
+               if (_mmcamcorder_get_log_level() >= MM_CAMCORDER_LOG_LEVEL_VERBOSE) \
                        SLOGD("[V] "format, ##args); \
        } while (0)
 
@@ -355,6 +355,10 @@ int _mmcamcorder_get_audiosrc_blocksize(int samplerate, int format, int channel,
 /* check encoded pixel format */
 gboolean _mmcamcorder_is_encoded_preview_pixel_format(int pixel_format);
 
+/* log */
+void _mmcamcorder_set_log_level(int level);
+int _mmcamcorder_get_log_level(void);
+
 
 #ifdef __cplusplus
 }
index 0108b45..f37e200 100644 (file)
@@ -469,3 +469,8 @@ int mm_camcorder_manage_external_storage_state(MMHandleType camcorder, int stora
 
        return _mmcamcorder_manage_external_storage_state(camcorder, storage_state);
 }
+
+int mm_camcorder_get_log_level(void)
+{
+       return _mmcamcorder_get_log_level();
+}
index 81b6ab2..c772f3d 100644 (file)
@@ -63,8 +63,7 @@ static int readonly_attributes[] = {
        MM_CAM_SUPPORT_ZSL_CAPTURE,
        MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
        MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
-       MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
-       MM_CAM_LOG_LEVEL
+       MM_CAM_PLATFORM_PRIVILEGE_CAMERA
 };
 
 /*-----------------------------------------------------------------------
@@ -1646,17 +1645,6 @@ _mmcamcorder_alloc_attribute(MMHandleType handle)
                        NULL,
                },
                {
-                       MM_CAM_LOG_LEVEL,
-                       "log-level",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       {(void*)MM_CAMCORDER_LOG_LEVEL_INFO},
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       {.int_min = MM_CAMCORDER_LOG_LEVEL_CRITICAL},
-                       {.int_max = MM_CAMCORDER_LOG_LEVEL_VERBOSE},
-                       NULL,
-               },
-               {
                        MM_CAM_STROBE_BRIGHTNESS,
                        "strobe-brightness",
                        MM_ATTRS_TYPE_INT,
index 7d6a812..cd5d2b9 100644 (file)
@@ -45,9 +45,6 @@
 #include "mm_camcorder_rm.h"
 #endif /* _MMCAMCORDER_RM_SUPPORT */
 
-/* log level */
-int mmcam_log_level = MM_CAMCORDER_LOG_LEVEL_INFO;
-
 /*---------------------------------------------------------------------------------------
 |    LOCAL VARIABLE DEFINITIONS for internal                                           |
 ---------------------------------------------------------------------------------------*/
@@ -100,6 +97,7 @@ static int      __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
 static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_type)
 {
        int ret = MM_ERROR_NONE;
+       int log_level = MM_CAMCORDER_LOG_LEVEL_INFO;
        mmf_camcorder_t *new_handle = NULL;
 
        if (!hcamcorder) {
@@ -186,7 +184,9 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
        _mmcamcorder_conf_get_value_int((MMHandleType)new_handle, new_handle->conf_main,
                CONFIGURE_CATEGORY_MAIN_GENERAL,
                "LogLevel",
-               &mmcam_log_level);
+               &log_level);
+
+       _mmcamcorder_set_log_level(log_level);
 
        /* allocate attribute */
        new_handle->attributes = _mmcamcorder_alloc_attribute((MMHandleType)new_handle);
@@ -195,13 +195,6 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
                goto _INIT_HANDLE_FAILED;
        }
 
-       /* Set log level to attribute */
-       ret = mm_camcorder_set_attributes((MMHandleType)new_handle, NULL,
-               MMCAM_LOG_LEVEL, mmcam_log_level,
-               NULL);
-
-       MMCAM_LOG_INFO("set log level[%d], ret[0x%x]", mmcam_log_level, ret);
-
        *hcamcorder = new_handle;
 
        MMCAM_LOG_INFO("new handle %p", new_handle);
index a3d6738..e884259 100644 (file)
@@ -42,6 +42,7 @@
 /*-----------------------------------------------------------------------
 |    GLOBAL VARIABLE DEFINITIONS for internal                          |
 -----------------------------------------------------------------------*/
+static int mmcam_log_level = MM_CAMCORDER_LOG_LEVEL_INFO;
 
 /*-----------------------------------------------------------------------
 |    LOCAL VARIABLE DEFINITIONS for internal                           |
@@ -2395,3 +2396,14 @@ gboolean _mmcamcorder_is_encoded_preview_pixel_format(int pixel_format)
        return (pixel_format == MM_PIXEL_FORMAT_ENCODED_H264 ||
                pixel_format == MM_PIXEL_FORMAT_ENCODED_MJPEG);
 }
+
+void _mmcamcorder_set_log_level(int level)
+{
+       MMCAM_LOG_WARNING("set log level[%d]", level);
+       mmcam_log_level = level;
+}
+
+int _mmcamcorder_get_log_level(void)
+{
+       return mmcam_log_level;
+}