summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-22 21:06:23 +0200
committerwm4 <wm4@nowhere>2014-04-22 21:06:23 +0200
commita45363a28af226d684e70aee7fbf094e6f7c02d2 (patch)
tree32cfdf2ba5b20d07c60de8badfd0c6e07faaa3e6 /video
parente156f8b052d583f0d57b20a5a9f87951d1d3a6f1 (diff)
downloadmpv-a45363a28af226d684e70aee7fbf094e6f7c02d2.tar.bz2
mpv-a45363a28af226d684e70aee7fbf094e6f7c02d2.tar.xz
vo: simplify event_fd handling
Add the event FD after preinit, remove it before destroy. There's no need to do it on vo_config, and there's no need to remove the event FD when vo_config fails.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo.c34
-rw-r--r--video/out/vo.h1
2 files changed, 13 insertions, 22 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index b21a3fb120..7db3c8dd2f 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -142,6 +142,13 @@ const struct m_obj_list vo_obj_list = {
.allow_trailer = true,
};
+static int event_fd_callback(void *ctx, int fd)
+{
+ struct vo *vo = ctx;
+ vo_check_events(vo);
+ return MP_INPUT_NOTHING;
+}
+
static struct vo *vo_create(struct mpv_global *global,
struct input_ctx *input_ctx,
struct encode_lavc_context *encode_lavc_ctx,
@@ -163,7 +170,6 @@ static struct vo *vo_create(struct mpv_global *global,
.encode_lavc_ctx = encode_lavc_ctx,
.input_ctx = input_ctx,
.event_fd = -1,
- .registered_fd = -1,
.monitor_par = 1,
.next_pts = MP_NOPTS_VALUE,
.next_pts2 = MP_NOPTS_VALUE,
@@ -179,6 +185,10 @@ static struct vo *vo_create(struct mpv_global *global,
vo->priv = config->optstruct;
if (vo->driver->preinit(vo))
goto error;
+ if (vo->event_fd != -1) {
+ mp_input_add_fd(vo->input_ctx, vo->event_fd, 1, NULL, event_fd_callback,
+ NULL, vo);
+ }
return vo;
error:
talloc_free(vo);
@@ -216,8 +226,8 @@ autoprobe:
void vo_destroy(struct vo *vo)
{
- if (vo->registered_fd != -1)
- mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd);
+ if (vo->event_fd != -1)
+ mp_input_rm_key_fd(vo->input_ctx, vo->event_fd);
mp_image_unrefp(&vo->waiting_mpi);
vo->driver->uninit(vo);
talloc_free(vo);
@@ -295,13 +305,6 @@ static void determine_window_geometry(struct vo *vo, int d_w, int d_h)
vo->dheight = d_h;
}
-static int event_fd_callback(void *ctx, int fd)
-{
- struct vo *vo = ctx;
- vo_check_events(vo);
- return MP_INPUT_NOTHING;
-}
-
static void check_vo_caps(struct vo *vo)
{
int rot = vo->params->rotate;
@@ -342,11 +345,6 @@ int vo_reconfig(struct vo *vo, struct mp_image_params *params, int flags)
talloc_free(vo->params);
vo->params = NULL;
}
- if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) {
- mp_input_add_fd(vo->input_ctx, vo->event_fd, 1, NULL, event_fd_callback,
- NULL, vo);
- vo->registered_fd = vo->event_fd;
- }
vo->frame_loaded = false;
vo->waiting_mpi = NULL;
vo->redrawing = false;
@@ -451,12 +449,6 @@ void vo_flip_page(struct vo *vo, int64_t pts_us, int duration)
void vo_check_events(struct vo *vo)
{
- if (!vo->config_ok) {
- if (vo->registered_fd != -1)
- mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd);
- vo->registered_fd = -1;
- return;
- }
vo_control(vo, VOCTRL_CHECK_EVENTS, NULL);
}
diff --git a/video/out/vo.h b/video/out/vo.h
index b9887d2119..e096c3c208 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -249,7 +249,6 @@ struct vo {
struct encode_lavc_context *encode_lavc_ctx;
struct input_ctx *input_ctx;
int event_fd; // check_events() should be called when this has input
- int registered_fd; // set to event_fd when registered in input system
// requested position/resolution (usually window position/window size)
int dx;