Use the pixel_size and share it with service & viewer
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 5 Mar 2014 06:13:15 +0000 (15:13 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 5 Mar 2014 10:07:05 +0000 (19:07 +0900)
Change-Id: I9796f8c2dd98a5faee29be4ccad16ef23d33fe77

include/conf.h
include/instance.h
packaging/data-provider-master.spec
src/buffer_handler.c
src/conf.c
src/instance.c
src/script_handler.c
src/server.c

index db1bdeb..aab11d1 100755 (executable)
@@ -27,6 +27,7 @@ struct conf {
                char *abi;
                char *pd_group;
                double period;
+               int pixels;
        } default_conf;
 
        struct {
@@ -125,6 +126,7 @@ extern void conf_init(void);
 #define DEFAULT_ABI            g_conf.default_conf.abi
 #define DEFAULT_GROUP          g_conf.default_conf.pd_group
 #define DEFAULT_PERIOD         g_conf.default_conf.period
+#define DEFAULT_PIXELS         g_conf.default_conf.pixels
 #define PRIORITY_NO_CHANGE     -1.0f
 
 #define BUNDLE_SLAVE_NAME      g_conf.launch_key.name
index 27a0018..bb5d2d7 100644 (file)
@@ -202,8 +202,8 @@ extern const enum instance_state const instance_state(const struct inst_info *in
 extern int instance_unicast_created_event(struct inst_info *inst, struct client_node *client);
 extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client, int reason);
 
-extern int instance_create_lb_buffer(struct inst_info *inst);
-extern int instance_create_pd_buffer(struct inst_info *inst);
+extern int instance_create_lb_buffer(struct inst_info *inst, int pixels);
+extern int instance_create_pd_buffer(struct inst_info *inst, int pixels);
 
 extern void instance_slave_set_pd_pos(struct inst_info *inst, double x, double y);
 extern void instance_slave_get_pd_pos(struct inst_info *inst, double *x, double *y);
index 4a79924..0df5e7d 100755 (executable)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes
-Version: 0.34.5
+Version: 0.35.0
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index f82a3ee..c27eecf 100644 (file)
@@ -662,7 +662,7 @@ static inline int load_pixmap_buffer(struct buffer_info *info)
 
        gem = (struct gem_data *)buffer->data;
 
-       snprintf(info->id, len, SCHEMA_PIXMAP "%d", (int)gem->pixmap);
+       snprintf(info->id, len, SCHEMA_PIXMAP "%d:%d", (int)gem->pixmap, info->pixel_size);
        DbgPrint("Loaded pixmap(info->id): %s\n", info->id);
        return LB_STATUS_SUCCESS;
 }
@@ -768,14 +768,15 @@ static inline int unload_pixmap_buffer(struct buffer_info *info)
 {
        int id;
        char *new_id;
+       int pixels;
 
-       new_id = strdup(SCHEMA_PIXMAP "0");
+       new_id = strdup(SCHEMA_PIXMAP "0:0");
        if (!new_id) {
                ErrPrint("Heap: %s\n", strerror(errno));
                return LB_STATUS_ERROR_MEMORY;
        }
 
-       if (sscanf(info->id, SCHEMA_PIXMAP "%d", &id) != 1) {
+       if (sscanf(info->id, SCHEMA_PIXMAP "%d:%d", &id, &pixels) != 2) {
                ErrPrint("Invalid ID (%s)\n", info->id);
                DbgFree(new_id);
                return LB_STATUS_ERROR_INVALID;
@@ -1541,7 +1542,7 @@ static inline struct buffer *raw_open_pixmap(unsigned int pixmap)
 {
        struct buffer *buffer;
 
-       buffer = calloc(1, sizeof(*buffer) + sizeof(int));
+       buffer = calloc(1, sizeof(*buffer) + DEFAULT_PIXELS);
        if (!buffer) {
                ErrPrint("Heap: %s\n", strerror(errno));
                return NULL;
@@ -1708,6 +1709,11 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
 
        switch (type) {
        case BUFFER_TYPE_SHM:
+               if (pixel_size != DEFAULT_PIXELS) {
+                       DbgPrint("SHM only supportes %d bytes pixels (requested: %d)\n", DEFAULT_PIXELS, pixel_size);
+                       pixel_size = DEFAULT_PIXELS;
+               }
+
                info->id = strdup(SCHEMA_SHM "-1");
                if (!info->id) {
                        ErrPrint("Heap: %s\n", strerror(errno));
@@ -1716,6 +1722,11 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
                }
                break;
        case BUFFER_TYPE_FILE:
+               if (pixel_size != DEFAULT_PIXELS) {
+                       DbgPrint("FILE only supportes %d bytes pixels (requested: %d)\n", DEFAULT_PIXELS, pixel_size);
+                       pixel_size = DEFAULT_PIXELS;
+               }
+
                info->id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
                if (!info->id) {
                        ErrPrint("Heap: %s\n", strerror(errno));
@@ -1724,7 +1735,7 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
                }
                break;
        case BUFFER_TYPE_PIXMAP:
-               info->id = strdup(SCHEMA_PIXMAP "0");
+               info->id = strdup(SCHEMA_PIXMAP "0:0");
                if (!info->id) {
                        ErrPrint("Heap: %s\n", strerror(errno));
                        DbgFree(info);
index c9e78dc..35fcf72 100644 (file)
@@ -74,6 +74,7 @@ static const int CONF_DEFAULT_PREMULTIPLIED = 1;
 static const double CONF_DEFAULT_SCALE_WIDTH_FACTOR = 1.0f;
 static const double CONF_DEFAULT_SCALE_HEIGHT_FACTOR = 1.0f;
 static const double CONF_DEFAULT_PD_REQUEST_TIMEOUT = 5.0f;
+static const int CONF_DEFAULT_PIXELS = sizeof(int);
 
 HAPI struct conf g_conf;
 
@@ -156,6 +157,14 @@ static void minimum_period_handler(char *buffer)
        DbgPrint("Minimum period: %lf\n", g_conf.minimum_period);
 }
 
+static void pixels_handler(char *buffer)
+{
+       if (sscanf(buffer, "%d", &g_conf.default_conf.pixels) != 1) {
+               ErrPrint("Failed to parse the minimum_period\n");
+       }
+       DbgPrint("Default pixels: %lf\n", g_conf.default_conf.pixels);
+}
+
 static void script_handler(char *buffer)
 {
        g_conf.default_conf.script = strdup(buffer);
@@ -375,6 +384,7 @@ HAPI void conf_init(void)
        g_conf.base_height = CONF_DEFAULT_BASE_HEIGHT;
        g_conf.minimum_period = CONF_DEFAULT_MINIMUM_PERIOD;
        g_conf.default_conf.period = CONF_DEFAULT_PERIOD;
+       g_conf.default_conf.pixels = CONF_DEFAULT_PIXELS;
        g_conf.minimum_space = CONF_DEFAULT_MINIMUM_SPACE;
        g_conf.default_packet_time = CONF_DEFAULT_PACKET_TIME;
        g_conf.slave_ttl = CONF_DEFAULT_SLAVE_TTL;
@@ -461,6 +471,10 @@ HAPI int conf_loader(void)
                        .handler = script_handler,
                },
                {
+                       .name = "pixels",
+                       .handler = pixels_handler,
+               },
+               {
                        .name = "default_abi",
                        .handler = default_abi_handler,
                },
@@ -803,6 +817,7 @@ HAPI void conf_reset(void)
        g_conf.scale_height_factor = CONF_DEFAULT_SCALE_HEIGHT_FACTOR;
        g_conf.pd_request_timeout = CONF_DEFAULT_PD_REQUEST_TIMEOUT;
        g_conf.premultiplied = CONF_DEFAULT_PREMULTIPLIED;
+       g_conf.default_conf.pixels = CONF_DEFAULT_PIXELS;
 
        if (g_conf.default_conf.script != CONF_DEFAULT_SCRIPT_TYPE) {
                DbgFree(g_conf.default_conf.script);
index b739db3..513c0ea 100644 (file)
@@ -1208,7 +1208,7 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
                                        script_handler_load(inst->lb.canvas.script, 0);
                                }
                        } else if (package_lb_type(inst->info) == LB_TYPE_BUFFER) {
-                               instance_create_lb_buffer(inst);
+                               instance_create_lb_buffer(inst, DEFAULT_PIXELS);
                        }
 
                        if (package_pd_type(inst->info) == PD_TYPE_SCRIPT) {
@@ -1225,7 +1225,7 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
                                        ErrPrint("Failed to create PD\n");
                                }
                        } else if (package_pd_type(inst->info) == PD_TYPE_BUFFER) {
-                               instance_create_pd_buffer(inst);
+                               instance_create_pd_buffer(inst, DEFAULT_PIXELS);
                        }
 
                        instance_broadcast_created_event(inst);
@@ -1246,14 +1246,14 @@ out:
        instance_unref(inst);
 }
 
-HAPI int instance_create_pd_buffer(struct inst_info *inst)
+HAPI int instance_create_pd_buffer(struct inst_info *inst, int pixels)
 {
        if (inst->pd.width == 0 && inst->pd.height == 0) {
                instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info));
        }
 
        if (!inst->pd.canvas.buffer) {
-               inst->pd.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->pd.width, inst->pd.height, sizeof(int));
+               inst->pd.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->pd.width, inst->pd.height, pixels);
                if (!inst->pd.canvas.buffer) {
                        ErrPrint("Failed to create PD Buffer\n");
                }
@@ -1262,7 +1262,7 @@ HAPI int instance_create_pd_buffer(struct inst_info *inst)
        return !!inst->pd.canvas.buffer;
 }
 
-HAPI int instance_create_lb_buffer(struct inst_info *inst)
+HAPI int instance_create_lb_buffer(struct inst_info *inst, int pixels)
 {
        if (inst->lb.width == 0 && inst->lb.height == 0) {
                livebox_service_get_size(LB_SIZE_TYPE_1x1, &inst->lb.width, &inst->lb.height);
@@ -1274,7 +1274,7 @@ HAPI int instance_create_lb_buffer(struct inst_info *inst)
                 * Slave doesn't call the acquire_buffer.
                 * In this case, create the buffer from here.
                 */
-               inst->lb.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->lb.width, inst->lb.height, sizeof(int));
+               inst->lb.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->lb.width, inst->lb.height, pixels);
                if (!inst->lb.canvas.buffer) {
                        ErrPrint("Failed to create LB\n");
                }
index e07af65..0d973f8 100644 (file)
@@ -552,7 +552,7 @@ HAPI struct script_info *script_handler_create(struct inst_info *inst, const cha
                return NULL;
        }
 
-       info->buffer_handle = buffer_handler_create(inst, s_info.env_buf_type, w, h, sizeof(int));
+       info->buffer_handle = buffer_handler_create(inst, s_info.env_buf_type, w, h, DEFAULT_PIXELS);
        if (!info->buffer_handle) {
                /* buffer_handler_create will prints some log */
                DbgFree(info);
index 76a9cc2..1a336c7 100644 (file)
@@ -6589,7 +6589,7 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p
 
                info = instance_lb_buffer(inst);
                if (!info) {
-                       if (!instance_create_lb_buffer(inst)) {
+                       if (!instance_create_lb_buffer(inst, pixel_size)) {
                                ErrPrint("Failed to create a LB buffer\n");
                                ret = LB_STATUS_ERROR_FAULT;
                                goto out;
@@ -6645,7 +6645,7 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p
 
                info = instance_pd_buffer(inst);
                if (!info) {
-                       if (!instance_create_pd_buffer(inst)) {
+                       if (!instance_create_pd_buffer(inst, pixel_size)) {
                                ErrPrint("Failed to create a PD buffer\n");
                                ret = LB_STATUS_ERROR_FAULT;
                                instance_client_pd_created(inst, ret);