mplayer: do not create X11 state in player frontend

This is about the vo_x11_init_state() call. It basically opens a X11
connection. It's called in the main() function once. It's not really
clear why this isn't done on VO creation instead. Maybe one reason was
that --no-fixed-vo used to be the default: when playing a new file, the
full VO state would be free'd and recreated. Keeping the X11 connection
possibly improved things, although the question is how. In summary,
there is no good reason to do this, and it only adds platform specific
details to the player frontend.

Do the X11 initialization in the respective VOs instead.
This commit is contained in:
wm4 2012-08-03 05:55:02 +02:00
parent 11648493db
commit b4d9647d18
7 changed files with 24 additions and 23 deletions

View File

@ -330,7 +330,7 @@ void list_video_out(void)
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
}
struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
struct vo *init_best_video_out(struct MPOpts *opts,
struct mp_fifo *key_fifo,
struct input_ctx *input_ctx)
{
@ -339,7 +339,6 @@ struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
struct vo *vo = talloc_ptrtype(NULL, vo);
struct vo initial_values = {
.opts = opts,
.x11 = x11,
.key_fifo = key_fifo,
.input_ctx = input_ctx,
.event_fd = -1,

View File

@ -297,7 +297,7 @@ struct vo {
char *window_title;
};
struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
struct vo *init_best_video_out(struct MPOpts *opts,
struct mp_fifo *key_fifo,
struct input_ctx *input_ctx);
int vo_config(struct vo *vo, uint32_t width, uint32_t height,

View File

@ -585,10 +585,8 @@ static int query_format(uint32_t format)
static void uninit(void)
{
if (!myximage)
return;
freeMyXImage();
if (myximage)
freeMyXImage();
#ifdef CONFIG_XF86VM
vo_vm_close();

View File

@ -595,9 +595,13 @@ static int preinit(struct vo *vo, const char *arg)
strarg_t ck_method_arg = { 0, NULL };
struct xvctx *ctx = talloc_zero(vo, struct xvctx);
vo->priv = ctx;
struct vo_x11_state *x11 = vo->x11;
int xv_adaptor = -1;
if (!vo_init(vo))
return -1;
struct vo_x11_state *x11 = vo->x11;
const opt_t subopts[] =
{
/* name arg type arg var test */
@ -618,9 +622,6 @@ static int preinit(struct vo *vo, const char *arg)
/* modify colorkey settings according to the given options */
xv_setup_colorkeyhandling(vo, ck_method_arg.str, ck_src_arg.str);
if (!vo_init(vo))
return -1;
/* check for Xvideo extension */
unsigned int ver, rel, req, ev, err;
if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err)) {

View File

@ -383,7 +383,6 @@ void update_xinerama_info(struct vo *vo) {
int vo_init(struct vo *vo)
{
struct MPOpts *opts = vo->opts;
struct vo_x11_state *x11 = vo->x11;
// int mScreen;
int depth, bpp;
unsigned int mask;
@ -396,6 +395,12 @@ int vo_init(struct vo *vo)
XWindowAttributes attribs;
char *dispName;
if (vo->x11)
return 1;
vo->x11 = vo_x11_init_state();
struct vo_x11_state *x11 = vo->x11;
if (vo_rootwin)
WinID = 0; // use root window
@ -422,6 +427,8 @@ int vo_init(struct vo *vo)
{
mp_msg(MSGT_VO, MSGL_ERR,
"vo: couldn't open the X11 display (%s)!\n", dispName);
talloc_free(x11);
vo->x11 = NULL;
return 0;
}
x11->screen = DefaultScreen(x11->display); // screen ID
@ -524,6 +531,8 @@ int vo_init(struct vo *vo)
void vo_uninit(struct vo_x11_state *x11)
{
if (!x11)
return;
if (!x11->display)
{
mp_msg(MSGT_VO, MSGL_V,
@ -765,6 +774,8 @@ void vo_x11_uninit(struct vo *vo)
x11->last_video_height = 0;
x11->size_changed_during_fs = false;
}
vo_uninit(x11);
vo->x11 = NULL;
}
static int check_resize(struct vo *vo)

View File

@ -82,7 +82,6 @@ struct chapter {
typedef struct MPContext {
struct MPOpts opts;
struct m_config *mconfig;
struct vo_x11_state *x11_state;
struct mp_fifo *key_fifo;
struct input_ctx *input;
struct osd_state *osd;

View File

@ -669,9 +669,6 @@ void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc)
#if defined(__MINGW32__) || defined(__CYGWIN__)
timeEndPeriod(1);
#endif
#ifdef CONFIG_X11
vo_uninit(mpctx->x11_state); // Close the X11 connection (if any is open).
#endif
mp_input_uninit(mpctx->input);
@ -2277,8 +2274,7 @@ int reinit_video_chain(struct MPContext *mpctx)
if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) {
//shouldn't we set dvideo->id=-2 when we fail?
//if((mpctx->video_out->preinit(vo_subdevice))!=0){
if (!(mpctx->video_out = init_best_video_out(opts, mpctx->x11_state,
mpctx->key_fifo,
if (!(mpctx->video_out = init_best_video_out(opts, mpctx->key_fifo,
mpctx->input))) {
mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Error opening/initializing "
"the selected video_out (-vo) device.\n");
@ -3059,8 +3055,8 @@ static void run_playloop(struct MPContext *mpctx)
vo_check_events(vo);
#ifdef CONFIG_X11
if (stop_xscreensaver) {
xscreensaver_heartbeat(mpctx->x11_state);
if (stop_xscreensaver && vo->x11) {
xscreensaver_heartbeat(vo->x11);
}
#endif
if (heartbeat_cmd) {
@ -3500,9 +3496,6 @@ int main(int argc, char *argv[])
init_libav();
screenshot_init(mpctx);
#ifdef CONFIG_X11
mpctx->x11_state = vo_x11_init_state();
#endif
struct MPOpts *opts = &mpctx->opts;
set_default_mplayer_options(opts);
// Create the config context and register the options