mirror of https://github.com/mpv-player/mpv
vo_drm: make VT switching non mandatory
This commit is contained in:
parent
fb1b8f93aa
commit
745cc7a8cd
|
@ -72,11 +72,13 @@ struct priv {
|
||||||
int mode_id;
|
int mode_id;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
struct vt_switcher vt_switcher;
|
|
||||||
struct modeset_dev *dev;
|
struct modeset_dev *dev;
|
||||||
drmModeCrtc *old_crtc;
|
drmModeCrtc *old_crtc;
|
||||||
drmEventContext ev;
|
drmEventContext ev;
|
||||||
|
|
||||||
|
bool vt_switcher_active;
|
||||||
|
struct vt_switcher vt_switcher;
|
||||||
|
|
||||||
bool active;
|
bool active;
|
||||||
bool pflip_happening;
|
bool pflip_happening;
|
||||||
|
|
||||||
|
@ -433,16 +435,19 @@ static void acquire_vt(void *data)
|
||||||
static int wait_events(struct vo *vo, int64_t until_time_us)
|
static int wait_events(struct vo *vo, int64_t until_time_us)
|
||||||
{
|
{
|
||||||
struct priv *p = vo->priv;
|
struct priv *p = vo->priv;
|
||||||
int64_t wait_us = until_time_us - mp_time_us();
|
if (p->vt_switcher_active) {
|
||||||
int timeout_ms = MPCLAMP((wait_us + 500) / 1000, 0, 10000);
|
int64_t wait_us = until_time_us - mp_time_us();
|
||||||
vt_switcher_poll(&p->vt_switcher, timeout_ms);
|
int timeout_ms = MPCLAMP((wait_us + 500) / 1000, 0, 10000);
|
||||||
|
vt_switcher_poll(&p->vt_switcher, timeout_ms);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wakeup(struct vo *vo)
|
static void wakeup(struct vo *vo)
|
||||||
{
|
{
|
||||||
struct priv *p = vo->priv;
|
struct priv *p = vo->priv;
|
||||||
vt_switcher_interrupt_poll(&p->vt_switcher);
|
if (p->vt_switcher_active)
|
||||||
|
vt_switcher_interrupt_poll(&p->vt_switcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
||||||
|
@ -568,7 +573,9 @@ static void uninit(struct vo *vo)
|
||||||
drmModeFreeEncoder(p->dev->enc);
|
drmModeFreeEncoder(p->dev->enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
vt_switcher_destroy(&p->vt_switcher);
|
if (p->vt_switcher_active)
|
||||||
|
vt_switcher_destroy(&p->vt_switcher);
|
||||||
|
|
||||||
talloc_free(p->last_input);
|
talloc_free(p->last_input);
|
||||||
talloc_free(p->cur_frame);
|
talloc_free(p->cur_frame);
|
||||||
talloc_free(p->dev);
|
talloc_free(p->dev);
|
||||||
|
@ -583,11 +590,13 @@ static int preinit(struct vo *vo)
|
||||||
p->ev.version = DRM_EVENT_CONTEXT_VERSION;
|
p->ev.version = DRM_EVENT_CONTEXT_VERSION;
|
||||||
p->ev.page_flip_handler = modeset_page_flipped;
|
p->ev.page_flip_handler = modeset_page_flipped;
|
||||||
|
|
||||||
if (vt_switcher_init(&p->vt_switcher, vo->log))
|
p->vt_switcher_active = vt_switcher_init(&p->vt_switcher, vo->log) == 0;
|
||||||
goto err;
|
if (p->vt_switcher_active) {
|
||||||
|
vt_switcher_acquire(&p->vt_switcher, acquire_vt, vo);
|
||||||
vt_switcher_acquire(&p->vt_switcher, acquire_vt, vo);
|
vt_switcher_release(&p->vt_switcher, release_vt, vo);
|
||||||
vt_switcher_release(&p->vt_switcher, release_vt, vo);
|
} else {
|
||||||
|
MP_WARN(vo, "Failed to set up VT switcher. Terminal switching will be unavailable.\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (modeset_open(vo, &p->fd, p->device_path))
|
if (modeset_open(vo, &p->fd, p->device_path))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Reference in New Issue