aboutsummaryrefslogtreecommitdiffhomepage
path: root/input
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2014-09-09 00:25:54 +0200
committerGravatar wm4 <wm4@nowhere>2014-09-09 01:23:09 +0200
commit76f9eede349b57fdffd2f09cb45f9f58b225711b (patch)
tree29ad98ed7e4412bb1e27d2b67050384495683fa9 /input
parentb578abe81b55f358df0f4496a075606bf412e399 (diff)
input: fix missed wakeups, simplify
mp_input_read_cmd() reset the wakeup flag, but only mp_input_wait() should be able to do that.
Diffstat (limited to 'input')
-rw-r--r--input/input.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/input/input.c b/input/input.c
index 07c7b3f13e..bf032e6ce2 100644
--- a/input/input.c
+++ b/input/input.c
@@ -1096,29 +1096,12 @@ static void read_events(struct input_ctx *ictx, int time)
}
time = FFMAX(time, 0);
- while (1) {
- if (ictx->need_wakeup)
- time = 0;
- ictx->need_wakeup = false;
-
- remove_dead_fds(ictx);
-
- if (time) {
- for (int i = 0; i < ictx->num_fds; i++) {
- if (!ictx->fds[i].select)
- read_fd(ictx, &ictx->fds[i]);
- }
- }
+ if (ictx->need_wakeup)
+ time = 0;
- if (ictx->need_wakeup)
- time = 0;
+ remove_dead_fds(ictx);
- input_wait_read(ictx, time);
-
- // Read until no new wakeups happen.
- if (!ictx->need_wakeup)
- break;
- }
+ input_wait_read(ictx, time);
}
int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t *cmd)
@@ -1160,14 +1143,15 @@ static mp_cmd_t *check_autorepeat(struct input_ctx *ictx)
void mp_input_wait(struct input_ctx *ictx, double seconds)
{
- if (seconds <= 0)
- return;
input_lock(ictx);
if (ictx->cmd_queue.first)
seconds = 0;
- MP_STATS(ictx, "start sleep");
- read_events(ictx, MPMIN(seconds * 1000, INT_MAX));
- MP_STATS(ictx, "end sleep");
+ if (seconds > 0) {
+ MP_STATS(ictx, "start sleep");
+ read_events(ictx, MPMIN(seconds * 1000, INT_MAX));
+ MP_STATS(ictx, "end sleep");
+ }
+ ictx->need_wakeup = false;
input_unlock(ictx);
}