Remove __mm_util_transform & __mm_util_create_thread 49/191049/5
authorjiyong.min <jiyong.min@samsung.com>
Thu, 11 Oct 2018 04:06:20 +0000 (13:06 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Thu, 11 Oct 2018 04:23:23 +0000 (13:23 +0900)
Change-Id: Ied7783f5a338deaa3a79b1da417b47b30f75e726

src/image_util.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index a5444af..f2df142
@@ -166,7 +166,7 @@ static void __mm_destroy_temp_buffer(unsigned char *buffer[])
                IMAGE_UTIL_SAFE_FREE(buffer[i]);
 }
 
-static int __mm_util_processing(transformation_s *handle)
+static int __mm_util_transform(transformation_s *handle)
 {
        int ret = IMAGE_UTIL_ERROR_NONE;
        unsigned char *dst_buf[4] = {NULL,};
@@ -370,7 +370,7 @@ gpointer __mm_util_thread_repeate(gpointer data)
 
                image_util_debug("orig_image: %p [%zu] %lu X %lu (%u)", pop_data->data, pop_data->size, pop_data->width, pop_data->height, pop_data->color);
 
-               ret = __mm_util_processing(handle);
+               ret = __mm_util_transform(handle);
 
                image_util_debug("result_image: %p [%zu] %lu X %lu (%u)", handle->dst->data, handle->dst->size, handle->dst->width, handle->dst->height, handle->dst->color);
 
@@ -401,50 +401,6 @@ gpointer __mm_util_thread_repeate(gpointer data)
        return NULL;
 }
 
-static int __mm_util_create_thread(transformation_s *handle)
-{
-       int ret = IMAGE_UTIL_ERROR_NONE;
-
-       image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
-       image_util_retvm_if(handle->thread != NULL, IMAGE_UTIL_ERROR_NONE, "[NO-ERROR] Thread is already created");
-
-       /*create threads*/
-       handle->thread = g_thread_new("transform_thread", (GThreadFunc)__mm_util_thread_repeate, (gpointer)handle);
-       image_util_retvm_if(handle->thread == NULL, IMAGE_UTIL_ERROR_INVALID_OPERATION, "ERROR - create thread");
-
-       image_util_debug("New thread is created");
-
-       return ret;
-}
-
-static int __mm_util_transform(transformation_s *handle, mm_image_info_s *image)
-{
-       int ret = IMAGE_UTIL_ERROR_NONE;
-
-       image_util_fenter();
-
-       image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
-       image_util_retvm_if(image == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid image");
-
-       image_util_debug("image: %p", image);
-
-       if (handle->queue) {
-               image_util_debug("g_async_queue_push");
-               g_async_queue_push(handle->queue, GINT_TO_POINTER(image));
-               ret = __mm_util_create_thread(handle);
-               if (ret != IMAGE_UTIL_ERROR_NONE) {
-                       image_util_error("ERROR - Create thread");
-                       return ret;
-               } else {
-                       image_util_debug("Success -__mm_util_create_thread");
-               }
-       }
-
-       image_util_fleave();
-
-       return ret;
-}
-
 static int _image_util_packet_to_image(media_packet_h packet, mm_image_info_s **color_image)
 {
        int err = IMAGE_UTIL_ERROR_NONE;
@@ -686,6 +642,7 @@ int image_util_transform_run(transformation_h handle, media_packet_h src, image_
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
        image_util_retvm_if((completed_cb == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid callback");
        image_util_retvm_if((src == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid source");
+       image_util_retvm_if((_handle->queue == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid queue");
        image_util_retvm_if((!_handle->set_convert && !_handle->set_resize && !_handle->set_rotate && !_handle->set_crop), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid transform");
 
        err = _image_util_packet_to_image(src, &color_image);
@@ -703,11 +660,21 @@ int image_util_transform_run(transformation_h handle, media_packet_h src, image_
        _handle->_util_cb->user_data = user_data;
        _handle->_util_cb->completed_cb = completed_cb;
 
-       err = __mm_util_transform(_handle, color_image);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("Error - Run transform (%d)", err);
-               __mm_util_destroy_color_image(color_image);
-               return err;
+       image_util_debug("g_async_queue_push");
+       g_async_queue_push(_handle->queue, GINT_TO_POINTER(color_image));
+
+       if (!_handle->thread) {
+               /*create threads*/
+               _handle->thread = g_thread_new("transform_thread", (GThreadFunc)__mm_util_thread_repeate, (gpointer)_handle);
+               if (_handle->thread == NULL) {
+                       image_util_error("Fail - Create thread");
+                       __mm_util_destroy_color_image(color_image);
+                       return IMAGE_UTIL_ERROR_INVALID_OPERATION;
+               } else {
+                       image_util_debug("Success - Create thread");
+               }
+       } else {
+               image_util_debug("Thread alreay exist");
        }
 
        return IMAGE_UTIL_ERROR_NONE;