Just add some debug msg to track error 00/187400/1 accepted/tizen/unified/20180824.062640 submit/tizen/20180823.021953
authorhj kim <backto.kim@samsung.com>
Thu, 23 Aug 2018 02:12:53 +0000 (11:12 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 23 Aug 2018 02:13:34 +0000 (11:13 +0900)
Change-Id: I3a4b84d7376cebdfd5bcb7d55c250dea44ebf0fb

include/image_util_private.h
src/image_util_decode.c

index 26f056958ce5647cda6edb0d72565cc81e983add..036769cd602965a401b653955472d53e95f08dc1 100755 (executable)
@@ -53,7 +53,7 @@ extern "C"
                        LOGD(FONT_COLOR_YELLOW"<ENTER>"FONT_COLOR_RESET); \
                } while (0)
 
-#define image_util__fleave() do { \
+#define image_util_fleave() do { \
                        LOGD(FONT_COLOR_YELLOW"<LEAVE>"FONT_COLOR_RESET); \
                } while (0)
 
index 043b00a9b55ed3ea4149f834dc79c9c0b9619e40..eab8d361575dab8e6e722a82c3ab5e98ac2f3365 100755 (executable)
@@ -206,24 +206,15 @@ int image_util_decode_set_input_buffer(image_util_decode_h handle, const unsigne
        IMAGE_UTIL_SAFE_FREE(_handle->path);
 
        err = _image_util_decode_check_image_type(src_buffer, &_handle->image_type);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("_image_util_decode_check_image_type failed");
-               return err;
-       }
+       image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "_image_util_decode_check_image_type failed");
 
        err = _image_util_decode_create_image_handle(_handle);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("_image_util_decode_create_image_handle failed");
-               return err;
-       }
+       image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "_image_util_decode_create_image_handle failed");
 
        IMAGE_UTIL_SAFE_FREE(_handle->src_buffer);
 
        _handle->src_buffer = (void *)calloc(1, sizeof(void *));
-       if (_handle->src_buffer == NULL) {
-               image_util_error("The memory of input buffer was not allocated");
-               return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
-       }
+       image_util_retvm_if(_handle->src_buffer == NULL, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "The memory of input buffer was not allocated");
 
        _handle->src_buffer[0] = (void *)src_buffer;
        _handle->src_size = src_size;
@@ -235,6 +226,8 @@ int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned cha
 {
        decode_encode_s *_handle = (decode_encode_s *) handle;
 
+       image_util_fenter();
+
        IMAGE_UTIL_DECODE_HANDLE_CHECK(handle);
        image_util_retvm_if(dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
@@ -276,7 +269,11 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
 {
        int err = MM_UTIL_ERROR_NONE;
 
+       image_util_fenter();
+
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid parameter");
+       image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
+
        switch (_handle->image_type) {
        case IMAGE_UTIL_JPEG:
                {
@@ -293,6 +290,8 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                                _handle->dst_size = (unsigned long long)jpeg_data.size;
                                _handle->width = jpeg_data.width;
                                _handle->height = jpeg_data.height;
+                       } else {
+                               image_util_error("fail to decode jpeg [%d]", err);
                        }
                }
                break;
@@ -311,6 +310,8 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                                _handle->dst_size = (unsigned long long)png_data.size;
                                _handle->width = png_data.width;
                                _handle->height = png_data.height;
+                       } else {
+                               image_util_error("fail to decode png [%d]", err);
                        }
                }
                break;
@@ -329,6 +330,8 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                                _handle->dst_size = gif_data.size;
                                _handle->width = gif_data.width;
                                _handle->height = gif_data.height;
+                       } else {
+                               image_util_error("fail to decode gif [%d]", err);
                        }
                }
                break;
@@ -347,14 +350,19 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                                _handle->dst_size = (unsigned long long)bmp_data.size;
                                _handle->width = bmp_data.width;
                                _handle->height = bmp_data.height;
+                       } else {
+                               image_util_error("fail to decode bmp [%d]", err);
                        }
                }
                break;
        default:
+               image_util_error("Not supported format [%d]", _handle->image_type);
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
                break;
        }
 
+       image_util_debug("dst_buffer(%p) width (%lu) height (%lu) dst_size (%zu)", *(_handle->dst_buffer), _handle->width, _handle->height, _handle->dst_size);
+
        return _image_error_capi(ERR_TYPE_DECODE, err);
 }
 
@@ -368,11 +376,7 @@ int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsi
        image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
 
        err = _image_util_decode_internal(_handle);
-
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("Error - decode run");
-               return err;
-       }
+       image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "fail to _image_util_decode_internal");
 
        if (width)
                *width = _handle->width;
@@ -389,6 +393,8 @@ gpointer _image_util_decode_thread(gpointer data)
        decode_encode_s *_handle = (decode_encode_s *) data;
        int err = IMAGE_UTIL_ERROR_NONE;
 
+       image_util_fenter();
+
        if (!_handle) {
                image_util_error("[ERROR] - handle");
                return NULL;
@@ -401,11 +407,13 @@ gpointer _image_util_decode_thread(gpointer data)
                image_util_error("Error - decode_internal");
 
        if (_handle->_decode_cb) {
-               image_util_debug("completed_cb");
+               image_util_debug("call completed_cb");
                _handle->_decode_cb->image_decode_completed_cb(err, _handle->_decode_cb->user_data, _handle->width, _handle->height, _handle->dst_size);
+       } else {
+               image_util_error("No callback");
        }
 
-       image_util_debug("exit thread");
+       image_util_fleave();
 
        return NULL;
 }
@@ -430,6 +438,8 @@ int image_util_decode_run_async(image_util_decode_h handle, image_util_decode_co
        int err = IMAGE_UTIL_ERROR_NONE;
        decode_encode_s *_handle = (decode_encode_s *) handle;
 
+       image_util_fenter();
+
        IMAGE_UTIL_DECODE_HANDLE_CHECK(handle);
        image_util_retvm_if((_handle->path == NULL && _handle->src_buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
        image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
@@ -453,6 +463,8 @@ int image_util_decode_run_async(image_util_decode_h handle, image_util_decode_co
                _handle->_decode_cb = NULL;
        }
 
+       image_util_fleave();
+
        return err;
 }
 
@@ -460,7 +472,7 @@ int image_util_decode_destroy(image_util_decode_h handle)
 {
        decode_encode_s *_handle = (decode_encode_s *) handle;
 
-       image_util_debug("image_util_decode_destroy");
+       image_util_fenter();
 
        IMAGE_UTIL_DECODE_HANDLE_CHECK(handle);
 
@@ -473,5 +485,7 @@ int image_util_decode_destroy(image_util_decode_h handle)
        IMAGE_UTIL_SAFE_FREE(_handle->src_buffer);
        IMAGE_UTIL_SAFE_FREE(_handle);
 
+       image_util_fleave();
+
        return IMAGE_UTIL_ERROR_NONE;
 }