Handling the extra buffer
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 17 Oct 2014 07:41:42 +0000 (16:41 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Fri, 17 Oct 2014 07:41:42 +0000 (16:41 +0900)
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ic17b9a437118cdfd29bd8d98f3ab13526aec86d5

include/instance.h
src/instance.c
src/server.c

index bc86e41..25e0d3f 100644 (file)
@@ -169,7 +169,9 @@ extern struct pkg_info * const instance_package(const struct inst_info *inst);
 extern struct script_info * const instance_dbox_script(const struct inst_info *inst);
 extern struct script_info * const instance_gbar_script(const struct inst_info *inst);
 extern struct buffer_info * const instance_gbar_buffer(const struct inst_info *inst);
+extern struct buffer_info * const instance_gbar_extra_buffer(const struct inst_info *inst, int idx);
 extern struct buffer_info * const instance_dbox_buffer(const struct inst_info *inst);
+extern struct buffer_info * const instance_dbox_extra_buffer(const struct inst_info *inst, int idx);
 extern const char * const instance_id(const struct inst_info *inst);
 extern const char * const instance_content(const struct inst_info *inst);
 extern const char * const instance_category(const struct inst_info *inst);
@@ -193,7 +195,9 @@ extern int instance_unicast_created_event(struct inst_info *inst, struct client_
 extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client, int reason);
 
 extern int instance_create_dbox_buffer(struct inst_info *inst, int pixels);
+extern int instance_create_dbox_extra_buffer(struct inst_info *inst, int pixels, int idx);
 extern int instance_create_gbar_buffer(struct inst_info *inst, int pixels);
+extern int instance_create_gbar_extra_buffer(struct inst_info *inst, int pixels, int idx);
 
 extern void instance_slave_set_gbar_pos(struct inst_info *inst, double x, double y);
 extern void instance_slave_get_gbar_pos(struct inst_info *inst, double *x, double *y);
@@ -225,6 +229,12 @@ extern void instance_extra_info_updated_by_instance(struct inst_info *inst);
 extern int instance_client_gbar_destroyed(struct inst_info *inst, int status);
 extern int instance_client_gbar_created(struct inst_info *inst, int status);
 
+extern int instance_client_gbar_extra_buffer_created(struct inst_info *inst, int idx);
+extern int instance_client_gbar_extra_buffer_destroyed(struct inst_info *inst, int idx);
+
+extern int instance_client_dbox_extra_buffer_created(struct inst_info *inst, int idx);
+extern int instance_client_dbox_extra_buffer_destroyed(struct inst_info *inst, int idx);
+
 extern int instance_send_access_status(struct inst_info *inst, int status);
 extern int instance_send_key_status(struct inst_info *inst, int status);
 extern int instance_forward_packet(struct inst_info *inst, struct packet *packet);
index 8465711..4ba4851 100644 (file)
@@ -126,6 +126,8 @@ struct inst_info {
                        struct buffer_info *buffer;
                } canvas;
 
+               struct buffer_info **extra_buffer;
+
                double period;
        } dbox;
 
@@ -140,6 +142,8 @@ struct inst_info {
                        struct buffer_info *buffer;
                } canvas;
 
+               struct buffer_info **extra_buffer;
+
                struct client_node *owner;
                int is_opened_for_reactivate;
                int need_to_send_close_event;
@@ -212,7 +216,6 @@ static inline void timer_freeze(struct inst_info *inst)
 #endif
 }
 
-
 static int viewer_deactivated_cb(struct client_node *client, void *data)
 {
        struct inst_info *inst = data;
@@ -693,6 +696,24 @@ static inline void destroy_instance(struct inst_info *inst)
                if (buffer_handler_destroy(inst->dbox.canvas.buffer) == (int)DBOX_STATUS_ERROR_NONE) {
                        inst->dbox.canvas.buffer = NULL;
                }
+
+               if (inst->dbox.extra_buffer) {
+                       int i;
+
+                       for (i = 0; i < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; i++) {
+                               if (!inst->dbox.extra_buffer[i]) {
+                                       continue;
+                               }
+
+                               (void)buffer_handler_unload(inst->dbox.extra_buffer[i]);
+                               if (buffer_handler_destroy(inst->dbox.extra_buffer[i]) == (int)DBOX_STATUS_ERROR_NONE) {
+                                       inst->dbox.extra_buffer[i] = NULL;
+                               }
+                       }
+
+                       DbgFree(inst->dbox.extra_buffer);
+                       inst->dbox.extra_buffer = NULL;
+               }
        }
 
        if (gbar_type == GBAR_TYPE_SCRIPT) {
@@ -705,6 +726,23 @@ static inline void destroy_instance(struct inst_info *inst)
                if (buffer_handler_destroy(inst->gbar.canvas.buffer) == (int)DBOX_STATUS_ERROR_NONE) {
                        inst->gbar.canvas.buffer = NULL;
                }
+               if (inst->gbar.extra_buffer) {
+                       int i;
+
+                       for (i = 0; i < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; i++) {
+                               if (!inst->gbar.extra_buffer[i]) {
+                                       continue;
+                               }
+
+                               (void)buffer_handler_unload(inst->gbar.extra_buffer[i]);
+                               if (buffer_handler_destroy(inst->gbar.extra_buffer[i]) == (int)DBOX_STATUS_ERROR_NONE) {
+                                       inst->gbar.extra_buffer[i] = NULL;
+                               }
+                       }
+
+                       DbgFree(inst->gbar.extra_buffer);
+                       inst->gbar.extra_buffer = NULL;
+               }
        }
 
        if (inst->client) {
@@ -725,6 +763,7 @@ static inline void destroy_instance(struct inst_info *inst)
        EINA_LIST_FREE(inst->delete_event_list, item) {
                DbgFree(item);
        }
+
        DbgFree(inst->icon);
        DbgFree(inst->name);
        DbgFree(inst->category);
@@ -857,6 +896,17 @@ HAPI struct inst_info *instance_create(struct client_node *client, double timest
        inst->unicast_delete_event = 1;
        inst->state = INST_INIT;
        inst->requested_state = INST_INIT;
+       if (DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) {
+               inst->dbox.extra_buffer = calloc(DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT, sizeof(*inst->dbox.extra_buffer));
+               if (!inst->dbox.extra_buffer) {
+                       ErrPrint("Failed to allocate buffer for dbox extra buffer\n");
+               }
+
+               inst->gbar.extra_buffer = calloc(DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT, sizeof(*inst->gbar.extra_buffer));
+               if (!inst->gbar.extra_buffer) {
+                       ErrPrint("Failed to allocate buffer for gbar extra buffer\n");
+               }
+       }
        instance_ref(inst);
 
        if (package_add_instance(inst->info, inst) < 0) {
@@ -1316,6 +1366,26 @@ HAPI int instance_create_gbar_buffer(struct inst_info *inst, int pixels)
        return !!inst->gbar.canvas.buffer;
 }
 
+HAPI int instance_create_gbar_extra_buffer(struct inst_info *inst, int pixels, int idx)
+{
+       if (!inst->gbar.extra_buffer) {
+               return 0;
+       }
+
+       if (inst->gbar.width == 0 && inst->gbar.height == 0) {
+               instance_set_gbar_size(inst, package_gbar_width(inst->info), package_gbar_height(inst->info));
+       }
+
+       if (!inst->gbar.extra_buffer[idx]) {
+               inst->gbar.extra_buffer[idx] = buffer_handler_create(inst, s_info.env_buf_type, inst->gbar.width, inst->gbar.height, pixels);
+               if (!inst->gbar.extra_buffer[idx]) {
+                       ErrPrint("Failed to create GBAR Extra Buffer\n");
+               }
+       }
+
+       return !!inst->gbar.extra_buffer[idx];
+}
+
 HAPI int instance_create_dbox_buffer(struct inst_info *inst, int pixels)
 {
        if (inst->dbox.width == 0 && inst->dbox.height == 0) {
@@ -1337,6 +1407,26 @@ HAPI int instance_create_dbox_buffer(struct inst_info *inst, int pixels)
        return !!inst->dbox.canvas.buffer;
 }
 
+HAPI int instance_create_dbox_extra_buffer(struct inst_info *inst, int pixels, int idx)
+{
+       if (!inst->dbox.extra_buffer) {
+               return 0;
+       }
+
+       if (inst->dbox.width == 0 && inst->dbox.height == 0) {
+               dynamicbox_service_get_size(DBOX_SIZE_TYPE_1x1, &inst->dbox.width, &inst->dbox.height);
+       }
+
+       if (!inst->dbox.extra_buffer[idx]) {
+               inst->dbox.extra_buffer[idx] = buffer_handler_create(inst, s_info.env_buf_type, inst->dbox.width, inst->dbox.height, pixels);
+               if (!inst->dbox.extra_buffer[idx]) {
+                       ErrPrint("Failed to create DBox Extra buffer\n");
+               }
+       }
+
+       return !!inst->dbox.extra_buffer[idx];
+}
+
 HAPI int instance_destroy(struct inst_info *inst, dynamicbox_destroy_type_e type)
 {
        struct packet *packet;
@@ -2764,6 +2854,16 @@ HAPI struct buffer_info *const instance_gbar_buffer(const struct inst_info *inst
        return (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) ? inst->gbar.canvas.buffer : NULL;
 }
 
+HAPI struct buffer_info *const instance_dbox_extra_buffer(const struct inst_info *inst, int idx)
+{
+       return (package_dbox_type(inst->info) == DBOX_TYPE_BUFFER) ? (inst->dbox.extra_buffer ? inst->dbox.extra_buffer[idx] : NULL) : NULL;
+}
+
+HAPI struct buffer_info *const instance_gbar_extra_buffer(const struct inst_info *inst, int idx)
+{
+       return (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) ? (inst->gbar.extra_buffer ? inst->gbar.extra_buffer[idx] : NULL) : NULL;
+}
+
 HAPI const char *const instance_id(const struct inst_info *inst)
 {
        return inst->id;
@@ -3226,6 +3326,90 @@ HAPI int instance_client_gbar_destroyed(struct inst_info *inst, int status)
        return send_gbar_destroyed_to_client(inst, status);
 }
 
+HAPI int instance_client_gbar_extra_buffer_created(struct inst_info *inst, int idx)
+{
+       struct packet *packet;
+       unsigned int cmd = CMD_GBAR_CREATE_XBUF;
+       int pixmap;
+
+       pixmap = buffer_handler_pixmap(inst->gbar.extra_buffer[idx]);
+       if (pixmap == 0) {
+               ErrPrint("Invalid buffer\n");
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
+       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+       if (!packet) {
+               ErrPrint("Failed to create a packet\n");
+               return DBOX_STATUS_ERROR_FAULT;
+       }
+
+       return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_gbar_extra_buffer_destroyed(struct inst_info *inst, int idx)
+{
+       struct packet *packet;
+       unsigned int cmd = CMD_GBAR_DESTROY_XBUF;
+       int pixmap;
+
+       pixmap = buffer_handler_pixmap(inst->gbar.extra_buffer[idx]);
+       if (pixmap == 0) {
+               ErrPrint("Invalid buffer\n");
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
+       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+       if (!packet) {
+               ErrPrint("Failed to create a packet\n");
+               return DBOX_STATUS_ERROR_FAULT;
+       }
+
+       return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_dbox_extra_buffer_created(struct inst_info *inst, int idx)
+{
+       struct packet *packet;
+       unsigned int cmd = CMD_DBOX_CREATE_XBUF;
+       int pixmap;
+
+       pixmap = buffer_handler_pixmap(inst->dbox.extra_buffer[idx]);
+       if (pixmap == 0) {
+               ErrPrint("Invalid buffer\n");
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
+       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+       if (!packet) {
+               ErrPrint("Failed to create a packet\n");
+               return DBOX_STATUS_ERROR_FAULT;
+       }
+
+       return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_dbox_extra_buffer_destroyed(struct inst_info *inst, int idx)
+{
+       struct packet *packet;
+       unsigned int cmd = CMD_DBOX_DESTROY_XBUF;
+       int pixmap;
+
+       pixmap = buffer_handler_pixmap(inst->dbox.extra_buffer[idx]);
+       if (pixmap == 0) {
+               ErrPrint("Invalid buffer\n");
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
+       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+       if (!packet) {
+               ErrPrint("Failed to create a packet\n");
+               return DBOX_STATUS_ERROR_FAULT;
+       }
+
+       return CLIENT_SEND_EVENT(inst, packet);
+}
+
 HAPI int instance_add_client(struct inst_info *inst, struct client_node *client)
 {
        if (inst->client == client) {
index 952cc08..e7081a6 100644 (file)
@@ -808,7 +808,7 @@ static struct packet *client_acquire(pid_t pid, int handle, const struct packet
        }
 
 out:
-       result = packet_create_reply(packet, "i", ret);
+       result = packet_create_reply(packet, "ii", ret, DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT);
        if (!result) {
                ErrPrint("Failed to create a packet\n");
        }
@@ -4771,6 +4771,76 @@ static int release_pixmap_cb(struct client_node *client, void *canvas)
        return -1; /* Delete this callback */
 }
 
+
+static struct packet *client_dbox_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+{
+       struct packet *result;
+       const char *pkgname;
+       const char *id;
+       struct client_node *client;
+       struct inst_info *inst;
+       int ret;
+       int pixmap = 0;
+       void *buf_ptr;
+       struct buffer_info *buffer;
+       int idx;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
+       if (ret != 3) {
+               ErrPrint("Parameter is not matched\n");
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               goto out;
+       }
+
+       if (idx >= DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
+               DbgPrint("Index is not valid: %d\n", idx);
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, NULL);
+       if (ret != DBOX_STATUS_ERROR_NONE) {
+               goto out;
+       }
+
+       buffer = instance_dbox_extra_buffer(inst, idx);
+       if (!buffer) {
+               ErrPrint("Extra buffer for %d is not available\n", idx);
+               goto out;
+       }
+
+       buf_ptr = buffer_handler_pixmap_ref(buffer);
+       if (!buf_ptr) {
+               ErrPrint("Failed to ref pixmap\n");
+               ret = DBOX_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
+       if (ret < 0) {
+               ErrPrint("Failed to add a new client deactivate callback\n");
+               buffer_handler_pixmap_unref(buf_ptr);
+       } else {
+               pixmap = buffer_handler_pixmap(buffer);
+               ret = DBOX_STATUS_ERROR_NONE;
+       }
+
+out:
+       result = packet_create_reply(packet, "ii", pixmap, ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
 static struct packet *client_dbox_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
 {
        struct packet *result;
@@ -4883,10 +4953,80 @@ static struct packet *client_dbox_release_pixmap(pid_t pid, int handle, const st
        }
 
 out:
-       /*! \note No reply packet */
+       /**
+        * @note No reply packet
+        */
        return NULL;
 }
 
+static struct packet *client_gbar_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+{
+       struct packet *result;
+       const char *pkgname;
+       const char *id;
+       struct client_node *client;
+       struct inst_info *inst;
+       int ret;
+       int pixmap = 0;
+       void *buf_ptr;
+       struct buffer_info *buffer;
+       int idx;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               ErrPrint("Client %d is not exists\n", pid);
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
+       if (ret != 3) {
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               ErrPrint("Parameter is not matched\n");
+               goto out;
+       }
+
+       if (idx >= DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, NULL);
+       if (ret != DBOX_STATUS_ERROR_NONE) {
+               goto out;
+       }
+
+       buffer = instance_gbar_extra_buffer(inst, idx);
+       if (!buffer) {
+               ret = DBOX_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       buf_ptr = buffer_handler_pixmap_ref(buffer);
+       if (!buf_ptr) {
+               ErrPrint("Failed to ref pixmap\n");
+               ret = DBOX_STATUS_ERROR_FAULT;
+               goto out;
+       }
+
+       ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
+       if (ret < 0) {
+               ErrPrint("Failed to add a new client deactivate callback\n");
+               buffer_handler_pixmap_unref(buf_ptr);
+       } else {
+               pixmap = buffer_handler_pixmap(buffer);
+               ret = DBOX_STATUS_ERROR_NONE;
+       }
+
+out:
+       result = packet_create_reply(packet, "ii", pixmap, ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
 static struct packet *client_gbar_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
 {
        struct packet *result;
@@ -6907,7 +7047,132 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p
 out:
        result = packet_create_reply(packet, "is", ret, id);
        if (!result) {
-               ErrPrint("Failed to create a packet\n");
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *slave_acquire_extra_buffer(pid_t pid, int handle, const struct packet *packet)
+{
+       struct slave_node *slave;
+       struct inst_info *inst;
+       struct packet *result;
+       const struct pkg_info *pkg;
+       const char *pkgname;
+       const char *id;
+       int pixel_size;
+       int target;
+       int idx;
+       int ret;
+       int w;
+       int h;
+
+       slave = slave_find_by_pid(pid);
+       if (!slave) {
+               ErrPrint("Slave %d is not exists\n", pid);
+               ret = DBOX_STATUS_ERROR_NOT_EXIST;
+               id = "";
+               goto out;
+       }
+
+       ret = packet_get(packet, "issiiii", &target, &pkgname, &id, &w, &h, &pixel_size, &idx);
+       if (ret != 7) {
+               ErrPrint("Invalid parameters\n");
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               id = "";
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       id = "";
+
+       if (ret != DBOX_STATUS_ERROR_NONE) {
+               goto out;
+       }
+
+       ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+
+       if (instance_state(inst) == INST_DESTROYED) {
+               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+               goto out;
+       }
+
+       if (target == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+               struct buffer_info *info;
+
+               info = instance_dbox_extra_buffer(inst, idx);
+               if (!info) {
+                       if (!instance_create_dbox_extra_buffer(inst, pixel_size, idx)) {
+                               ErrPrint("Failed to create a DBOX buffer\n");
+                               ret = DBOX_STATUS_ERROR_FAULT;
+                               goto out;
+                       }
+
+                       info = instance_dbox_extra_buffer(inst, idx);
+                       if (!info) {
+                               ErrPrint("DBOX extra buffer is not valid\n");
+                               /*!
+                                * \NOTE
+                                * ret value should not be changed.
+                                */
+                               goto out;
+                       }
+               }
+
+               ret = buffer_handler_resize(info, w, h);
+               ret = buffer_handler_load(info);
+               if (ret == 0) {
+                       /**
+                        * @todo
+                        * Send the extra buffer info to the viewer.
+                        * Then the viewer will try to acquire extra pixmap(aka, resource id) information
+                        */
+                       id = buffer_handler_id(info);
+                       (void)instance_client_dbox_extra_buffer_created(inst, idx);
+               } else {
+                       ErrPrint("Failed to load a buffer(%d)\n", ret);
+               }
+       } else if (target == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+               struct buffer_info *info;
+
+               info = instance_gbar_extra_buffer(inst, idx);
+               if (!info) {
+                       if (!instance_create_gbar_extra_buffer(inst, pixel_size, idx)) {
+                               ErrPrint("Failed to create a GBAR buffer\n");
+                               ret = DBOX_STATUS_ERROR_FAULT;
+                               goto out;
+                       }
+
+                       info = instance_gbar_extra_buffer(inst, idx);
+                       if (!info) {
+                               ErrPrint("GBAR buffer is not valid\n");
+                               /*!
+                                * \NOTE
+                                * ret value should not be changed.
+                                */
+                               goto out;
+                       }
+               }
+
+               ret = buffer_handler_resize(info, w, h);
+               ret = buffer_handler_load(info);
+               if (ret == 0) {
+                       id = buffer_handler_id(info);
+                       /**
+                        * @todo
+                        * Send the extra buffer acquired event to the viewer
+                        */
+                       (void)instance_client_gbar_extra_buffer_created(inst, idx);
+               } else {
+                       ErrPrint("Failed to load a buffer (%d)\n", ret);
+               }
+       }
+
+out:
+       result = packet_create_reply(packet, "is", ret, id);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
        }
 
        return result;
@@ -6944,6 +7209,7 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa
 
        ret = validate_request(pkgname, id, &inst, &pkg);
        id = "";
+
        if (ret != DBOX_STATUS_ERROR_NONE) {
                goto out;
        }
@@ -7048,8 +7314,8 @@ static struct packet *slave_release_buffer(pid_t pid, int handle, const struct p
                gbar_monitor = instance_del_data(inst, GBAR_CLOSE_MONITOR_TAG);
                if (!gbar_monitor && !package_is_fault(pkg)) {
                        ErrPrint("Slave requests to release a buffer\n");
-                       /*!
-                        * \note
+                       /**
+                        * @note
                         * In this case just keep going to release buffer,
                         * Even if a user(client) doesn't wants to destroy the GBAR.
                         *
@@ -7062,8 +7328,8 @@ static struct packet *slave_release_buffer(pid_t pid, int handle, const struct p
                         * which will be checked by instance_client_gbar_destroyed function.
                         */
 
-                       /*!
-                        * \note
+                       /**
+                        * @note
                         * provider can try to resize the buffer size.
                         * in that case, it will release the buffer first.
                         * Then even though the client doesn't request to close the GBAR,
@@ -7095,8 +7361,8 @@ static struct packet *slave_release_buffer(pid_t pid, int handle, const struct p
                        }
                } else {
                        if (gbar_monitor) {
-                               /*!
-                                * \note
+                               /**
+                                * @note
                                 * If the instance has gbar_monitor, the pd close requested from client via client_destroy_gbar.
                                 */
                                slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
@@ -7109,15 +7375,15 @@ static struct packet *slave_release_buffer(pid_t pid, int handle, const struct p
                                        goto out;
                                }
                        } /* else {
-                               \note
+                               @note
                                This case means that the package is faulted so the service provider tries to release the buffer
                        */
 
                        info = instance_gbar_buffer(inst);
                        ret = buffer_handler_unload(info);
 
-                       /*!
-                        * \note
+                       /**
+                        * @note
                         * Send the GBAR destroyed event to the client
                         */
                        instance_client_gbar_destroyed(inst, ret);
@@ -7133,6 +7399,60 @@ out:
        return result;
 }
 
+static struct packet *slave_release_extra_buffer(pid_t pid, int handle, const struct packet *packet)
+{
+       struct slave_node *slave;
+       struct packet *result;
+       const char *id;
+       struct buffer_info *info = NULL;
+       int ret;
+       int idx;
+       int type;
+       const char *pkgname;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+
+       slave = slave_find_by_pid(pid);
+       if (!slave) {
+               ErrPrint("Slave %d is not exists\n", pid);
+               ret = DBOX_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       if (packet_get(packet, "issi", &type, &pkgname, &id, &idx) != 4) {
+               ErrPrint("Inavlid argument\n");
+               ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != DBOX_STATUS_ERROR_NONE) {
+               goto out;
+       }
+
+       ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+
+       if (type == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+               info = instance_dbox_extra_buffer(inst, idx);
+               (void)instance_client_dbox_extra_buffer_destroyed(inst, idx);
+       } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+               info = instance_gbar_extra_buffer(inst, idx);
+               (void)instance_client_gbar_extra_buffer_destroyed(inst, idx);
+       }
+
+       if (info) {
+               ret = buffer_handler_unload(info);
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
 static struct packet *service_instance_count(pid_t pid, int handle, const struct packet *packet)
 {
        struct packet *result;
@@ -8148,6 +8468,14 @@ static struct method s_client_table[] = {
                .cmd = CMD_STR_CLIENT_RESUMED,
                .handler = client_resume_request,
        },
+       {
+               .cmd = CMD_STR_DBOX_ACQUIRE_XPIXMAP,
+               .handler = client_dbox_acquire_xpixmap,
+       },
+       {
+               .cmd = CMD_STR_GBAR_ACQUIRE_XPIXMAP,
+               .handler = client_gbar_acquire_xpixmap,
+       },
 
        {
                .cmd = NULL,
@@ -8264,6 +8592,15 @@ static struct method s_slave_table[] = {
        },
 
        {
+               .cmd = CMD_STR_ACQUIRE_XBUFFER,
+               .handler = slave_acquire_extra_buffer,
+       },
+       {
+               .cmd = CMD_STR_RELEASE_XBUFFER,
+               .handler = slave_release_extra_buffer,
+       },
+
+       {
                .cmd = NULL,
                .handler = NULL,
        },