From: Sung-jae Park Date: Mon, 7 Oct 2013 09:37:47 +0000 (+0900) Subject: Add frame drop & manual sync mode. X-Git-Tag: accepted/tizen/20131022.083701^2~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fframework%2Fweb%2Flivebox-viewer.git;a=commitdiff_plain;h=a447d04e4013fef7b6b9e50b6bad3b4abda36861 Add frame drop & manual sync mode. Change-Id: I5600aa18e16d5526bec045ae7297c71990d4d805 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0933a34..505f8f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED src/client.c src/critical_log.c src/file_service.c + src/conf.c ) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) diff --git a/include/conf.h b/include/conf.h index 57a8b92..7258093 100644 --- a/include/conf.h +++ b/include/conf.h @@ -30,4 +30,9 @@ #define VCONFKEY_MASTER_CLIENT_ADDR "db/data-provider-master/serveraddr" #endif +extern void conf_set_manual_sync(int flag); +extern int conf_manual_sync(void); +extern void conf_set_frame_drop_for_resizing(int flag); +extern int conf_frame_drop_for_resizing(void); + /* End of a file */ diff --git a/include/livebox.h b/include/livebox.h index c57f193..b64c55c 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -1413,6 +1413,18 @@ extern int livebox_set_update_mode(struct livebox *handler, int active_update, r */ extern int livebox_is_active_update(struct livebox *handler); +extern void livebox_set_manual_sync(int flag); + +extern int livebox_manual_sync(void); + +extern void livebox_set_frame_drop_for_resizing(int flag); + +extern int livebox_frame_drop_for_resizing(void); + +extern int livebox_sync_pd_fb(struct livebox *handler); + +extern int livebox_sync_lb_fb(struct livebox *handler); + /*! * \} */ diff --git a/packaging/liblivebox-viewer.spec b/packaging/liblivebox-viewer.spec index ec545be..a05b31a 100644 --- a/packaging/liblivebox-viewer.spec +++ b/packaging/liblivebox-viewer.spec @@ -1,6 +1,6 @@ Name: liblivebox-viewer Summary: Library for developing the application. -Version: 0.14.4 +Version: 0.14.5 Release: 1 Group: HomeTF/Livebox License: Flora License diff --git a/src/client.c b/src/client.c index c94b92e..037a5d5 100644 --- a/src/client.c +++ b/src/client.c @@ -284,7 +284,7 @@ static struct packet *master_lb_update_begin(pid_t pid, int handle, const struct * And then begin updating again after change its size. */ if (lb_get_lb_fb(handler)) { - lb_set_lb_fb(handler, fbfile); + (void)lb_set_lb_fb(handler, fbfile); ret = fb_sync(lb_get_lb_fb(handler)); if (ret != LB_STATUS_SUCCESS) { @@ -326,7 +326,7 @@ static struct packet *master_pd_update_begin(pid_t pid, int handle, const struct } if (lb_get_pd_fb(handler)) { - lb_set_lb_fb(handler, fbfile); + (void)lb_set_lb_fb(handler, fbfile); ret = fb_sync(lb_get_lb_fb(handler)); if (ret != LB_STATUS_SUCCESS) { @@ -509,10 +509,21 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack */ goto out; } else if (lb_get_lb_fb(handler)) { - lb_set_lb_fb(handler, fbfile); - ret = fb_sync(lb_get_lb_fb(handler)); - if (ret != LB_STATUS_SUCCESS) { - ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret); + if (conf_frame_drop_for_resizing() && handler->size_changed_cb) { + /* Just for skipping the update event callback call, After request to resize buffer, update event will be discarded */ + DbgPrint("Discards obsoloted update event\n"); + ret = LB_STATUS_ERROR_BUSY; + } else { + (void)lb_set_lb_fb(handler, fbfile); + + if (!conf_manual_sync()) { + ret = fb_sync(lb_get_lb_fb(handler)); + if (ret != LB_STATUS_SUCCESS) { + ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret); + } + } else { + ret = LB_STATUS_SUCCESS; + } } } else { ret = LB_STATUS_SUCCESS; @@ -685,13 +696,20 @@ static struct packet *master_pd_updated(pid_t pid, int handle, const struct pack if (lb_text_pd(handler)) { (void)parse_desc(handler, descfile, 1); } else { - (void)lb_set_pd_fb(handler, fbfile); - - ret = fb_sync(lb_get_pd_fb(handler)); - if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s), %d\n", pkgname, util_basename(util_uri_to_path(id)), ret); + if (conf_frame_drop_for_resizing() && handler->size_changed_cb) { + /* Just for skipping the update event callback call, After request to resize buffer, update event will be discarded */ + DbgPrint("Discards obsoloted update event\n"); } else { - lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATED); + (void)lb_set_pd_fb(handler, fbfile); + + if (!conf_manual_sync()) { + ret = fb_sync(lb_get_pd_fb(handler)); + if (ret < 0) { + ErrPrint("Failed to do sync FB (%s - %s), %d\n", pkgname, util_basename(util_uri_to_path(id)), ret); + } else { + lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATED); + } + } } } @@ -811,7 +829,7 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa * Update it too. */ if (lb_get_lb_fb(handler)) { - lb_set_lb_fb(handler, fbfile); + (void)lb_set_lb_fb(handler, fbfile); ret = fb_sync(lb_get_lb_fb(handler)); if (ret < 0) { @@ -1079,7 +1097,8 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet if (!strlen(lb_fname)) { break; } - lb_set_lb_fb(handler, lb_fname); + (void)lb_set_lb_fb(handler, lb_fname); + ret = fb_sync(lb_get_lb_fb(handler)); if (ret < 0) { ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); diff --git a/src/conf.c b/src/conf.c new file mode 100644 index 0000000..9a9063b --- /dev/null +++ b/src/conf.c @@ -0,0 +1,31 @@ +#include + +static struct info { + int manual_sync; + int frame_drop_for_resizing; +} s_info = { + .manual_sync = 0, + .frame_drop_for_resizing = 1, +}; + +void conf_set_manual_sync(int flag) +{ + s_info.manual_sync = flag; +} + +int conf_manual_sync(void) +{ + return s_info.manual_sync; +} + +void conf_set_frame_drop_for_resizing(int flag) +{ + s_info.frame_drop_for_resizing = flag; +} + +int conf_frame_drop_for_resizing(void) +{ + return s_info.frame_drop_for_resizing; +} + +/* End of a file */ diff --git a/src/fb.c b/src/fb.c index 1d9fc75..20bffc9 100644 --- a/src/fb.c +++ b/src/fb.c @@ -106,6 +106,11 @@ int fb_fini(void) return 0; } +static inline void update_fb_size(struct fb_info *info) +{ + info->bufsz = info->w * info->h * s_info.depth; +} + static inline int sync_for_file(struct fb_info *info) { int fd; @@ -208,6 +213,12 @@ static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info } if (info->bufsz == 0) { + /*! + * If the client does not acquire the buffer, + * This function will do nothing. + * It will work only if the buffer is acquired. + * To sync its contents. + */ DbgPrint("Nothing can be sync\n"); return LB_STATUS_SUCCESS; } @@ -386,7 +397,8 @@ void *fb_acquire_buffer(struct fb_info *info) if (!info->buffer) { if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) { - info->bufsz = info->w * info->h * s_info.depth; + update_fb_size(info); + buffer = calloc(1, sizeof(*buffer) + info->bufsz); if (!buffer) { CRITICAL_LOG("Heap: %s\n", strerror(errno)); @@ -406,7 +418,8 @@ void *fb_acquire_buffer(struct fb_info *info) */ sync_for_pixmap(info); } else if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) { - info->bufsz = info->w * info->h * s_info.depth; + update_fb_size(info); + buffer = calloc(1, sizeof(*buffer) + info->bufsz); if (!buffer) { CRITICAL_LOG("Heap: %s\n", strerror(errno)); @@ -573,7 +586,8 @@ int fb_size(struct fb_info *info) return 0; } - info->bufsz = info->w * info->h * s_info.depth; + update_fb_size(info); + return info->bufsz; } diff --git a/src/livebox.c b/src/livebox.c index a139f7a..743ae95 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -38,6 +38,7 @@ #include "master_rpc.h" #include "client.h" #include "critical_log.h" +#include "conf.h" #define EAPI __attribute__((visibility("default"))) #define MINIMUM_EVENT s_info.event_filter @@ -2827,8 +2828,8 @@ void lb_set_id(struct livebox *handler, const char *id) void lb_set_filename(struct livebox *handler, const char *filename) { if (handler->filename) { - if (unlink(handler->filename) < 0) { - ErrPrint("unlink: %s\n", strerror(errno)); + if (handler->filename[0] && unlink(handler->filename) < 0) { + ErrPrint("unlink: %s (%s)\n", strerror(errno), handler->filename); } free(handler->filename); @@ -2836,7 +2837,7 @@ void lb_set_filename(struct livebox *handler, const char *filename) handler->filename = strdup(filename); if (!handler->filename) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s (%s)\n", strerror(errno), handler->filename); return; } } @@ -3140,4 +3141,34 @@ EAPI int livebox_client_resumed(void) return master_rpc_request_only(NULL, packet); } +EAPI void livebox_set_manual_sync(int flag) +{ + conf_set_manual_sync(flag); +} + +EAPI int livebox_manual_sync(void) +{ + return conf_manual_sync(); +} + +EAPI void livebox_set_frame_drop_for_resizing(int flag) +{ + conf_set_frame_drop_for_resizing(flag); +} + +EAPI int livebox_frame_drop_for_resizing(void) +{ + return conf_frame_drop_for_resizing(); +} + +EAPI int livebox_sync_lb_fb(struct livebox *handler) +{ + return fb_sync(lb_get_lb_fb(handler)); +} + +EAPI int livebox_sync_pd_fb(struct livebox *handler) +{ + return fb_sync(lb_get_pd_fb(handler)); +} + /* End of a file */