modality_vision : correct about missing return value, and remove not useful wrapping... 98/265198/1
authordyamy-lee <dyamy.lee@samsung.com>
Tue, 12 Oct 2021 13:25:30 +0000 (22:25 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 12 Oct 2021 14:36:20 +0000 (23:36 +0900)
Change-Id: Ibda400b2c612b7232f60a979d25051b218f85329

src/modules/modality_vision/vision.c

index ff7d43c0719b27b225e95c33b990a9133e0d335a..367c3addf151aca1fe8cdb982d7c508f26d9f3aa 100644 (file)
@@ -84,10 +84,6 @@ mv_engine_config_h _engine_cfg = NULL;
 mv_inference_h _infer = NULL;
 static Ecore_Event_Handler *_event_handlers;
 
-typedef struct _video_info{
-       mv_video_reader_h reader;
-} video_info;
-
 void _send_vision_event_cb(void *data)
 {
        mmi_provider_event_vision *ev = (mmi_provider_event_vision *)data;
@@ -230,18 +226,15 @@ void _vision_finish_cb(void *user_data)
                LOGE("ERROR: eos callback can't stop tracking process.");
                return;
        }
+       mv_video_reader_h reader = (mv_video_reader_h) user_data;
 
-       video_info *video_infos = (video_info *)user_data;
-       if(!video_infos)
+       if(reader)
        {
-               LOGE("video_info malloc fail\n");
-               return;
-       }
-
-       if(video_infos->reader)
-       {
-               mv_destroy_video_reader(video_infos->reader);
-               LOGD("destroy reader well");
+               LOGD("destroy reader");
+               int err = mv_destroy_video_reader(reader);
+               if (MEDIA_VISION_ERROR_NONE != err) {
+                       LOGE("ERROR: Errors were occurred during video reader destroying; code %i\n", err);
+               }
        }
 
        LOGD("end of destroy");
@@ -257,16 +250,8 @@ void eos_frame_cb(mv_video_reader_h reader,
                LOGE("ERROR: eos callback can't stop tracking process.");
                return;
        }
-       video_info *video_infos = calloc(1, sizeof(video_info));
-       if(!video_infos)
-       {
-               LOGE("video_info malloc fail\n");
-               return;
-       }
-
-       video_infos->reader = reader;
 
-       ecore_main_loop_thread_safe_call_async(_vision_finish_cb, video_infos);
+       ecore_main_loop_thread_safe_call_async(_vision_finish_cb, reader);
 }
 
 int infer_task_with_frame(mv_source_h frame, int task_id, void *user_data)
@@ -427,6 +412,7 @@ int classification_from_video(const char *path_to_video)
        else
        {
                LOGE("Fail to find infer handler\n");
+               err = -1;
        }
        return err;
 }
@@ -475,7 +461,7 @@ int infer_task_with_image(const char *img_file_name, mv_inference_h infer, int t
        return err;
 }
 
-void classification_from_image(const char *path_to_image)
+int classification_from_image(const char *path_to_image)
 {
        int err = MEDIA_VISION_ERROR_NONE;
 
@@ -489,7 +475,9 @@ void classification_from_image(const char *path_to_image)
        else
        {
                LOGE("Fail to find infer handler\n");
+               err = -1;
        }
+       return err;
 }
 
 int image_classification_init(void)
@@ -539,7 +527,10 @@ _vision_event_cb(void *data, int type, void *event)
        }
 
        LOGI("path to video = %s", path_to_video);
-       classification_from_video(path_to_video);
+       int err = classification_from_video(path_to_video);
+       if (err != MEDIA_VISION_ERROR_NONE) {
+               LOGE("classification_from_video failed");
+       }
 
        return ECORE_CALLBACK_PASS_ON;
 }