From 06811238a1d809eab17b65be1ecdb7a114d5aee7 Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Thu, 17 Mar 2016 11:44:56 +0200 Subject: [PATCH] Recording: stop recording consecutive duplicates events A lot of events caught by Exactness preload are repeated with the same information, such as mouse move on the same coordinates and with the same timestamp. This adds a lot of noise into the recording file. This patch checks if the current caught event is the same as the last stored and skips it if they are the same. --- src/lib/tsuite_evas_hook.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/lib/tsuite_evas_hook.c b/src/lib/tsuite_evas_hook.c index 288cea1..a53d44c 100644 --- a/src/lib/tsuite_evas_hook.c +++ b/src/lib/tsuite_evas_hook.c @@ -588,7 +588,7 @@ tsuite_feed_event(void *data) current_event_time = td->recent_event_time; #ifdef DEBUG_TSUITE - printf("%s td->recent_event_time=<%u> current_event_time=<%u>\n", __func__, td->recent_event_time, current_event_time); + printf(" %s td->recent_event_time=<%u> current_event_time=<%u>\n", __func__, td->recent_event_time, current_event_time); #endif timer_time = (current_event_time - td->recent_event_time) / 1000.0; @@ -596,7 +596,7 @@ tsuite_feed_event(void *data) timer_time = 0.0; #ifdef DEBUG_TSUITE - printf("%s timer_time=<%f>\n", __func__, timer_time); + printf(" %s timer_time=<%f>\n", __func__, timer_time); #endif ecore_timer_add(timer_time, tsuite_feed_event, td); @@ -626,17 +626,30 @@ ecore_main_loop_begin(void) return _ecore_main_loop_begin(); } +static Eina_Bool +_is_hook_duplicate(const Variant_st *v, Tsuite_Event_Type ev_type, const void *info, int len) +{ + if (v->t.type == tsuite_event_mapping_type_str_get(ev_type) && + !memcmp(v->data, info, len)) return EINA_TRUE; + return EINA_FALSE; +} + /* Adding variant to list, this list is later written to EET file */ #define ADD_TO_LIST(EVT_TYPE, EVT_STRUCT_NAME, INFO) \ do { /* This macro will add event to EET data list */ \ if (vr_list && _hook_setting->recording) \ { \ - Variant_st *v = malloc(sizeof(Variant_st)); \ - v->data = malloc(sizeof(EVT_STRUCT_NAME)); \ - _variant_type_set(tsuite_event_mapping_type_str_get(EVT_TYPE), \ - &v->t, EINA_FALSE); \ - memcpy(v->data, &INFO, sizeof(EVT_STRUCT_NAME)); \ - vr_list->variant_list = eina_list_append(vr_list->variant_list, v); \ + const Variant_st *prev_v = eina_list_last_data_get(vr_list->variant_list); \ + if (!prev_v || !_is_hook_duplicate(prev_v, EVT_TYPE, &INFO, sizeof(EVT_STRUCT_NAME))) \ + { \ + printf("Recording %s\n", tsuite_event_mapping_type_str_get(EVT_TYPE)); \ + Variant_st *v = malloc(sizeof(Variant_st)); \ + v->data = malloc(sizeof(EVT_STRUCT_NAME)); \ + _variant_type_set(tsuite_event_mapping_type_str_get(EVT_TYPE), \ + &v->t, EINA_FALSE); \ + memcpy(v->data, &INFO, sizeof(EVT_STRUCT_NAME)); \ + vr_list->variant_list = eina_list_append(vr_list->variant_list, v); \ + } \ } \ } while (0)