summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-03 05:55:02 +0200
committerwm4 <wm4@nowhere>2012-08-03 05:55:02 +0200
commitb4d9647d189a6bb924fc6b415ae18969885f11f1 (patch)
treef794e727435ef230f52dd1fac7c0f7029dc7b083
parent11648493db7db164aa8fe01751b7e5c5e5faa810 (diff)
downloadmpv-b4d9647d189a6bb924fc6b415ae18969885f11f1.tar.bz2
mpv-b4d9647d189a6bb924fc6b415ae18969885f11f1.tar.xz
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.
-rw-r--r--libvo/video_out.c3
-rw-r--r--libvo/video_out.h2
-rw-r--r--libvo/vo_x11.c6
-rw-r--r--libvo/vo_xv.c9
-rw-r--r--libvo/x11_common.c13
-rw-r--r--mp_core.h1
-rw-r--r--mplayer.c13
7 files changed, 24 insertions, 23 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c
index d2c2f439df..a17fc9aa28 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -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,
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 62bbf89975..203e6b47b7 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -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,
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index cee2b0bf0c..75cd7e4415 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -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();
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index df9bb69aa1..65581dac35 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -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)) {
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 9f580ba47a..65140359f2 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -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)
diff --git a/mp_core.h b/mp_core.h
index 70ad8a89a7..49cc81a8e1 100644
--- a/mp_core.h
+++ b/mp_core.h
@@ -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;
diff --git a/mplayer.c b/mplayer.c
index a133bfb6c5..3b53e9301e 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -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