lmkd: polling code cleanup am: 3f84a211e5
Change-Id: I5265d3370371ea5b4c07dce31af732f6d4f29c71
This commit is contained in:
commit
8a6cf251b8
14
lmkd.cpp
14
lmkd.cpp
|
|
@ -216,7 +216,6 @@ static android_log_context ctx;
|
|||
enum polling_update {
|
||||
POLLING_DO_NOT_CHANGE,
|
||||
POLLING_START,
|
||||
POLLING_STOP,
|
||||
POLLING_PAUSE,
|
||||
POLLING_RESUME,
|
||||
};
|
||||
|
|
@ -2990,9 +2989,12 @@ static void call_handler(struct event_handler_info* handler_info,
|
|||
struct polling_params *poll_params, uint32_t events) {
|
||||
struct timespec curr_tm;
|
||||
|
||||
poll_params->update = POLLING_DO_NOT_CHANGE;
|
||||
handler_info->handler(handler_info->data, events, poll_params);
|
||||
clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm);
|
||||
if (poll_params->poll_handler == handler_info) {
|
||||
poll_params->last_poll_tm = curr_tm;
|
||||
}
|
||||
|
||||
switch (poll_params->update) {
|
||||
case POLLING_START:
|
||||
|
|
@ -3004,9 +3006,6 @@ static void call_handler(struct event_handler_info* handler_info,
|
|||
poll_params->poll_start_tm = curr_tm;
|
||||
poll_params->poll_handler = handler_info;
|
||||
break;
|
||||
case POLLING_STOP:
|
||||
poll_params->poll_handler = NULL;
|
||||
break;
|
||||
case POLLING_PAUSE:
|
||||
poll_params->paused_handler = handler_info;
|
||||
poll_params->poll_handler = NULL;
|
||||
|
|
@ -3019,11 +3018,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) {
|
||||
/* Polled for the duration of PSI window, time to stop */
|
||||
poll_params->poll_handler = NULL;
|
||||
poll_params->paused_handler = NULL;
|
||||
}
|
||||
/* WARNING: skipping the rest of the function */
|
||||
return;
|
||||
break;
|
||||
}
|
||||
poll_params->update = POLLING_DO_NOT_CHANGE;
|
||||
}
|
||||
|
||||
static void mainloop(void) {
|
||||
|
|
@ -3034,7 +3032,7 @@ static void mainloop(void) {
|
|||
long delay = -1;
|
||||
|
||||
poll_params.poll_handler = NULL;
|
||||
poll_params.update = POLLING_DO_NOT_CHANGE;
|
||||
poll_params.paused_handler = NULL;
|
||||
|
||||
while (1) {
|
||||
struct epoll_event events[MAX_EPOLL_EVENTS];
|
||||
|
|
|
|||
Loading…
Reference in New Issue