summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-06-08 16:33:26 +0900
committerMinje Ahn <minje.ahn@samsung.com>2015-06-08 16:33:26 +0900
commitb17f8d10bf16779c62c4e2b267d2bdc716ccfdac (patch)
treef4572cb3d19abe5c93bb331ae639eb54d5a123dc
parent9c534f334a71a5250c9411cc53c83cd72e3b7e74 (diff)
downloadlibmedia-thumbnail-b17f8d10bf16779c62c4e2b267d2bdc716ccfdac.tar.gz
libmedia-thumbnail-b17f8d10bf16779c62c4e2b267d2bdc716ccfdac.tar.bz2
libmedia-thumbnail-b17f8d10bf16779c62c4e2b267d2bdc716ccfdac.zip
Update error log.
Change-Id: I632eda45a7b46927b5c5be9e98cebd30aefc69d4 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rw-r--r--packaging/libmedia-thumbnail.spec30
-rwxr-xr-xserver/thumb-server-internal.c4
-rw-r--r--src/codec/img-codec-osal.c2
-rwxr-xr-xsrc/include/util/media-thumb-debug.h30
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c14
-rwxr-xr-xsrc/media-thumb-internal.c12
-rwxr-xr-xsrc/media-thumbnail.c9
-rwxr-xr-xsrc/util/media-thumb-db.c40
-rwxr-xr-xsrc/util/media-thumb-debug.c4
-rwxr-xr-xsrc/util/media-thumb-util.c3
10 files changed, 85 insertions, 63 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index 4886069..4409f0b 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -10,22 +10,22 @@ Source1002: %{name}-devel.manifest
Source1003: media-thumbnail-server.manifest
Requires: media-server
-BuildRequires: cmake
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(drm-client)
-BuildRequires: pkgconfig(heynoti)
-BuildRequires: pkgconfig(libexif)
-BuildRequires: pkgconfig(libmedia-utils)
-BuildRequires: pkgconfig(mm-fileinfo)
-BuildRequires: pkgconfig(mmutil-imgp)
-BuildRequires: pkgconfig(mmutil-jpeg)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(gdk-pixbuf-2.0)
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(mm-fileinfo)
+BuildRequires: pkgconfig(mmutil-imgp)
+BuildRequires: pkgconfig(mmutil-jpeg)
+BuildRequires: pkgconfig(drm-client)
+BuildRequires: pkgconfig(heynoti)
+BuildRequires: pkgconfig(libexif)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(libmedia-utils)
+BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(gdk-pixbuf-2.0)
%description
-Media thumbnail service library for multimedia applications.
+Description: Media thumbnail service library for multimedia applications.
%package devel
Summary: Media Thumbnail Service Library (development)
@@ -39,7 +39,7 @@ Summary: Thumbnail generator
Requires: %{name} = %{version}-%{release}
%description -n media-thumbnail-server
-Media Thumbnail Server.
+Description: Media Thumbnail Server.
%package test
Summary: Thumbnail generator Tests
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index 3bd4139..c739251 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -62,7 +62,7 @@ void _thumb_daemon_finish_jobs(void)
}
g_main_loop_quit(g_thumb_server_mainloop);
-
+
return;
}
@@ -349,7 +349,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
_media_thumb_set_buffer(&res_msg, &buf, &buf_size);
if (sendto(sock, buf, buf_size, 0, (struct sockaddr *)&client_addr, sizeof(client_addr)) != buf_size) {
- thumb_err("sendto failed: %s\n", strerror(errno));
+ thumb_stderror("sendto failed");
SAFE_FREE(buf);
return FALSE;
}
diff --git a/src/codec/img-codec-osal.c b/src/codec/img-codec-osal.c
index ecce649..88123bb 100644
--- a/src/codec/img-codec-osal.c
+++ b/src/codec/img-codec-osal.c
@@ -126,7 +126,7 @@ BOOL DrmSeekFile(HFile hFile, long position, long offset)
if (!_is_real_drm) {
ret = fseek(hFile, offset, position);
if (ret < 0) {
- thumb_err("fseek failed : %s", strerror(errno));
+ thumb_stderror("fseek failed");
return FALSE;
}
} else {
diff --git a/src/include/util/media-thumb-debug.h b/src/include/util/media-thumb-debug.h
index 2bc7380..3c0c21b 100755
--- a/src/include/util/media-thumb-debug.h
+++ b/src/include/util/media-thumb-debug.h
@@ -54,9 +54,33 @@ static pid_t gettid(void)
#define FONT_COLOR_CYAN "\033[36m"
#define FONT_COLOR_GRAY "\033[37m"
-#define thumb_dbg(fmt, arg...) LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg)
-#define thumb_warn(fmt, arg...) LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg)
-#define thumb_err(fmt, arg...) LOGE(FONT_COLOR_RED"[%d] " fmt "\n", gettid(), ##arg)
+#define thumb_dbg(fmt, arg...) do{ \
+ LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg); \
+ } while(0)
+
+#define thumb_warn(fmt, arg...) do{ \
+ LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg); \
+ } while(0)
+
+#define thumb_err(fmt, arg...) do{ \
+ LOGE(FONT_COLOR_RED"[%d] " fmt "\n", gettid(), ##arg); \
+ } while(0)
+
+#define thumb_dbg_slog(fmt, arg...) do{ \
+ SECURE_LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg); \
+ } while(0)
+
+#define thumb_warn_slog(fmt, arg...) do{ \
+ SECURE_LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg); \
+ } while(0)
+
+
+#define ERR_BUF_LENGHT 256
+#define thumb_stderror(fmt) do { \
+ char buf[ERR_BUF_LENGHT] = {0,}; \
+ strerror_r(errno, buf, ERR_BUF_LENGHT); \
+ LOGE(FONT_COLOR_RED fmt" : standard error [%s]", buf); \
+ } while (0)
#ifdef _USE_LOG_FILE_
void thumb_init_file_debug();
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 9284c64..7f4c381 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -186,7 +186,7 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
buf = (unsigned char*)malloc(header_size);
if ((recv_msg_len = recv(sock, buf, header_size, 0)) <= 0) {
- thumb_err("recvfrom failed : %s", strerror(errno));
+ thumb_stderror("recv failed");
SAFE_FREE(buf);
return _media_thumb_get_error();
}
@@ -233,7 +233,7 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
buf = (unsigned char*)malloc(sizeof(thumbMsg));
if ((recv_msg_len = recvfrom(sock, buf, sizeof(thumbMsg), 0, (struct sockaddr *)from_addr, &from_addr_size)) < 0) {
- thumb_err("recvfrom failed : %s", strerror(errno));
+ thumb_stderror("recvform failed");
SAFE_FREE(buf);
return _media_thumb_get_error();
}
@@ -313,7 +313,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
- thumb_err("connect error : %s", strerror(errno));
+ thumb_stderror("connect");
return MS_MEDIA_ERR_SOCKET_CONN;
}
@@ -356,7 +356,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
_media_thumb_set_buffer(&req_msg, &buf, &buf_size);
if (send(sock, buf, buf_size, 0) != buf_size) {
- thumb_err("sendto failed: %d\n", errno);
+ thumb_err("sendto failed: %d", errno);
SAFE_FREE(buf);
close(sock);
return MS_MEDIA_ERR_SOCKET_SEND;
@@ -373,7 +373,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
}
recv_str_len = strlen(recv_msg.org_path);
- thumb_dbg("recv %s(%d) from thumb daemon is successful", recv_msg.org_path, recv_str_len);
+ thumb_dbg_slog("recv %s(%d) from thumb daemon is successful", recv_msg.org_path, recv_str_len);
close(sock);
@@ -710,7 +710,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
req_msg.pid = pid;
req_msg.msg_type = msg_type;
req_msg.thumb_type = thumb_type;
- req_msg.uid = uid;
+ req_msg.uid = uid;
strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
req_msg.org_path[strlen(req_msg.org_path)] = '\0';
@@ -729,7 +729,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
_media_thumb_set_buffer(&req_msg, &buf, &buf_size);
if (send(sock, buf, buf_size, 0) != buf_size) {
- thumb_err("sendto failed: %d\n", errno);
+ thumb_err("sendto failed: %d", errno);
SAFE_FREE(buf);
g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id));
g_io_channel_shutdown(channel, TRUE, NULL);
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index 2ca640d..12e36f2 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -134,7 +134,7 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
tag == EXIF_TAG_PIXEL_Y_DIMENSION) {
if (value == NULL) {
- thumb_dbg("value is NULL");
+ thumb_err("value is NULL");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
@@ -145,7 +145,7 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
} else {
/* Get the contents of the tag in human-readable form */
if (buf == NULL) {
- thumb_dbg("buf is NULL");
+ thumb_err("buf is NULL");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
exif_entry_get_value(entry, buf, max_size);
@@ -160,8 +160,8 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
return MS_MEDIA_ERR_NONE;
}
-int _media_thumb_get_thumb_from_exif(ExifData *ed,
- const char *file_full_path,
+int _media_thumb_get_thumb_from_exif(ExifData *ed,
+ const char *file_full_path,
int orientation,
int required_width,
int required_height,
@@ -191,7 +191,7 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
if (entry) {
/* Get the contents of the tag in human-readable form */
ExifShort value = exif_get_short(entry->data, byte_order);
- //thumb_dbg("%s: %d\n", exif_tag_get_name_in_ifd(tag,ifd), value);
+ //thumb_dbg("%s: %d", exif_tag_get_name_in_ifd(tag,ifd), value);
if (value == 6) {
thumb_dbg("There's jpeg thumb in this image");
@@ -1183,7 +1183,7 @@ int _media_thumb_video(const char *origin_path,
g_object_unref(pixbuf);
} else {
- thumb_dbg("no contents information\n");
+ thumb_dbg("no contents information");
frame = NULL;
mm_file_destroy_content_attrs(content);
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index dca2285..1099cb5 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -58,7 +58,7 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- thumb_err("Path : %s", origin_path);
+ thumb_dbg_slog("Path : %s", origin_path);
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info, uid);
@@ -130,13 +130,12 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- thumb_err("Path : %s", origin_path);
+ thumb_dbg_slog("Path : %s", origin_path);
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info, uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
- //_media_thumb_db_disconnect();
return err;
}
@@ -188,7 +187,7 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- thumb_err("Path : %s", origin_path);
+ thumb_dbg_slog("Path : %s", origin_path);
thumbUserData *userData = (thumbUserData*)malloc(sizeof(thumbUserData));
userData->func = (ThumbFunc)func;
@@ -208,7 +207,7 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi
int _media_thumbnail_cancel_cb(int error_code, char* path, void* data)
{
thumb_dbg("Error code : %d", error_code);
- if (path) thumb_dbg("Cancel : %s", path);
+ if (path) thumb_dbg_slog("Cancel : %s", path);
return MS_MEDIA_ERR_NONE;
}
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index 275a98e..76c737e 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -95,7 +95,7 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
const char *origin_path,
int *type)
{
- thumb_dbg("Origin path : %s", origin_path);
+ thumb_dbg_slog("Origin path : %s", origin_path);
if (handle == NULL) {
thumb_err("DB handle is NULL");
@@ -141,7 +141,7 @@ int _media_thumb_get_wh_from_db(sqlite3 *handle,
int *width,
int *height)
{
- thumb_dbg("Origin path : %s", origin_path);
+ thumb_dbg_slog("Origin path : %s", origin_path);
if (handle == NULL) {
thumb_err("DB handle is NULL");
@@ -156,7 +156,7 @@ int _media_thumb_get_wh_from_db(sqlite3 *handle,
path_string = sqlite3_mprintf("%s", origin_path);
query_string = sqlite3_mprintf(SELECT_WH_BY_PATH, path_string);
- thumb_dbg("Query: %s", query_string);
+ thumb_dbg_slog("Query: %s", query_string);
err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);
@@ -164,13 +164,13 @@ int _media_thumb_get_wh_from_db(sqlite3 *handle,
sqlite3_free(path_string);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle));
+ thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
return -1;
}
err = sqlite3_step(stmt);
if (err != SQLITE_ROW) {
- thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
+ thumb_err("end of row [%s]", sqlite3_errmsg(handle));
sqlite3_finalize(stmt);
return -1;
}
@@ -187,7 +187,7 @@ int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
char *thumb_path,
int max_length)
{
- thumb_dbg("Origin path : %s", origin_path);
+ thumb_dbg_slog("Origin path : %s", origin_path);
if (handle == NULL) {
thumb_err("DB handle is NULL");
@@ -202,7 +202,7 @@ int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
path_string = sqlite3_mprintf("%s", origin_path);
query_string = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path_string);
- thumb_dbg("Query: %s", query_string);
+ thumb_dbg_slog("Query: %s", query_string);
err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);
@@ -236,7 +236,6 @@ int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
char *thumb_path,
uid_t uid)
{
- thumb_dbg("");
int err = MS_MEDIA_ERR_NONE;
char *path_string = NULL;
char *thumbpath_string = NULL;
@@ -252,13 +251,13 @@ int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, thumbpath_string, path_string);
err = media_db_request_update_db(query_string, uid);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_request_update_db failed : %d", err);
- return err;
+ } else {
+ thumb_dbg("Query success");
}
- thumb_dbg("Query success");
- return MS_MEDIA_ERR_NONE;
+ return err;
}
int _media_thumb_update_wh_to_db(sqlite3 *handle,
@@ -282,9 +281,9 @@ int _media_thumb_update_wh_to_db(sqlite3 *handle,
err = media_db_request_update_db(query_string, uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_request_update_db failed : %d", err);
- return err;
+ } else {
+ thumb_dbg("Query success");
}
- thumb_dbg("Query success");
return err;
}
@@ -311,11 +310,10 @@ int _media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
err = media_db_request_update_db(query_string, uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_request_update_db failed : %d", err);
- return err;
+ } else {
+ thumb_dbg("Query success");
}
- thumb_dbg("Query success");
-
return err;
}
@@ -327,7 +325,7 @@ int _media_thumb_db_connect(uid_t uid)
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_connect failed: %d", err);
db_handle = NULL;
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ return err;
}
return MS_MEDIA_ERR_NONE;
@@ -341,7 +339,7 @@ int _media_thumb_db_disconnect()
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_disconnect failed: %d", err);
db_handle = NULL;
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ return err;
}
db_handle = NULL;
@@ -368,7 +366,7 @@ int _media_thumb_get_thumb_from_db(const char *origin_path,
return -1;
}
- thumb_dbg("Thumb path in DB is %s", thumb_path);
+ thumb_dbg_slog("Thumb path in DB is %s", thumb_path);
if (!g_file_test(thumb_path,
G_FILE_TEST_EXISTS)) {
@@ -404,7 +402,7 @@ int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
return -1;
}
- thumb_dbg("Thumb path in DB is %s", thumb_path);
+ thumb_dbg_slog("Thumb path in DB is %s", thumb_path);
if (!g_file_test(thumb_path,
G_FILE_TEST_EXISTS)) {
diff --git a/src/util/media-thumb-debug.c b/src/util/media-thumb-debug.c
index ab75286..a9ce049 100755
--- a/src/util/media-thumb-debug.c
+++ b/src/util/media-thumb-debug.c
@@ -92,7 +92,7 @@ void thumb_print_debug_time(char *time_string)
(double)(time.tv_sec * 1000000 + time.tv_usec -
g_time_usec) / CLOCKS_PER_SEC;
- thumb_dbg("time [%s] : %f \n", time_string, totaltime);
+ thumb_dbg("time [%s] : %f", time_string, totaltime);
#endif
}
@@ -105,7 +105,7 @@ thumb_print_debug_time_ex(long start, long end, const char *func_name,
totaltime = (double)(end - start) / CLOCKS_PER_SEC;
- thumb_dbg("time [%s: %s] : %f \n", func_name, time_string,
+ thumb_dbg("time [%s: %s] : %f", func_name, time_string,
totaltime);
#endif
}
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index ed9c0c7..a6c4fb4 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -21,6 +21,7 @@
#include "media-thumb-util.h"
#include "media-thumb-internal.h"
+#include "media-thumb-debug.h"
#include <glib.h>
#include <aul.h>
@@ -188,7 +189,7 @@ int _media_thumb_remove_file(const char *path)
thumb_dbg("success to remove file");
return TRUE;
} else {
- thumb_err("fail to remove file[%s] result errno = %s", path, strerror(errno));
+ thumb_stderror("fail to remove file[%s] result");
return FALSE;
}
}