mirror of
https://github.com/mpv-player/mpv
synced 2025-01-02 21:12:23 +00:00
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.
This commit is contained in:
parent
0874e4e461
commit
a4c436bac2
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user