Add timer call for live service pause 64/45864/1
authorjinwoo.shin <jw0227.shin@samsung.com>
Wed, 12 Aug 2015 05:31:56 +0000 (14:31 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Wed, 12 Aug 2015 05:31:56 +0000 (14:31 +0900)
Change-Id: I98902148dcb481e7ec29909224db65969e8c0a96
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
src/main.c

index 6616c90..e7c444b 100644 (file)
@@ -28,6 +28,7 @@
 #include "view.h"
 
 #define KEY_MAX 256
+#define PAUSE_WAIT_TIME 0.5
 
 SET_TAG(PACKAGE)
 
@@ -38,6 +39,7 @@ struct _appdata {
        Ecore_Event_Handler *key_up;
        tzsh_h tzsh;
        tzsh_tvsrv_h ta;
+       Ecore_Timer *pause_timer;
 
        int is_signal;
        int is_channel;
@@ -201,13 +203,39 @@ static void _tv_signal_cb(void *data, int is_signal)
        }
 }
 
-static void _pause(void *data)
+Eina_Bool _tv_pause(void *data)
 {
+       struct _appdata *ad;
        int r;
 
+       if (!data) {
+               _ERR("failed to get data");
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       ad = data;
+
        r = tv_pause();
        if (r < 0)
                _ERR("Pause tv service failed");
+
+       ad->pause_timer = NULL;
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
+static void _pause(void *data)
+{
+       struct _appdata *ad;
+
+       if (!data) {
+               _ERR("failed to get data");
+               return;
+       }
+
+       ad = data;
+
+       ad->pause_timer = ecore_timer_add(PAUSE_WAIT_TIME, _tv_pause, ad);
 }
 
 static void _resume(void *data)
@@ -222,6 +250,11 @@ static void _resume(void *data)
 
        ad = data;
 
+       if (ad->pause_timer) {
+               ecore_timer_del(ad->pause_timer);
+               ad->pause_timer = NULL;
+       }
+
        r = tv_resume();
        if (r < 0) {
                _ERR("Resume tv service failed");
@@ -233,9 +266,6 @@ static void _resume(void *data)
                        return;
                }
        }
-
-       if (ad->win)
-               elm_win_activate(ad->win);
 }
 
 static bool _create(void *data)
@@ -313,6 +343,11 @@ static void _terminate(void *data)
 
        ad = data;
 
+       if (ad->pause_timer) {
+               ecore_timer_del(ad->pause_timer);
+               ad->pause_timer = NULL;
+       }
+
        if (ad->win) {
                tv_destroy();
 
@@ -369,7 +404,6 @@ static void _control(app_control_h control, void *data)
                viewmgr_update_view(VIEW_ERROR, UPDATE_TYPE_NOCHANNEL, NULL);
        } else {
                ad->is_channel = true;
-               viewmgr_show_view(VIEW_CHANNELINFO);
        }
 }