lmkd: polling code cleanup am: 9ca5334683
Change-Id: I4cf6a8f55d9fc127d80686c07ce2893f3146f0da
This commit is contained in:
commit
63123e1b84
16
lmkd.cpp
16
lmkd.cpp
|
|
@ -214,7 +214,6 @@ static android_log_context ctx;
|
||||||
enum polling_update {
|
enum polling_update {
|
||||||
POLLING_DO_NOT_CHANGE,
|
POLLING_DO_NOT_CHANGE,
|
||||||
POLLING_START,
|
POLLING_START,
|
||||||
POLLING_STOP,
|
|
||||||
POLLING_PAUSE,
|
POLLING_PAUSE,
|
||||||
POLLING_RESUME,
|
POLLING_RESUME,
|
||||||
};
|
};
|
||||||
|
|
@ -2938,9 +2937,12 @@ static void call_handler(struct event_handler_info* handler_info,
|
||||||
struct polling_params *poll_params, uint32_t events) {
|
struct polling_params *poll_params, uint32_t events) {
|
||||||
struct timespec curr_tm;
|
struct timespec curr_tm;
|
||||||
|
|
||||||
|
poll_params->update = POLLING_DO_NOT_CHANGE;
|
||||||
handler_info->handler(handler_info->data, events, poll_params);
|
handler_info->handler(handler_info->data, events, poll_params);
|
||||||
clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm);
|
clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm);
|
||||||
poll_params->last_poll_tm = curr_tm;
|
if (poll_params->poll_handler == handler_info) {
|
||||||
|
poll_params->last_poll_tm = curr_tm;
|
||||||
|
}
|
||||||
|
|
||||||
switch (poll_params->update) {
|
switch (poll_params->update) {
|
||||||
case POLLING_START:
|
case POLLING_START:
|
||||||
|
|
@ -2952,9 +2954,6 @@ static void call_handler(struct event_handler_info* handler_info,
|
||||||
poll_params->poll_start_tm = curr_tm;
|
poll_params->poll_start_tm = curr_tm;
|
||||||
poll_params->poll_handler = handler_info;
|
poll_params->poll_handler = handler_info;
|
||||||
break;
|
break;
|
||||||
case POLLING_STOP:
|
|
||||||
poll_params->poll_handler = NULL;
|
|
||||||
break;
|
|
||||||
case POLLING_PAUSE:
|
case POLLING_PAUSE:
|
||||||
poll_params->paused_handler = handler_info;
|
poll_params->paused_handler = handler_info;
|
||||||
poll_params->poll_handler = NULL;
|
poll_params->poll_handler = NULL;
|
||||||
|
|
@ -2967,11 +2966,10 @@ static void call_handler(struct event_handler_info* handler_info,
|
||||||
if (get_time_diff_ms(&poll_params->poll_start_tm, &curr_tm) > PSI_WINDOW_SIZE_MS) {
|
if (get_time_diff_ms(&poll_params->poll_start_tm, &curr_tm) > PSI_WINDOW_SIZE_MS) {
|
||||||
/* Polled for the duration of PSI window, time to stop */
|
/* Polled for the duration of PSI window, time to stop */
|
||||||
poll_params->poll_handler = NULL;
|
poll_params->poll_handler = NULL;
|
||||||
|
poll_params->paused_handler = NULL;
|
||||||
}
|
}
|
||||||
/* WARNING: skipping the rest of the function */
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
poll_params->update = POLLING_DO_NOT_CHANGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mainloop(void) {
|
static void mainloop(void) {
|
||||||
|
|
@ -2982,7 +2980,7 @@ static void mainloop(void) {
|
||||||
long delay = -1;
|
long delay = -1;
|
||||||
|
|
||||||
poll_params.poll_handler = NULL;
|
poll_params.poll_handler = NULL;
|
||||||
poll_params.update = POLLING_DO_NOT_CHANGE;
|
poll_params.paused_handler = NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
struct epoll_event events[maxevents];
|
struct epoll_event events[maxevents];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue