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.
This commit is contained in:
Daniel Zaoui 2016-03-17 11:44:56 +02:00
parent 4b2887721b
commit 06811238a1
1 changed files with 21 additions and 8 deletions

View File

@ -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)