tethering: apply new debug channel 77/24677/1
authorKitae Kim <kt920.kim@samsung.com>
Fri, 18 Jul 2014 02:59:30 +0000 (11:59 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Fri, 18 Jul 2014 02:59:30 +0000 (11:59 +0900)
Change-Id: Idf659c6227ac38f126783a548564e034b2b45a32
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
tizen/src/tethering/common.c
tizen/src/tethering/encode_fb.c
tizen/src/tethering/sensor.c
tizen/src/tethering/touch.c

index 3b9333e..4497eb0 100644 (file)
@@ -47,9 +47,9 @@
 #include "ecs/ecs_tethering.h"
 #include "genmsg/tethering.pb-c.h"
 
-#include "debug_ch.h"
+#include "util/new_debug_ch.h"
 
-MULTI_DEBUG_CHANNEL(tizen, app_tethering);
+DECLARE_DEBUG_CHANNEL(app_tethering);
 
 #define TETHERING_MSG_HANDSHAKE_KEY     100
 #define MSG_BUF_SIZE    255
@@ -144,19 +144,19 @@ static void *build_tethering_msg(Tethering__TetheringMsg* msg, int *payloadsize)
     msg_packed_size = tethering__tethering_msg__get_packed_size(msg);
     *payloadsize = msg_packed_size + MSG_LEN_SIZE;
 
-    TRACE("create tethering_msg. msg_packed_size %d, payloadsize %d\n", msg_packed_size, *payloadsize);
+    LOG_TRACE("create tethering_msg. msg_packed_size %d, payloadsize %d\n", msg_packed_size, *payloadsize);
 
     buf = g_malloc(*payloadsize);
     if (!buf) {
-        ERR("failed to allocate memory\n");
+        LOG_SEVERE("failed to allocate memory\n");
         return NULL;
     }
 
     tethering__tethering_msg__pack(msg, buf + MSG_LEN_SIZE);
 
-    TRACE("msg_packed_size 1 %x\n", msg_packed_size);
+    LOG_TRACE("msg_packed_size 1 %x\n", msg_packed_size);
     msg_packed_size = htonl(msg_packed_size);
-    TRACE("msg_packed_size 2 %x\n", msg_packed_size);
+    LOG_TRACE("msg_packed_size 2 %x\n", msg_packed_size);
 
     memcpy(buf, &msg_packed_size, MSG_LEN_SIZE);
 
@@ -180,7 +180,7 @@ bool send_msg_to_controller(void *msg)
     }
 
     if (!tethering_client) {
-        ERR("TetheringState is NULL\n");
+        LOG_SEVERE("TetheringState is NULL\n");
         g_free(buf);
         return false;
     }
@@ -188,7 +188,7 @@ bool send_msg_to_controller(void *msg)
 
     total_buf_size = payload_size;
     do {
-        TRACE("sending a buffer as many as this size: %d\n", total_buf_size);
+        LOG_TRACE("sending a buffer as many as this size: %d\n", total_buf_size);
 
         sent_size =
             qemu_sendto(sockfd, buf + buf_offset, total_buf_size, 0, NULL, 0);
@@ -207,24 +207,24 @@ bool send_msg_to_controller(void *msg)
 
                 ret = select(sockfd + 1, NULL, &writefds, NULL, &timeout);
                 if (ret < 0) {
-                    INFO("not possible to send data\n");
+                    LOG_INFO("not possible to send data\n");
                     break;
                 }
-                TRACE("possible to send data\n");
+                LOG_TRACE("possible to send data\n");
                 continue;
             }
 
-            ERR("failed to send a message. sent_size: %d\n", sent_size);
+            LOG_SEVERE("failed to send a message. sent_size: %d\n", sent_size);
             ret = false;
             break;
         }
 
-        TRACE("sent size: %d\n", sent_size);
+        LOG_TRACE("sent size: %d\n", sent_size);
         buf_offset += sent_size;
         total_buf_size -= sent_size;
     } while (total_buf_size > 0);
 
-    TRACE("sent packets: %d, payload_size %d\n", (payload_size - total_buf_size), payload_size);
+    LOG_TRACE("sent packets: %d, payload_size %d\n", (payload_size - total_buf_size), payload_size);
     g_free(buf);
 
     return ret;
@@ -235,17 +235,17 @@ static bool send_handshake_req_msg(void)
     Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
     Tethering__HandShakeReq req = TETHERING__HAND_SHAKE_REQ__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     req.key = TETHERING_MSG_HANDSHAKE_KEY;
 
     msg.type = TETHERING__TETHERING_MSG__TYPE__HANDSHAKE_REQ;
     msg.handshakereq = &req;
 
-    TRACE("send handshake_req message\n");
+    LOG_TRACE("send handshake_req message\n");
     send_msg_to_controller(&msg);
 
-    TRACE("leave: %s\n", __func__);
+    LOG_TRACE("leave: %s\n", __func__);
 
     return true;
 }
@@ -255,17 +255,17 @@ static bool send_emul_state_msg(void)
     Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
     Tethering__EmulatorState emul_state = TETHERING__EMULATOR_STATE__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     emul_state.state = TETHERING__CONNECTION_STATE__DISCONNECTED;
 
     msg.type = TETHERING__TETHERING_MSG__TYPE__EMUL_STATE;
     msg.emulstate = &emul_state;
 
-    INFO("send emulator_state message\n");
+    LOG_INFO("send emulator_state message\n");
     send_msg_to_controller(&msg);
 
-    TRACE("leave: %s\n", __func__);
+    LOG_TRACE("leave: %s\n", __func__);
 
     return true;
 }
@@ -276,14 +276,14 @@ static bool build_event_msg(Tethering__EventMsg *event)
     bool ret = false;
     Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     msg.type = TETHERING__TETHERING_MSG__TYPE__EVENT_MSG;
     msg.eventmsg = event;
 
     ret = send_msg_to_controller(&msg);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -294,17 +294,17 @@ static bool send_event_start_ans_msg(Tethering__MessageResult result)
     Tethering__EventMsg event = TETHERING__EVENT_MSG__INIT;
     Tethering__StartAns start_ans = TETHERING__START_ANS__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     start_ans.result = result;
 
     event.type = TETHERING__EVENT_MSG__TYPE__START_ANS;
     event.startans = &start_ans;
 
-    TRACE("send event_start_ans message\n");
+    LOG_TRACE("send event_start_ans message\n");
     ret = build_event_msg(&event);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -316,7 +316,7 @@ static bool send_set_event_status_msg(Tethering__EventType event_type,
     Tethering__EventMsg event = TETHERING__EVENT_MSG__INIT;
     Tethering__SetEventStatus event_status = TETHERING__SET_EVENT_STATUS__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     event_status.type = event_type;
     event_status.state = status;
@@ -324,10 +324,10 @@ static bool send_set_event_status_msg(Tethering__EventType event_type,
     event.type = TETHERING__EVENT_MSG__TYPE__EVENT_STATUS;
     event.setstatus = &event_status;
 
-    TRACE("send event_set_event_status message\n");
+    LOG_TRACE("send event_set_event_status message\n");
     ret = build_event_msg(&event);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -344,7 +344,7 @@ static void msgproc_app_state_msg(Tethering__AppState *msg)
     int status = TETHERING__STATE__DISABLED;
 
     if (msg->state == TETHERING__CONNECTION_STATE__TERMINATED) {
-        INFO("app is terminated\n");
+        LOG_INFO("app is terminated\n");
 
         // set_tethering_app_state(false);
         set_tethering_sensor_status(status);
@@ -365,7 +365,7 @@ static bool msgproc_tethering_event_msg(Tethering__EventMsg *msg)
     {
         int touch_status = 0;
 
-        TRACE("EVENT_MSG_TYPE_START_REQ\n");
+        LOG_TRACE("EVENT_MSG_TYPE_START_REQ\n");
         send_set_event_status_msg(TETHERING__EVENT_TYPE__SENSOR,
                                 TETHERING__STATE__ENABLED);
 
@@ -382,17 +382,17 @@ static bool msgproc_tethering_event_msg(Tethering__EventMsg *msg)
         }
         set_tethering_touch_status(touch_status);
 
-        TRACE("send multi-touch event_status msg: %d\n", touch_status);
+        LOG_TRACE("send touch event_status msg: %d\n", touch_status);
         send_set_event_status_msg(TETHERING__EVENT_TYPE__TOUCH, touch_status);
 
-        TRACE("send event_start_ans msg: %d\n", touch_status);
+        LOG_TRACE("send event_start_ans msg: %d\n", touch_status);
         send_event_start_ans_msg(TETHERING__MESSAGE_RESULT__SUCCESS);
     }
         break;
     case TETHERING__EVENT_MSG__TYPE__TERMINATE:
         break;
     default:
-        TRACE("invalid event_msg type\n");
+        LOG_TRACE("invalid event_msg type\n");
         ret = false;
         break;
     }
@@ -409,7 +409,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
                                             (const uint8_t *)data);
 
     if (!tethering) {
-        ERR("no tethering massage\n");
+        LOG_SEVERE("no tethering massage\n");
         return false;
     }
 
@@ -422,7 +422,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
             ret = false;
         } else {
             msgproc_tethering_handshake_ans(msg);
-            TRACE("receive handshake answer\n");
+            LOG_TRACE("receive handshake answer\n");
 
             set_tethering_connection_status(CONNECTED);
         }
@@ -432,7 +432,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__AppState *msg = tethering->appstate;
 
-        TRACE("receive app_state msg\n");
+        LOG_TRACE("receive app_state msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -444,7 +444,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__EventMsg *msg = tethering->eventmsg;
 
-        TRACE("receive event_msg\n");
+        LOG_TRACE("receive event_msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -456,7 +456,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__SensorMsg *msg = tethering->sensormsg;
 
-        TRACE("receive sensor_msg\n");
+        LOG_TRACE("receive sensor_msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -468,7 +468,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__TouchMsg *msg = tethering->touchmsg;
 
-        TRACE("receive touch_msg\n");
+        LOG_TRACE("receive touch_msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -482,7 +482,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__DisplayMsg *msg = tethering->displaymsg;
 
-        TRACE("receive display_msg\n");
+        LOG_TRACE("receive display_msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -493,7 +493,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
 #endif
 
     default:
-        TRACE("invalid type message\n");
+        LOG_WARNING("invalid type message\n");
         ret = false;
         break;
     }
@@ -540,9 +540,9 @@ static void tethering_io_handler(void *opaque)
     to_read_bytes = (int)to_read_bytes_long;
 #endif
 
-    TRACE("ioctl: ret: %d, FIONREAD: %d\n", ret, to_read_bytes);
+    LOG_TRACE("ioctl: ret: %d, FIONREAD: %d\n", ret, to_read_bytes);
     if (to_read_bytes == 0) {
-        INFO("there is no read data\n");
+        LOG_INFO("there is no read data\n");
         disconnect_tethering_app();
         return;
     }
@@ -555,11 +555,11 @@ static void tethering_io_handler(void *opaque)
         }
 
         payloadsize = ntohl(payloadsize);
-        TRACE("payload size: %d\n", payloadsize);
+        LOG_TRACE("payload size: %d\n", payloadsize);
 
 #if 0
         if (payloadsize > to_read_bytes) {
-            TRACE("invalid payload size: %d\n", payloadsize);
+            LOG_TRACE("invalid payload size: %d\n", payloadsize);
             return;
         }
 #endif
@@ -577,7 +577,7 @@ static void tethering_io_handler(void *opaque)
         qemu_recv(sockfd, (char *)(recv_buf.data + recv_buf.stack_size),
                     to_read_bytes, 0);
     if (read_size == 0) {
-        ERR("failed to read data\n");
+        LOG_SEVERE("failed to read data\n");
         disconnect_tethering_app();
         return;
     }
@@ -618,21 +618,21 @@ static int start_tethering_socket(const char *ipaddress, int port)
         g_strlcpy(serveraddr, ipaddress, sizeof(serveraddr));
     }
 
-    INFO("server ip address: %s, port: %d\n", serveraddr, port);
+    LOG_INFO("server ip address: %s, port: %d\n", serveraddr, port);
     ret = inet_aton(serveraddr, &addr.sin_addr);
 
     if (ret == 0) {
-        ERR("inet_aton failure\n");
+        LOG_SEVERE("inet_aton failure\n");
         return -1;
     }
 
     sock = qemu_socket(PF_INET, SOCK_STREAM, 0);
     if (sock < 0) {
         // set_tethering_connection_status(DISCONNECTED);
-        ERR("tethering socket creation is failed\n", sock);
+        LOG_SEVERE("tethering socket creation is failed\n", sock);
         return -1;
     }
-    INFO("tethering socket is created: %d\n", sock);
+    LOG_INFO("tethering socket is created: %d\n", sock);
 
     qemu_set_nonblock(sock);
 
@@ -642,20 +642,20 @@ static int start_tethering_socket(const char *ipaddress, int port)
             perror("connect failure");
             ret = -socket_error();
         } else {
-            INFO("tethering socket is connected.\n");
+            LOG_INFO("tethering socket is connected.\n");
             ret = 0;
             // set_tethering_app_state(true);
             break;
         }
-        TRACE("ret: %d\n", ret);
+        LOG_TRACE("ret: %d\n", ret);
     } while (ret == -EINPROGRESS);
 
     if (ret < 0 && ret != -EISCONN) {
         if (ret == -ECONNREFUSED) {
-            INFO("socket connection is refused\n");
+            LOG_INFO("socket connection is refused\n");
             set_tethering_connection_status(CONNREFUSED);
         }
-        INFO("close socket\n");
+        LOG_TRACE("close socket\n");
         end_tethering_socket(sock);
         sock = -1;
     }
@@ -674,7 +674,7 @@ static void end_tethering_socket(int sockfd)
 
     tethering_client->fd = -1;
 
-    INFO("close tethering socket\n");
+    LOG_INFO("close tethering socket\n");
     set_tethering_connection_status(DISCONNECTED);
     set_tethering_sensor_status(status);
     set_tethering_touch_status(status);
@@ -683,7 +683,7 @@ static void end_tethering_socket(int sockfd)
 #if 0
 static void set_tethering_app_state(bool state)
 {
-    TRACE("set tethering_app state: %d", state);
+    LOG_TRACE("set tethering_app state: %d", state);
     app_state = state;
 }
 
@@ -722,7 +722,9 @@ static void set_tethering_connection_status(int status)
     send_tethering_connection_status_ecp();
 }
 
-static void tethering_notify_exit(Notifier *notifier, void *data) {
+static void tethering_notify_exit(Notifier *notifier, void *data)
+{
+    LOG_INFO("tethering_notify_exit\n");
     disconnect_tethering_app();
 }
 static Notifier tethering_exit = { .notify = tethering_notify_exit };
@@ -772,25 +774,19 @@ int disconnect_tethering_app(void)
 {
     int sock = 0;
 
-    INFO("disconnect app from ecp\n");
+    LOG_TRACE("disconnect app from ecp\n");
     if (!tethering_client) {
+        LOG_SEVERE("tethering client instance is NULL\n");
         return -1;
     }
 
     sock = tethering_client->fd;
     if (sock < 0) {
-        ERR("tethering socket is terminated or not ready\n");
+        LOG_SEVERE("tethering socket is terminated or not ready\n");
+        return -1;
     } else {
-        // destroy_tethering_io_handler(sock);
-#if 0
-        if (get_tethering_app_state()) {
-            send_emul_state_msg();
-        }
-#endif
         send_emul_state_msg();
-
         end_tethering_socket(sock);
-        // release_tethering_thread(tethering_client);
     }
 
     return 0;
@@ -809,10 +805,10 @@ static int tethering_loop(int sockfd)
     timeout.tv_usec = 0;
 
     ret = select(sockfd + 1, &readfds, NULL, NULL, &timeout);
-    TRACE("select timeout! result: %d\n", ret);
+    LOG_TRACE("select timeout! result: %d\n", ret);
 
     if (ret > 0) {
-        TRACE("ready for read operation!!\n");
+        LOG_TRACE("ready for read operation!!\n");
         tethering_io_handler(socket);
     }
 
@@ -821,22 +817,21 @@ static int tethering_loop(int sockfd)
 
 static void *initialize_tethering_socket(void *opaque)
 {
-    TetheringState *socket = (TetheringState *)opaque;
-    TRACE("callback function for tethering_thread\n");
+    TetheringState *client = (TetheringState *)opaque;
+    LOG_TRACE("callback function for tethering_thread\n");
 
-    if (!socket) {
-        ERR("TetheringState is NULL\n");
+    if (!client) {
+        LOG_SEVERE("TetheringState is NULL\n");
         return NULL;
     }
 
-    socket->fd = start_tethering_socket(socket->ipaddress, socket->port);
-    if (socket->fd < 0) {
-        ERR("failed to start tethering_socket\n");
+    client->fd = start_tethering_socket(client->ipaddress, client->port);
+    if (client->fd < 0) {
+        LOG_SEVERE("failed to start tethering_socket\n");
         // tethering_sock = -1;
         return NULL;
     }
-
-    INFO("tethering_sock: %d\n", socket->fd);
+    LOG_TRACE("tethering_sock: %d\n", client->fd);
 
     reset_tethering_recv_buf(&recv_buf);
     send_handshake_req_msg();
@@ -844,18 +839,18 @@ static void *initialize_tethering_socket(void *opaque)
     emulator_add_exit_notifier(&tethering_exit);
 
     while (1) {
-        qemu_mutex_lock(&socket->mutex);
-        if (socket->status == DISCONNECTED) {
-            qemu_mutex_unlock(&socket->mutex);
-            INFO("disconnected socket. destroy this thread\n");
+        qemu_mutex_lock(&client->mutex);
+        if (client->status == DISCONNECTED) {
+            qemu_mutex_unlock(&client->mutex);
+            LOG_INFO("disconnected socket. destroy this thread\n");
             break;
         }
-        qemu_mutex_unlock(&socket->mutex);
+        qemu_mutex_unlock(&client->mutex);
 
-        tethering_loop(socket->fd);
+        tethering_loop(client->fd);
     }
 
-    return socket;
+    return client;
 }
 
 #if 0
index a8f4603..eb90c31 100644 (file)
@@ -36,9 +36,9 @@
 #include "emul_state.h"
 #include "skin/maruskin_operation.h"
 #include "encode_fb.h"
-#include "debug_ch.h"
+#include "util/new_debug_ch.h"
 
-MULTI_DEBUG_CHANNEL(tizen, app_tethering);
+DECLARE_DEBUG_CHANNEL(app_tethering);
 
 #ifdef CONFIG_WEBP
 static void *encode_webp(void);
@@ -68,7 +68,7 @@ void *encode_framebuffer(int encoder)
 #if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG)
     clock_gettime(CLOCK_MONOTONIC, &end);
 
-    INFO("encoding time: %.5f seconds\n",
+    LOG_TRACE("encoding time: %.5f seconds\n",
         ((double)end.tv_sec + (1.0e-9 * end.tv_nsec)) -
         ((double)start.tv_sec + (1.0e-9 * start.tv_nsec)));
 #endif
@@ -88,7 +88,7 @@ static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t len)
     }
 
     if (!p->buffer) {
-        ERR("failed to allocate \n");
+        LOG_SEVERE("failed to allocate \n");
     }
 
     memcpy(p->buffer + p->length, data, len);
@@ -118,7 +118,7 @@ static void *encode_png(void)
 
     surface = request_screenshot();
     if (!surface) {
-        ERR("failed to get framebuffer\n");
+        LOG_SEVERE("failed to get framebuffer\n");
         return NULL;
     }
 
@@ -126,31 +126,31 @@ static void *encode_png(void)
     height = get_emul_resolution_height();
 
     image_stride = width * 4;
-    TRACE("width %d, height %d, stride %d, raw image %d\n",
+    LOG_TRACE("width %d, height %d, stride %d, raw image %d\n",
         width, height, image_stride, (image_stride * height));
 
-    TRACE("png_create_write_struct\n");
+    LOG_TRACE("png_create_write_struct\n");
     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
     if (!png_ptr) {
-        ERR("png_create_write_struct failure\n");
+        LOG_SEVERE("png_create_write_struct failure\n");
         g_free(surface->data);
         g_free(surface);
         return NULL;
     }
 
-    TRACE("png_create_info_struct\n");
+    LOG_TRACE("png_create_info_struct\n");
     info_ptr = png_create_info_struct(png_ptr);
     if (!png_ptr) {
-        ERR("png_create_info_struct failure\n");
+        LOG_SEVERE("png_create_info_struct failure\n");
         g_free(surface->data);
         g_free(surface);
         png_destroy_write_struct(&png_ptr, &info_ptr);
         return NULL;
     }
 
-    TRACE("try png_jmpbuf\n");
+    LOG_TRACE("try png_jmpbuf\n");
     if (setjmp(png_jmpbuf(png_ptr))) {
-        ERR("png_jmpbuf failure\n");
+        LOG_SEVERE("png_jmpbuf failure\n");
         g_free(surface->data);
         g_free(surface);
         png_destroy_write_struct(&png_ptr, &info_ptr);
@@ -158,10 +158,10 @@ static void *encode_png(void)
         return NULL;
     }
 
-    TRACE("png_init_io\n");
+    LOG_TRACE("png_init_io\n");
     container = g_malloc(sizeof(struct encode_mem));
     if (!container) {
-        ERR("failed to allocate encode_mem\n");
+        LOG_SEVERE("failed to allocate encode_mem\n");
         g_free(surface->data);
         g_free(surface);
         png_destroy_write_struct(&png_ptr, &info_ptr);
@@ -188,7 +188,7 @@ static void *encode_png(void)
 
     row_pointers = png_malloc(png_ptr, sizeof(png_bytep) * height);
     if (row_pointers == NULL) {
-        ERR("failed to allocate png memory\n");
+        LOG_SEVERE("failed to allocate png memory\n");
         g_free(surface->data);
         g_free(surface);
         png_destroy_write_struct(&png_ptr, &info_ptr);
@@ -200,16 +200,16 @@ static void *encode_png(void)
         row_pointers[row_index] = surface->data + (row_index * image_stride);
     }
 
-    TRACE("png_write_image\n");
+    LOG_TRACE("png_write_image\n");
     png_write_image(png_ptr, row_pointers);
 
-    TRACE("png_write_end\n");
+    LOG_TRACE("png_write_end\n");
     png_write_end(png_ptr, info_ptr);
 
     g_free(surface->data);
     g_free(surface);
 
-    TRACE("png image size %d\n", container->length);
+    LOG_TRACE("png image size %d\n", container->length);
     png_destroy_write_struct(&png_ptr, &info_ptr);
     png_destroy_info_struct(png_ptr, &info_ptr);
 
@@ -228,7 +228,7 @@ static void *encode_webp(void)
 
     container = g_malloc(sizeof(struct encode_mem));
     if (!container) {
-        ERR("failed to allocate encode_mem\n");
+        LOG_SEVERE("failed to allocate encode_mem\n");
         return NULL;
     }
 
@@ -237,7 +237,7 @@ static void *encode_webp(void)
 
     surface = request_screenshot();
     if (!surface) {
-        ERR("failed to get framebuffer\n");
+        LOG_SEVERE("failed to get framebuffer\n");
         g_free(container);
         return NULL;
     }
@@ -246,12 +246,12 @@ static void *encode_webp(void)
     height = get_emul_resolution_height();
 
     image_stride = width * 4;
-    TRACE("width %d, height %d, stride %d, raw image %d\n",
+    LOG_TRACE("width %d, height %d, stride %d, raw image %d\n",
         width, height, image_stride, (image_stride * height));
 
     ret = WebPEncodeLosslessBGRA((const uint8_t *)surface->data, width,
             height, image_stride, &container->buffer);
-    TRACE("lossless encode framebuffer via webp. result %zu\n", ret);
+    LOG_TRACE("lossless encode framebuffer via webp. result %zu\n", ret);
 
     container->length = (int)ret;
 
index 43f7a0a..74d0fb9 100644 (file)
@@ -48,9 +48,9 @@
 #include "ecs/ecs_tethering.h"
 #include "genmsg/tethering.pb-c.h"
 
-#include "debug_ch.h"
+#include "util/new_debug_ch.h"
 
-MULTI_DEBUG_CHANNEL(tizen, app_tethering);
+DECLARE_DEBUG_CHANNEL(app_tethering);
 
 typedef struct sensor_state {
     bool is_sensor_event;
@@ -105,14 +105,14 @@ static bool build_sensor_msg(Tethering__SensorMsg *sensor)
     bool ret = false;
     Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     msg.type = TETHERING__TETHERING_MSG__TYPE__SENSOR_MSG;
     msg.sensormsg = sensor;
 
     ret = send_msg_to_controller(&msg);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -123,17 +123,17 @@ static bool send_sensor_start_ans_msg(Tethering__MessageResult result)
     Tethering__SensorMsg event = TETHERING__SENSOR_MSG__INIT;
     Tethering__StartAns start_ans = TETHERING__START_ANS__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     start_ans.result = result;
 
     event.type = TETHERING__SENSOR_MSG__TYPE__START_ANS;
     event.startans = &start_ans;
 
-    TRACE("send sensor_start_ans message\n");
+    LOG_TRACE("send sensor_start_ans message\n");
     ret = build_sensor_msg(&event);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -147,7 +147,7 @@ static bool send_set_sensor_status_msg(Tethering__SensorType sensor_type,
     Tethering__SetSensorStatus sensor_status =
                             TETHERING__SET_SENSOR_STATUS__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     sensor_status.type = sensor_type;
     sensor_status.state = status;
@@ -155,10 +155,10 @@ static bool send_set_sensor_status_msg(Tethering__SensorType sensor_type,
     sensor.type = TETHERING__SENSOR_MSG__TYPE__SENSOR_STATUS;
     sensor.setstatus = &sensor_status;
 
-    TRACE("send sensor_set_event_status message\n");
+    LOG_TRACE("send sensor_set_event_status message\n");
     ret = build_sensor_msg(&sensor);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -181,7 +181,7 @@ static void set_sensor_data(Tethering__SensorData *data)
                 level_accel, 3, data->x, data->y, data->z);
         send_tethering_sensor_data(tmp, strlen(tmp));
 
-        TRACE("sensor_accel x: %s, y: %s, z: %s\n",
+        LOG_TRACE("sensor_accel x: %s, y: %s, z: %s\n",
             data->x, data->y, data->z);
     }
         break;
@@ -193,7 +193,7 @@ static void set_sensor_data(Tethering__SensorData *data)
                 level_magnetic, 3, data->x, data->y, data->z);
         send_tethering_sensor_data(tmp, strlen(tmp));
 
-        TRACE("sensor_mag x: %s, y: %s, z: %s\n",
+        LOG_TRACE("sensor_mag x: %s, y: %s, z: %s\n",
             data->x, data->y, data->z);
     }
         break;
@@ -205,7 +205,7 @@ static void set_sensor_data(Tethering__SensorData *data)
                 level_gyro, 3, data->x, data->y, data->z);
         send_tethering_sensor_data(tmp, strlen(tmp));
 
-        TRACE("sensor_gyro x: %s, y: %s, z: %s\n",
+        LOG_TRACE("sensor_gyro x: %s, y: %s, z: %s\n",
             data->x, data->y, data->z);
     }
         break;
@@ -217,7 +217,7 @@ static void set_sensor_data(Tethering__SensorData *data)
         sprintf(tmp, "%d\n%d\n%.1f\n", level_proxi, 1, x);
         send_tethering_sensor_data(tmp, strlen(tmp));
 
-        TRACE("sensor_proxi x: %.1f, %s\n", x, tmp);
+        LOG_TRACE("sensor_proxi x: %.1f, %s\n", x, tmp);
     }
         break;
     case TETHERING__SENSOR_TYPE__LIGHT:
@@ -227,11 +227,11 @@ static void set_sensor_data(Tethering__SensorData *data)
         sprintf(tmp, "%d\n%d\n%s%s\n", level_light, 2, data->x, data->y);
         send_tethering_sensor_data(tmp, strlen(tmp));
 
-        TRACE("sensor_light x: %s\n", data->x);
+        LOG_TRACE("sensor_light x: %s\n", data->x);
     }
         break;
     default:
-        TRACE("invalid sensor data\n");
+        LOG_TRACE("invalid sensor data\n");
         break;
     }
 }
@@ -243,7 +243,7 @@ bool msgproc_tethering_sensor_msg(void *message)
 
     switch(msg->type) {
     case TETHERING__SENSOR_MSG__TYPE__START_REQ:
-        TRACE("SENSOR_MSG_TYPE_START_REQ\n");
+        LOG_TRACE("SENSOR_MSG_TYPE_START_REQ\n");
 
         // TODO
         // init_sensor_state();
@@ -260,20 +260,20 @@ bool msgproc_tethering_sensor_msg(void *message)
         send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__LIGHT,
                                 TETHERING__STATE__ENABLED);
 
-        TRACE("SENSOR_MSG_TYPE_START_ANS\n");
+        LOG_TRACE("SENSOR_MSG_TYPE_START_ANS\n");
         send_sensor_start_ans_msg(TETHERING__MESSAGE_RESULT__SUCCESS);
 
         break;
     case TETHERING__SENSOR_MSG__TYPE__TERMINATE:
-        TRACE("SENSOR_MSG_TYPE_TERMINATE\n");
+        LOG_TRACE("SENSOR_MSG_TYPE_TERMINATE\n");
         break;
 
     case TETHERING__SENSOR_MSG__TYPE__SENSOR_DATA:
-        TRACE("SENSOR_MSG_TYPE_SENSOR_DATA\n");
+        LOG_TRACE("SENSOR_MSG_TYPE_SENSOR_DATA\n");
         set_sensor_data(msg->data);
         break;
     default:
-        TRACE("invalid sensor_msg type");
+        LOG_TRACE("invalid sensor_msg type");
         ret = false;
         break;
     }
index 296b656..845500a 100644 (file)
 #include "touch.h"
 #include "genmsg/tethering.pb-c.h"
 #include "ecs/ecs_tethering.h"
-#include "debug_ch.h"
+#include "util/new_debug_ch.h"
 
-MULTI_DEBUG_CHANNEL(tizen, app_tethering);
+DECLARE_DEBUG_CHANNEL(app_tethering);
 
 typedef struct touch_state {
     bool is_touch_event;
     bool is_touch_supported;
 
     // int touch_max_point;
-
     // display_state *display;
 } touch_event;
 
@@ -98,15 +97,15 @@ static bool build_touch_msg(Tethering__TouchMsg *touch)
     bool ret = false;
     Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     msg.type = TETHERING__TETHERING_MSG__TYPE__TOUCH_MSG;
     msg.touchmsg = touch;
 
-    TRACE("touch message size: %d\n", tethering__tethering_msg__get_packed_size(&msg));
+    LOG_TRACE("touch message size: %d\n", tethering__tethering_msg__get_packed_size(&msg));
     ret = send_msg_to_controller(&msg);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -118,7 +117,7 @@ static bool send_touch_start_ans_msg(Tethering__MessageResult result)
     Tethering__TouchMsg mt = TETHERING__TOUCH_MSG__INIT;
     Tethering__StartAns start_ans = TETHERING__START_ANS__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     start_ans.result = result;
 
@@ -127,7 +126,7 @@ static bool send_touch_start_ans_msg(Tethering__MessageResult result)
 
     ret = build_touch_msg(&mt);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -140,17 +139,17 @@ static bool send_set_touch_max_count(void)
     Tethering__TouchMaxCount touch_cnt =
         TETHERING__TOUCH_MAX_COUNT__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     touch_cnt.max = get_emul_max_touch_point();
 
     mt.type = TETHERING__TOUCH_MSG__TYPE__MAX_COUNT;
     mt.maxcount = &touch_cnt;
 
-    TRACE("send touch max count: %d\n", touch_cnt.max);
+    LOG_TRACE("send touch max count: %d\n", touch_cnt.max);
     ret = build_touch_msg(&mt);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -162,25 +161,25 @@ static void set_touch_data(Tethering__TouchData *data)
 
     switch(data->state) {
     case TETHERING__TOUCH_STATE__PRESSED:
-        TRACE("touch pressed\n");
+        LOG_TRACE("touch pressed\n");
         index = data->index;
         x = data->xpoint;
         y = data->ypoint;
         state = PRESSED;
         break;
     case TETHERING__TOUCH_STATE__RELEASED:
-        TRACE("touch released\n");
+        LOG_TRACE("touch released\n");
         index = data->index;
         x = data->xpoint;
         y = data->ypoint;
         state = RELEASED;
         break;
     default:
-        TRACE("invalid touch data\n");
+        LOG_TRACE("invalid touch data\n");
         break;
     }
 
-    TRACE("set touch_data. index: %d, x: %lf, y: %lf\n", index, x, y);
+    LOG_TRACE("set touch_data. index: %d, x: %lf, y: %lf\n", index, x, y);
     send_tethering_touch_data(x, y, index, state);
 }
 
@@ -191,7 +190,7 @@ static bool send_set_touch_resolution(void)
     Tethering__TouchMsg mt = TETHERING__TOUCH_MSG__INIT;
     Tethering__Resolution resolution = TETHERING__RESOLUTION__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     resolution.width = get_emul_resolution_width();
     resolution.height = get_emul_resolution_height();
@@ -199,11 +198,11 @@ static bool send_set_touch_resolution(void)
     mt.type = TETHERING__TOUCH_MSG__TYPE__RESOLUTION;
     mt.resolution = &resolution;
 
-    TRACE("send touch resolution: %dx%d\n",
+    LOG_TRACE("send touch resolution: %dx%d\n",
         resolution.width, resolution.height);
     ret = build_touch_msg(&mt);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
 
     return ret;
 }
@@ -213,7 +212,7 @@ static void set_touch_event_status(bool status)
 {
     is_touch_event = status;
 
-    INFO("set touch_event status: %d\n", status);
+    LOG_TRACE("set touch_event status: %d\n", status);
 }
 
 static void set_hwkey_data(Tethering__HWKeyMsg *msg)
@@ -246,10 +245,10 @@ static void set_hwkey_data(Tethering__HWKeyMsg *msg)
         break;
 
     default:
-        INFO("undefined type: %d\n", msg->type);
+        LOG_WARNING("undefined type: %d\n", msg->type);
     }
 
-    INFO("convert hwkey msg to keycode: %d\n", keycode);
+    LOG_TRACE("convert hwkey msg to keycode: %d\n", keycode);
     send_tethering_hwkey_data(keycode);
 }
 #endif
@@ -264,7 +263,7 @@ bool msgproc_tethering_touch_msg(void *message)
 
     switch(msg->type) {
     case TETHERING__TOUCH_MSG__TYPE__START_REQ:
-        TRACE("TOUCH_MSG_TYPE_START\n");
+        LOG_TRACE("TOUCH_MSG_TYPE_START\n");
         // state = init_touch_state();
 
         // it means that app starts to send touch values.
@@ -276,7 +275,7 @@ bool msgproc_tethering_touch_msg(void *message)
         ret = send_touch_start_ans_msg(TETHERING__MESSAGE_RESULT__SUCCESS);
         break;
     case TETHERING__TOUCH_MSG__TYPE__TERMINATE:
-        TRACE("TOUCH_MSG_TYPE_TERMINATE\n");
+        LOG_TRACE("TOUCH_MSG_TYPE_TERMINATE\n");
 
         // it means that app stops to send touch values.
         // set_touch_event_status(false);
@@ -296,7 +295,7 @@ bool msgproc_tethering_touch_msg(void *message)
         break;
 #endif
     default:
-        TRACE("invalid touch_msg\n");
+        LOG_TRACE("invalid touch_msg\n");
         ret = false;
         break;
     }
@@ -323,15 +322,15 @@ static bool send_display_image_data(void)
     Tethering__TouchMsg touch = TETHERING__TOUCH_MSG__INIT;
     Tethering__DisplayMsg display = TETHERING__DISPLAY_MSG__INIT;
 
-    TRACE("enter: %s\n", __func__);
+    LOG_TRACE("enter: %s\n", __func__);
 
     image = (struct encode_mem *)encode_framebuffer(ENCODE_WEBP);
     if (!image) {
-        ERR("failed to encode framebuffer\n");
+        LOG_SEVERE("failed to encode framebuffer\n");
         return false;
     }
 
-    TRACE("image data size %d\n", image->length);
+    LOG_TRACE("image data size %d\n", image->length);
     display.has_imagedata = true;
     display.imagedata.len = image->length;
     display.imagedata.data = image->buffer;
@@ -353,11 +352,11 @@ static bool send_display_image_data(void)
 
     // ret = build_display_msg(&display);
     ret = build_touch_msg(&touch);
-    INFO("send display message: %d\n", ret);
+    LOG_TRACE("send display message: %d\n", ret);
 
     g_free(image->buffer);
     g_free(image);
 
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    LOG_TRACE("leave: %s, ret: %d\n", __func__, ret);
     return ret;
 }