mirror of
https://github.com/mpv-player/mpv
synced 2025-01-03 13:32:16 +00:00
x11: never forcefully terminate xdg-screensaver process
It sometimes happens on exit, and it's probably a bad idea. If the process hangs on exit (possibly due to stupid hardcoded timeouts it's doing), mpv will also hang now, unfortunately.
This commit is contained in:
parent
0d020c5c46
commit
be9bf4cc7c
video/out
@ -483,13 +483,11 @@ static void *screensaver_thread(void *arg)
|
|||||||
// don't queue multiple wakeups
|
// don't queue multiple wakeups
|
||||||
while (!sem_trywait(&x11->screensaver_sem)) {}
|
while (!sem_trywait(&x11->screensaver_sem)) {}
|
||||||
|
|
||||||
if (mp_cancel_test(x11->screensaver_terminate))
|
if (atomic_load(&x11->screensaver_terminate))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
char *args[] = {"xdg-screensaver", "reset", NULL};
|
char *args[] = {"xdg-screensaver", "reset", NULL};
|
||||||
if (mp_subprocess(args, x11->screensaver_terminate, NULL, NULL,
|
if (mp_subprocess(args, NULL, NULL, NULL, NULL, &(char*){0})) {
|
||||||
NULL, &(char*){0}))
|
|
||||||
{
|
|
||||||
MP_WARN(x11, "Disabling screensaver failed.\n");
|
MP_WARN(x11, "Disabling screensaver failed.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -515,13 +513,12 @@ int vo_x11_init(struct vo *vo)
|
|||||||
};
|
};
|
||||||
vo->x11 = x11;
|
vo->x11 = x11;
|
||||||
|
|
||||||
x11->screensaver_terminate = mp_cancel_new(x11);
|
|
||||||
sem_init(&x11->screensaver_sem, 0, 0);
|
sem_init(&x11->screensaver_sem, 0, 0);
|
||||||
if (pthread_create(&x11->screensaver_thread, NULL, screensaver_thread, x11)) {
|
if (pthread_create(&x11->screensaver_thread, NULL, screensaver_thread, x11)) {
|
||||||
x11->screensaver_terminate = NULL;
|
|
||||||
sem_destroy(&x11->screensaver_sem);
|
sem_destroy(&x11->screensaver_sem);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
x11->screensaver_thread_running = true;
|
||||||
|
|
||||||
x11_error_output = x11->log;
|
x11_error_output = x11->log;
|
||||||
XSetErrorHandler(x11_errorhandler);
|
XSetErrorHandler(x11_errorhandler);
|
||||||
@ -731,8 +728,8 @@ void vo_x11_uninit(struct vo *vo)
|
|||||||
XCloseDisplay(x11->display);
|
XCloseDisplay(x11->display);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x11->screensaver_terminate) {
|
if (x11->screensaver_thread_running) {
|
||||||
mp_cancel_trigger(x11->screensaver_terminate);
|
atomic_store(&x11->screensaver_terminate, true);
|
||||||
sem_post(&x11->screensaver_sem);
|
sem_post(&x11->screensaver_sem);
|
||||||
pthread_join(x11->screensaver_thread, NULL);
|
pthread_join(x11->screensaver_thread, NULL);
|
||||||
sem_destroy(&x11->screensaver_sem);
|
sem_destroy(&x11->screensaver_sem);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
#include "osdep/atomics.h"
|
||||||
#include "osdep/semaphore.h"
|
#include "osdep/semaphore.h"
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
@ -61,8 +62,9 @@ struct vo_x11_state {
|
|||||||
bool dpms_touched;
|
bool dpms_touched;
|
||||||
double screensaver_time_last;
|
double screensaver_time_last;
|
||||||
pthread_t screensaver_thread;
|
pthread_t screensaver_thread;
|
||||||
|
bool screensaver_thread_running;
|
||||||
sem_t screensaver_sem;
|
sem_t screensaver_sem;
|
||||||
struct mp_cancel *screensaver_terminate;
|
atomic_bool screensaver_terminate;
|
||||||
|
|
||||||
XIM xim;
|
XIM xim;
|
||||||
XIC xic;
|
XIC xic;
|
||||||
|
Loading…
Reference in New Issue
Block a user