summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kindestam <antonki@kth.se>2018-02-25 00:57:47 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-26 23:56:13 -0800
commita4c436bac26cc9a6f257764bbb268adde8ef8496 (patch)
treef4b2cfb0d96df5799ce71b1b8da00d40e42acc63
parent0874e4e461e3ade9e3bf1f537732c5f849a15b5e (diff)
downloadmpv-a4c436bac26cc9a6f257764bbb268adde8ef8496.tar.bz2
mpv-a4c436bac26cc9a6f257764bbb268adde8ef8496.tar.xz
drm_common: Improve VT switching signal handling somewhat
By blocking the VT switcher signal in the VO thread we get less races and other oddities. This gets rid of tearing (at least for me) when VT switching with --gpu-context=drm.
-rw-r--r--video/out/drm_common.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/video/out/drm_common.c b/video/out/drm_common.c
index 1a164f9a30..68c64d4298 100644
--- a/video/out/drm_common.c
+++ b/video/out/drm_common.c
@@ -431,7 +431,6 @@ static int install_signal(int signo, void (*handler)(int))
return sigaction(signo, &act, NULL);
}
-
bool vt_switcher_init(struct vt_switcher *s, struct mp_log *log)
{
s->log = log;
@@ -482,6 +481,14 @@ bool vt_switcher_init(struct vt_switcher *s, struct mp_log *log)
return false;
}
+ // Block the VT switching signals from interrupting the VO thread (they will
+ // still be picked up by other threads, which will fill vt_switcher_pipe for us)
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, RELEASE_SIGNAL);
+ sigaddset(&set, ACQUIRE_SIGNAL);
+ pthread_sigmask(SIG_BLOCK, &set, NULL);
+
return true;
}
@@ -507,6 +514,13 @@ void vt_switcher_interrupt_poll(struct vt_switcher *s)
void vt_switcher_destroy(struct vt_switcher *s)
{
+ struct vt_mode vt_mode = {0};
+ vt_mode.mode = VT_AUTO;
+ if (ioctl(s->tty_fd, VT_SETMODE, &vt_mode) < 0) {
+ MP_ERR(s, "VT_SETMODE failed: %s\n", mp_strerror(errno));
+ return;
+ }
+
install_signal(RELEASE_SIGNAL, SIG_DFL);
install_signal(ACQUIRE_SIGNAL, SIG_DFL);
close(s->tty_fd);