diff options
author | Minje Ahn <minje.ahn@samsung.com> | 2016-03-23 09:37:57 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2016-03-23 09:43:25 +0900 |
commit | 7020eb25112070454fe450cab3b0b7215d8f90cc (patch) | |
tree | 4e16aa2b7521801db235736622ebb98704668b6c /src | |
parent | 5ab78ec86380f306e30b6ac419a0e7bcb21dadbe (diff) | |
download | libmedia-thumbnail-7020eb25112070454fe450cab3b0b7215d8f90cc.tar.gz libmedia-thumbnail-7020eb25112070454fe450cab3b0b7215d8f90cc.tar.bz2 libmedia-thumbnail-7020eb25112070454fe450cab3b0b7215d8f90cc.zip |
Add request id to media handler for duplicated requestsubmit/tizen/20160405.001445accepted/tizen/wearable/20160405.081633accepted/tizen/tv/20160405.081600accepted/tizen/mobile/20160405.081535accepted/tizen/ivi/20160405.081652accepted/tizen/common/20160405.132318
Change-Id: I90d6103c199c4a7e209f16e1e0e6f648f488e866
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/include/ipc/media-thumb-ipc.h | 1 | ||||
-rwxr-xr-x | src/ipc/media-thumb-ipc.c | 24 | ||||
-rwxr-xr-x | src/media-thumbnail.c | 9 |
3 files changed, 19 insertions, 15 deletions
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h index aa5db4b..1b5b17f 100755 --- a/src/include/ipc/media-thumb-ipc.h +++ b/src/include/ipc/media-thumb-ipc.h @@ -73,6 +73,7 @@ int _media_thumb_request(int msg_type, uid_t uid); int _media_thumb_request_async(int msg_type, + unsigned int request_id, const char *origin_path, thumbUserData *userData, uid_t uid); diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c index f8f213f..29ce6b1 100755 --- a/src/ipc/media-thumb-ipc.c +++ b/src/ipc/media-thumb-ipc.c @@ -43,6 +43,7 @@ static GQueue *g_manage_raw_queue = NULL; typedef struct { GIOChannel *channel; int msg_type; + unsigned int request_id; bool isCanceled; int source_id; uid_t uid; @@ -139,7 +140,7 @@ int __media_thumb_pop_req_queue(const char *path) return MS_MEDIA_ERR_NONE; } -int __media_thumb_check_req_queue_for_cancel(const char *path) +int __media_thumb_check_req_queue_for_cancel(unsigned int request_id, const char *path) { int req_len = 0; @@ -151,7 +152,7 @@ int __media_thumb_check_req_queue_for_cancel(const char *path) thumbReq *req = NULL; req = (thumbReq *)g_queue_peek_head(g_request_queue); - if (req != NULL && strncmp(path, req->path, strlen(path)) == 0) { + if (req != NULL && strncmp(path, req->path, strlen(path)) == 0 && request_id == req->request_id) { req->isCanceled = true; __media_thumb_shutdown_channel(false); @@ -162,7 +163,7 @@ int __media_thumb_check_req_queue_for_cancel(const char *path) return MS_MEDIA_ERR_INTERNAL; } -int __media_thumb_pop_manage_queue(const char *path) +int __media_thumb_pop_manage_queue(unsigned int request_id, const char *path) { int req_len = 0, i; bool flag = false; @@ -177,7 +178,7 @@ int __media_thumb_pop_manage_queue(const char *path) req = (thumbReq *)g_queue_peek_nth(g_manage_queue, i); if (req == NULL) continue; - if (strncmp(path, req->path, strlen(path)) == 0) { + if (strncmp(path, req->path, strlen(path)) == 0 && request_id == req->request_id) { g_queue_pop_nth(g_manage_queue, i); SAFE_FREE(req->path); @@ -188,7 +189,7 @@ int __media_thumb_pop_manage_queue(const char *path) } } if (!flag) { - return __media_thumb_check_req_queue_for_cancel(path); + return __media_thumb_check_req_queue_for_cancel(request_id, path); } else { __media_thumb_shutdown_channel(false); @@ -296,7 +297,7 @@ int __media_thumb_pop_raw_data_manage_queue(int request_id) return MS_MEDIA_ERR_NONE; } - +#if 0 int __media_thumb_check_req_queue(const char *path) { int req_len = 0, i; @@ -348,7 +349,7 @@ int __media_thumb_check_req_queue(const char *path) return MS_MEDIA_ERR_NONE; } - +#endif bool __media_thumb_check_cancel(void) { thumbReq *req = NULL; @@ -997,7 +998,7 @@ int _media_thumb_raw_data_send_request() return MS_MEDIA_ERR_NONE; } -int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserData *userData, uid_t uid) +int _media_thumb_request_async(int msg_type, unsigned int request_id, const char *origin_path, thumbUserData *userData, uid_t uid) { int err = MS_MEDIA_ERR_NONE; @@ -1018,6 +1019,7 @@ int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserD thumb_req->path = strdup(origin_path); thumb_req->userData = userData; thumb_req->isCanceled = false; + thumb_req->request_id = request_id; thumb_req->uid = uid; g_queue_push_tail(g_manage_queue, (gpointer)thumb_req); @@ -1028,11 +1030,12 @@ int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserD } else { if (msg_type != THUMB_REQUEST_CANCEL_MEDIA) { /* Enqueue */ +#if 0 if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) { thumb_err("duplicated request"); return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST; } - +#endif thumbReq *thumb_req = NULL; THUMB_MALLOC(thumb_req, sizeof(thumbReq)); if (thumb_req == NULL) { @@ -1044,12 +1047,13 @@ int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserD thumb_req->path = strdup(origin_path); thumb_req->userData = userData; thumb_req->isCanceled = false; + thumb_req->request_id = request_id; thumb_req->uid = uid; g_queue_push_tail(g_manage_queue, (gpointer)thumb_req); } else { /* Dequeue */ - err = __media_thumb_pop_manage_queue(origin_path); + err = __media_thumb_pop_manage_queue(request_id, origin_path); } } diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c index f378f14..1cbc719 100755 --- a/src/media-thumbnail.c +++ b/src/media-thumbnail.c @@ -30,7 +30,6 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height, uid_t uid) { int err = MS_MEDIA_ERR_NONE; - //int need_update_db = 0; media_thumb_info thumb_info; if (origin_path == NULL || thumb_path == NULL) { @@ -94,7 +93,7 @@ int thumbnail_request_extract_all_thumbs(uid_t uid) return MS_MEDIA_ERR_NONE; } -int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data, uid_t uid) +int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_path, ThumbFunc func, void *user_data, uid_t uid) { int err = MS_MEDIA_ERR_NONE; @@ -127,7 +126,7 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi userData->user_data = user_data; /* Request for thumb file to the daemon "Thumbnail generator" */ - err = _media_thumb_request_async(THUMB_REQUEST_DB_INSERT, origin_path, userData, uid); + err = _media_thumb_request_async(THUMB_REQUEST_DB_INSERT, request_id, origin_path, userData, uid); if (err != MS_MEDIA_ERR_NONE) { thumb_err("_media_thumb_request failed : %d", err); SAFE_FREE(userData); @@ -170,7 +169,7 @@ int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_ return MS_MEDIA_ERR_NONE; } -int thumbnail_request_cancel_media(const char *origin_path) +int thumbnail_request_cancel_media(unsigned int request_id, const char *origin_path) { int err = MS_MEDIA_ERR_NONE; @@ -179,7 +178,7 @@ int thumbnail_request_cancel_media(const char *origin_path) return MS_MEDIA_ERR_INVALID_PARAMETER; } - err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA, origin_path, NULL, 0); + err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA, request_id, origin_path, NULL, 0); if (err != MS_MEDIA_ERR_NONE) { thumb_err("_media_thumb_request failed : %d", err); return err; |