diff options
author | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-04-18 06:28:47 +0300 |
---|---|---|
committer | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-04-23 13:46:39 +0300 |
commit | 7521aac66509d18666b7737160153986cc1437ac (patch) | |
tree | 753deecae845a29694223461e6d3a397137966b1 | |
parent | 26039a38e3d5a2305e0ec93481df07c2717aa06d (diff) |
Move global vo_config_count to vo struct
Remove the global and Add a corresponding field to the vo struct, plus
another which tells whether the LAST config call was successful.The
latter value which tells whether the VO should be properly configured
at the moment seems a better match for the semantics actually needed
in most places where the old value was used. The 'count' field with
the old semantics is not currently used by anything, but I'm leaving
it there for vo drivers which would need those semantics if converted
to use the struct.
Existing uses of the global outside old vo drivers are either converted
to use the struct field or moved inside the vo_xyz() calls (instead of
"if (vo_config_count) vo_flip_page(..." just call vo_flip_page which
will now do nothing if not configured). The removal of the check in
mpcommon.c/update_subtitles() is less trivial than the others, but I
think it shouldn't cause problems.
-rw-r--r-- | command.c | 8 | ||||
-rw-r--r-- | libmpcodecs/vf_vo.c | 19 | ||||
-rw-r--r-- | libvo/old_vo_defines.h | 1 | ||||
-rw-r--r-- | libvo/video_out.c | 17 | ||||
-rw-r--r-- | libvo/video_out.h | 4 | ||||
-rw-r--r-- | libvo/vo_xv.c | 2 | ||||
-rw-r--r-- | mencoder.c | 1 | ||||
-rw-r--r-- | mpcommon.c | 3 | ||||
-rw-r--r-- | mplayer.c | 17 |
9 files changed, 38 insertions, 34 deletions
@@ -975,7 +975,7 @@ static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, guiGetEvent(guiIEvent, (char *) MP_CMD_GUI_FULLSCREEN); else #endif - if (vo_config_count) + if (mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0); return M_PROPERTY_OK; default: @@ -1064,7 +1064,7 @@ static int mp_property_vo_flag(m_option_t * prop, int action, void *arg, return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - if (vo_config_count) + if (mpctx->video_out->config_ok) vo_control(mpctx->video_out, vo_ctrl, 0); return M_PROPERTY_OK; default: @@ -2892,7 +2892,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd) break; case MP_CMD_SCREENSHOT: - if (vo_config_count) { + if (mpctx->video_out && mpctx->video_out->config_ok) { mp_msg(MSGT_CPLAYER, MSGL_INFO, "sending VFCTRL_SCREENSHOT!\n"); if (CONTROL_OK != ((vf_instance_t *) sh_video->vfilter)-> @@ -3037,7 +3037,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd) break; case MP_CMD_GET_VO_FULLSCREEN: - if (mpctx->video_out && vo_config_count) + if (mpctx->video_out && mpctx->video_out->config_ok) mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs); break; diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 5074148a8c..4543f821b6 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -68,7 +68,6 @@ static int config(struct vf_instance_s* vf, ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED)); #endif - ++vo_config_count; return 1; } @@ -86,26 +85,26 @@ static int control(struct vf_instance_s* vf, int request, void* data) return vo_control(video_out, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE; } case VFCTRL_DRAW_OSD: - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? + if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? vo_draw_osd(video_out); return CONTROL_TRUE; case VFCTRL_FLIP_PAGE: { - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? + if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? vo_flip_page(video_out); return CONTROL_TRUE; } case VFCTRL_SET_EQUALIZER: { vf_equalizer_t *eq=data; - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? + if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? struct voctrl_set_equalizer_args param = {eq->item, eq->value}; return vo_control(video_out, VOCTRL_SET_EQUALIZER, ¶m) == VO_TRUE; } case VFCTRL_GET_EQUALIZER: { vf_equalizer_t *eq=data; - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? + if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? struct voctrl_get_equalizer_args param = {eq->item, &eq->value}; return vo_control(video_out, VOCTRL_GET_EQUALIZER, ¶m) == VO_TRUE; } @@ -122,7 +121,7 @@ static int control(struct vf_instance_s* vf, int request, void* data) { mp_eosd_images_t images = {NULL, 2}; double pts = vf->priv->pts; - if (!vo_config_count || !vf->priv->ass_priv) return CONTROL_FALSE; + if (!video_out->config_ok || !vf->priv->ass_priv) return CONTROL_FALSE; if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) { mp_eosd_res_t res; memset(&res, 0, sizeof(res)); @@ -162,13 +161,13 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ - if(vo_directrendering && vo_config_count) + if(vo_directrendering && video_out->config_ok) vo_control(video_out, VOCTRL_GET_IMAGE, mpi); } static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ - if(!vo_config_count) return 0; // vo not configured? + if(!video_out->config_ok) return 0; // vo not configured? // record pts (potentially modified by filters) for main loop vf->priv->pts = pts; // first check, maybe the vo/vf plugin implements draw_image using mpi: @@ -187,13 +186,13 @@ static int put_image(struct vf_instance_s* vf, static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi) { - if(!vo_config_count) return; // vo not configured? + if(!video_out->config_ok) return; // vo not configured? vo_control(video_out, VOCTRL_START_SLICE,mpi); } static void draw_slice(struct vf_instance_s* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ - if(!vo_config_count) return; // vo not configured? + if(!video_out->config_ok) return; // vo not configured? vo_draw_slice(video_out, src,stride,w,h,x,y); } diff --git a/libvo/old_vo_defines.h b/libvo/old_vo_defines.h index 285758038e..ef52e52256 100644 --- a/libvo/old_vo_defines.h +++ b/libvo/old_vo_defines.h @@ -9,5 +9,6 @@ #define IS_OLD_VO 1 #define vo_ontop global_vo->opts->vo_ontop +#define vo_config_count global_vo->config_count #endif diff --git a/libvo/video_out.c b/libvo/video_out.c index 3a6b57347a..6cab65d25f 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -35,8 +35,6 @@ int vo_depthonscreen=0; int vo_screenwidth=0; int vo_screenheight=0; -int vo_config_count=0; - // requested resolution/bpp: (-x -y -bpp options) int vo_dx=0; int vo_dy=0; @@ -260,6 +258,8 @@ int vo_control(struct vo *vo, uint32_t request, void *data) int vo_draw_frame(struct vo *vo, uint8_t *src[]) { + if (!vo->config_ok) + return 0; return vo->driver->draw_frame(vo, src); } @@ -270,16 +270,22 @@ int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int void vo_draw_osd(struct vo *vo) { + if (!vo->config_ok) + return; vo->driver->draw_osd(vo); } void vo_flip_page(struct vo *vo) { + if (!vo->config_ok) + return; vo->driver->flip_page(vo); } void vo_check_events(struct vo *vo) { + if (!vo->config_ok) + return; vo->driver->check_events(vo); } @@ -371,8 +377,11 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height, vo_dheight = d_height; } - return vo->driver->config(vo, width, height, d_width, d_height, flags, - title, format); + int ret = vo->driver->config(vo, width, height, d_width, d_height, flags, + title, format); + vo->config_ok = (ret == 0); + vo->config_count += vo->config_ok; + return ret; } #if defined(HAVE_FBDEV)||defined(HAVE_VESA) diff --git a/libvo/video_out.h b/libvo/video_out.h index c1ba46e59f..1870af17d3 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -207,6 +207,8 @@ struct vo_old_functions { }; struct vo { + int config_ok; // Last config call was successful? + int config_count; // Total number of successful config calls const struct vo_driver *driver; void *priv; struct MPOpts *opts; @@ -233,8 +235,6 @@ extern const struct vo_driver *video_out_drivers[]; extern int vo_flags; -extern int vo_config_count; - extern int xinerama_screen; extern int xinerama_x; extern int xinerama_y; diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index b324912658..bc8a5015e7 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -867,7 +867,7 @@ static int control(struct vo *vo, uint32_t request, void *data) case VOCTRL_GUISUPPORT: return VO_TRUE; case VOCTRL_GET_PANSCAN: - if (!vo_config_count || !vo_fs) + if (!vo->config_ok || !vo_fs) return VO_FALSE; return VO_TRUE; case VOCTRL_FULLSCREEN: diff --git a/mencoder.c b/mencoder.c index 873a4af734..8c429fa615 100644 --- a/mencoder.c +++ b/mencoder.c @@ -97,7 +97,6 @@ MPOpts opts; int vo_doublebuffering=0; int vo_directrendering=0; -int vo_config_count=1; int forced_subs_only=0; //-------------------------- diff --git a/mpcommon.c b/mpcommon.c index d1d7316230..661468b1da 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -56,8 +56,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) } // DVD sub: - if (vo_config_count && vo_spudec && - (vobsub_id >= 0 || (dvdsub_id >= 0 && type == 'v'))) { + if (vo_spudec && (vobsub_id >= 0 || (dvdsub_id >= 0 && type == 'v'))) { int timestamp; current_module = "spudec"; spudec_heartbeat(vo_spudec, 90000*sh_video->timer); @@ -2142,7 +2142,6 @@ int reinit_video_chain(void) { current_module="preinit_libvo"; //shouldn't we set dvideo->id=-2 when we fail? - vo_config_count=0; //if((mpctx->video_out->preinit(vo_subdevice))!=0){ if(!(mpctx->video_out=init_best_video_out(opts, mpctx->x11_state))){ mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_ErrorInitializingVODevice); @@ -2343,7 +2342,7 @@ static void pause_loop(void) if (use_gui) guiGetEvent(guiCEvent, (char *)guiSetPause); #endif - if (mpctx->video_out && mpctx->sh_video && vo_config_count) + if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL); if (mpctx->audio_out && mpctx->sh_audio) @@ -2356,7 +2355,7 @@ static void pause_loop(void) mp_cmd_free(cmd); continue; } - if (mpctx->sh_video && mpctx->video_out && vo_config_count) + if (mpctx->sh_video && mpctx->video_out) vo_check_events(mpctx->video_out); #ifdef HAVE_NEW_GUI if (use_gui) { @@ -2379,7 +2378,7 @@ static void pause_loop(void) mpctx->osd_function=OSD_PLAY; if (mpctx->audio_out && mpctx->sh_audio) mpctx->audio_out->resume(); // resume audio - if (mpctx->video_out && mpctx->sh_video && vo_config_count) + if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_RESUME, NULL); // resume video (void)GetRelativeTime(); // ignore time that passed during pause #ifdef HAVE_NEW_GUI @@ -2497,7 +2496,7 @@ static int seek(MPContext *mpctx, double amount, int style) if (mpctx->sh_video) { current_module = "seek_video_reset"; resync_video_stream(mpctx->sh_video); - if (vo_config_count) + if (mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_RESET, NULL); mpctx->sh_video->num_buffered_pts = 0; mpctx->sh_video->last_pts = MP_NOPTS_VALUE; @@ -3010,7 +3009,7 @@ while (player_idle_mode && !filename) { play_tree_t * entry = NULL; mp_cmd_t * cmd; while (!(cmd = mp_input_get_cmd(0,1,0))) { // wait for command - if (mpctx->video_out && vo_config_count) + if (mpctx->video_out) vo_check_events(mpctx->video_out); usec_sleep(20000); } @@ -3746,8 +3745,7 @@ if(!mpctx->sh_video) { #endif current_module="vo_check_events"; - if (vo_config_count) - vo_check_events(mpctx->video_out); + vo_check_events(mpctx->video_out); #ifdef HAVE_X11 if (stop_xscreensaver) { @@ -3772,8 +3770,7 @@ if(!mpctx->sh_video) { if (!frame_time_remaining && blit_frame) { unsigned int t2=GetTimer(); - if(vo_config_count) - vo_flip_page(mpctx->video_out); + vo_flip_page(mpctx->video_out); mpctx->num_buffered_frames--; vout_time_usage += (GetTimer() - t2) * 0.000001; |