From 28fc13977e740769d11b17165016559505187486 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 9 Sep 2014 20:58:26 +0200 Subject: terminal-unix: move to thread Do terminal input with a thread, instead of using the central select() loop. This also changes some details how SIGTERM is handled. Part of my crusade against mp_input_add_fd(). --- input/input.c | 20 +------------------- input/input.h | 2 -- 2 files changed, 1 insertion(+), 21 deletions(-) (limited to 'input') diff --git a/input/input.c b/input/input.c index bf032e6ce2..31ce41ff57 100644 --- a/input/input.c +++ b/input/input.c @@ -187,8 +187,6 @@ struct input_ctx { int wakeup_pipe[2]; }; -int async_quit_request; - static int parse_config(struct input_ctx *ictx, bool builtin, bstr data, const char *location, const char *restrict_section); static void close_input_sources(struct input_ctx *ictx); @@ -296,12 +294,6 @@ static void queue_remove(struct cmd_queue *queue, struct mp_cmd *cmd) *p_prev = cmd->queue_next; } -static void queue_add_head(struct cmd_queue *queue, struct mp_cmd *cmd) -{ - cmd->queue_next = queue->first; - queue->first = cmd; -} - static void queue_add_tail(struct cmd_queue *queue, struct mp_cmd *cmd) { struct mp_cmd **p_prev = &queue->first; @@ -1159,11 +1151,6 @@ mp_cmd_t *mp_input_read_cmd(struct input_ctx *ictx) { input_lock(ictx); read_events(ictx, 0); - if (async_quit_request && !queue_has_abort_cmds(&ictx->cmd_queue)) { - struct mp_cmd *cmd = mp_input_parse_cmd(ictx, bstr0("quit"), ""); - queue_add_head(&ictx->cmd_queue, cmd); - async_quit_request = 0; - } struct cmd_queue *queue = &ictx->cmd_queue; if (!queue->first) { struct mp_cmd *repeated = check_autorepeat(ictx); @@ -1664,11 +1651,6 @@ void mp_input_wakeup_nolock(struct input_ctx *ictx) } } -static bool test_abort(struct input_ctx *ictx) -{ - return async_quit_request || queue_has_abort_cmds(&ictx->cmd_queue); -} - void mp_input_set_main_thread(struct input_ctx *ictx) { ictx->mainthread = pthread_self(); @@ -1678,7 +1660,7 @@ void mp_input_set_main_thread(struct input_ctx *ictx) bool mp_input_check_interrupt(struct input_ctx *ictx) { input_lock(ictx); - bool res = test_abort(ictx); + bool res = queue_has_abort_cmds(&ictx->cmd_queue); if (!res && ictx->mainthread_set && pthread_equal(ictx->mainthread, pthread_self())) { diff --git a/input/input.h b/input/input.h index 6ab1392111..1bd1410f66 100644 --- a/input/input.h +++ b/input/input.h @@ -260,6 +260,4 @@ void mp_input_add_pipe(struct input_ctx *ictx, const char *filename); void mp_input_set_main_thread(struct input_ctx *ictx); -extern int async_quit_request; - #endif /* MPLAYER_INPUT_H */ -- cgit v1.2.3