summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-09 20:58:26 +0200
committerwm4 <wm4@nowhere>2014-09-10 00:48:12 +0200
commit28fc13977e740769d11b17165016559505187486 (patch)
tree1ed04f39b6f852d0c9c9e9142094bf3738624854 /input
parentd0b525121af63cc8cf19f2207a5ef384c78e61f6 (diff)
downloadmpv-28fc13977e740769d11b17165016559505187486.tar.bz2
mpv-28fc13977e740769d11b17165016559505187486.tar.xz
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().
Diffstat (limited to 'input')
-rw-r--r--input/input.c20
-rw-r--r--input/input.h2
2 files changed, 1 insertions, 21 deletions
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 */