From 079e0e796350a3df64c03619b7593e1d934bf321 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 3 Dec 2013 23:50:01 +0100 Subject: vf_vo: don't abuse option strings to set VO Whoever thought this was a good idea should be punched. --- mpvcore/player/video.c | 8 ++++---- video/filter/vf.h | 1 + video/filter/vf_vo.c | 20 ++++++++++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c index c422b6997e..6560192fb4 100644 --- a/mpvcore/player/video.c +++ b/mpvcore/player/video.c @@ -60,10 +60,10 @@ static void recreate_video_filters(struct MPContext *mpctx) vf_uninit_filter_chain(d_video->vfilter); - char *vf_arg[] = { - "_oldargs_", (char *)mpctx->video_out, NULL - }; - d_video->vfilter = vf_open_filter(opts, NULL, "vo", vf_arg); + d_video->vfilter = vf_open_filter(opts, NULL, "vo", NULL); + if (!d_video->vfilter) + abort(); + d_video->vfilter->control(d_video->vfilter, VFCTRL_SET_VO, mpctx->video_out); d_video->vfilter = append_filters(d_video->vfilter, opts->vf_settings); diff --git a/video/filter/vf.h b/video/filter/vf.h index 6c07e6c4d9..af7f0a3481 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -103,6 +103,7 @@ enum vf_ctrl { /* Hack to make the OSD state object available to vf_sub which * access OSD/subtitle state outside of normal OSD draw time. */ VFCTRL_SET_OSD_OBJ, + VFCTRL_SET_VO, VFCTRL_GET_HWDEC_INFO, // for hwdec filters }; diff --git a/video/filter/vf_vo.c b/video/filter/vf_vo.c index 74becd7250..8deb632085 100644 --- a/video/filter/vf_vo.c +++ b/video/filter/vf_vo.c @@ -37,6 +37,9 @@ struct vf_priv_s { static int reconfig(struct vf_instance *vf, struct mp_image_params *p, int flags) { + if (!video_out) + return -1; + if (p->w <= 0 || p->h <= 0 || p->d_w <= 0 || p->d_h <= 0) { mp_msg(MSGT_CPLAYER, MSGL_ERR, "VO: invalid dimensions!\n"); return -1; @@ -55,6 +58,13 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *p, int flags static int control(struct vf_instance *vf, int request, void *data) { + if (request == VFCTRL_SET_VO) { + video_out = data; + return CONTROL_OK; + } + if (!video_out) + return CONTROL_FALSE; + switch (request) { case VFCTRL_GET_DEINTERLACE: return vo_control(video_out, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE; @@ -86,16 +96,17 @@ static int control(struct vf_instance *vf, int request, void *data) static int query_format(struct vf_instance *vf, unsigned int fmt) { + if (!video_out) + return 0; return video_out->driver->query_format(video_out, fmt); } static void uninit(struct vf_instance *vf) { - if (vf->priv) { + if (vf->priv && video_out) { /* Allow VO (which may live on to work with another instance of vf_vo) * to get rid of numbered-mpi references that will now be invalid. */ vo_seek_reset(video_out); - free(vf->priv); } } @@ -105,10 +116,6 @@ static int vf_open(vf_instance_t *vf, char *args) vf->control = control; vf->query_format = query_format; vf->uninit = uninit; - vf->priv = calloc(1, sizeof(struct vf_priv_s)); - vf->priv->vo = (struct vo *)args; - if (!video_out) - return 0; return 1; } @@ -116,4 +123,5 @@ const vf_info_t vf_info_vo = { .description = "libvo wrapper", .name = "vo", .open = vf_open, + .priv_size = sizeof(struct vf_priv_s), }; -- cgit v1.2.3