mirror of
https://github.com/mpv-player/mpv
synced 2025-03-19 18:05:21 +00:00
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:
parent
11648493db
commit
b4d9647d18
@ -330,7 +330,7 @@ void list_video_out(void)
|
|||||||
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
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 mp_fifo *key_fifo,
|
||||||
struct input_ctx *input_ctx)
|
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 *vo = talloc_ptrtype(NULL, vo);
|
||||||
struct vo initial_values = {
|
struct vo initial_values = {
|
||||||
.opts = opts,
|
.opts = opts,
|
||||||
.x11 = x11,
|
|
||||||
.key_fifo = key_fifo,
|
.key_fifo = key_fifo,
|
||||||
.input_ctx = input_ctx,
|
.input_ctx = input_ctx,
|
||||||
.event_fd = -1,
|
.event_fd = -1,
|
||||||
|
@ -297,7 +297,7 @@ struct vo {
|
|||||||
char *window_title;
|
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 mp_fifo *key_fifo,
|
||||||
struct input_ctx *input_ctx);
|
struct input_ctx *input_ctx);
|
||||||
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
|
@ -585,10 +585,8 @@ static int query_format(uint32_t format)
|
|||||||
|
|
||||||
static void uninit(void)
|
static void uninit(void)
|
||||||
{
|
{
|
||||||
if (!myximage)
|
if (myximage)
|
||||||
return;
|
freeMyXImage();
|
||||||
|
|
||||||
freeMyXImage();
|
|
||||||
|
|
||||||
#ifdef CONFIG_XF86VM
|
#ifdef CONFIG_XF86VM
|
||||||
vo_vm_close();
|
vo_vm_close();
|
||||||
|
@ -595,9 +595,13 @@ static int preinit(struct vo *vo, const char *arg)
|
|||||||
strarg_t ck_method_arg = { 0, NULL };
|
strarg_t ck_method_arg = { 0, NULL };
|
||||||
struct xvctx *ctx = talloc_zero(vo, struct xvctx);
|
struct xvctx *ctx = talloc_zero(vo, struct xvctx);
|
||||||
vo->priv = ctx;
|
vo->priv = ctx;
|
||||||
struct vo_x11_state *x11 = vo->x11;
|
|
||||||
int xv_adaptor = -1;
|
int xv_adaptor = -1;
|
||||||
|
|
||||||
|
if (!vo_init(vo))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
struct vo_x11_state *x11 = vo->x11;
|
||||||
|
|
||||||
const opt_t subopts[] =
|
const opt_t subopts[] =
|
||||||
{
|
{
|
||||||
/* name arg type arg var test */
|
/* 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 */
|
/* modify colorkey settings according to the given options */
|
||||||
xv_setup_colorkeyhandling(vo, ck_method_arg.str, ck_src_arg.str);
|
xv_setup_colorkeyhandling(vo, ck_method_arg.str, ck_src_arg.str);
|
||||||
|
|
||||||
if (!vo_init(vo))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* check for Xvideo extension */
|
/* check for Xvideo extension */
|
||||||
unsigned int ver, rel, req, ev, err;
|
unsigned int ver, rel, req, ev, err;
|
||||||
if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err)) {
|
if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err)) {
|
||||||
|
@ -383,7 +383,6 @@ void update_xinerama_info(struct vo *vo) {
|
|||||||
int vo_init(struct vo *vo)
|
int vo_init(struct vo *vo)
|
||||||
{
|
{
|
||||||
struct MPOpts *opts = vo->opts;
|
struct MPOpts *opts = vo->opts;
|
||||||
struct vo_x11_state *x11 = vo->x11;
|
|
||||||
// int mScreen;
|
// int mScreen;
|
||||||
int depth, bpp;
|
int depth, bpp;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
@ -396,6 +395,12 @@ int vo_init(struct vo *vo)
|
|||||||
XWindowAttributes attribs;
|
XWindowAttributes attribs;
|
||||||
char *dispName;
|
char *dispName;
|
||||||
|
|
||||||
|
if (vo->x11)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
vo->x11 = vo_x11_init_state();
|
||||||
|
struct vo_x11_state *x11 = vo->x11;
|
||||||
|
|
||||||
if (vo_rootwin)
|
if (vo_rootwin)
|
||||||
WinID = 0; // use root window
|
WinID = 0; // use root window
|
||||||
|
|
||||||
@ -422,6 +427,8 @@ int vo_init(struct vo *vo)
|
|||||||
{
|
{
|
||||||
mp_msg(MSGT_VO, MSGL_ERR,
|
mp_msg(MSGT_VO, MSGL_ERR,
|
||||||
"vo: couldn't open the X11 display (%s)!\n", dispName);
|
"vo: couldn't open the X11 display (%s)!\n", dispName);
|
||||||
|
talloc_free(x11);
|
||||||
|
vo->x11 = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
x11->screen = DefaultScreen(x11->display); // screen ID
|
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)
|
void vo_uninit(struct vo_x11_state *x11)
|
||||||
{
|
{
|
||||||
|
if (!x11)
|
||||||
|
return;
|
||||||
if (!x11->display)
|
if (!x11->display)
|
||||||
{
|
{
|
||||||
mp_msg(MSGT_VO, MSGL_V,
|
mp_msg(MSGT_VO, MSGL_V,
|
||||||
@ -765,6 +774,8 @@ void vo_x11_uninit(struct vo *vo)
|
|||||||
x11->last_video_height = 0;
|
x11->last_video_height = 0;
|
||||||
x11->size_changed_during_fs = false;
|
x11->size_changed_during_fs = false;
|
||||||
}
|
}
|
||||||
|
vo_uninit(x11);
|
||||||
|
vo->x11 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_resize(struct vo *vo)
|
static int check_resize(struct vo *vo)
|
||||||
|
@ -82,7 +82,6 @@ struct chapter {
|
|||||||
typedef struct MPContext {
|
typedef struct MPContext {
|
||||||
struct MPOpts opts;
|
struct MPOpts opts;
|
||||||
struct m_config *mconfig;
|
struct m_config *mconfig;
|
||||||
struct vo_x11_state *x11_state;
|
|
||||||
struct mp_fifo *key_fifo;
|
struct mp_fifo *key_fifo;
|
||||||
struct input_ctx *input;
|
struct input_ctx *input;
|
||||||
struct osd_state *osd;
|
struct osd_state *osd;
|
||||||
|
13
mplayer.c
13
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__)
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||||
timeEndPeriod(1);
|
timeEndPeriod(1);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_X11
|
|
||||||
vo_uninit(mpctx->x11_state); // Close the X11 connection (if any is open).
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mp_input_uninit(mpctx->input);
|
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)) {
|
if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) {
|
||||||
//shouldn't we set dvideo->id=-2 when we fail?
|
//shouldn't we set dvideo->id=-2 when we fail?
|
||||||
//if((mpctx->video_out->preinit(vo_subdevice))!=0){
|
//if((mpctx->video_out->preinit(vo_subdevice))!=0){
|
||||||
if (!(mpctx->video_out = init_best_video_out(opts, mpctx->x11_state,
|
if (!(mpctx->video_out = init_best_video_out(opts, mpctx->key_fifo,
|
||||||
mpctx->key_fifo,
|
|
||||||
mpctx->input))) {
|
mpctx->input))) {
|
||||||
mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Error opening/initializing "
|
mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Error opening/initializing "
|
||||||
"the selected video_out (-vo) device.\n");
|
"the selected video_out (-vo) device.\n");
|
||||||
@ -3059,8 +3055,8 @@ static void run_playloop(struct MPContext *mpctx)
|
|||||||
vo_check_events(vo);
|
vo_check_events(vo);
|
||||||
|
|
||||||
#ifdef CONFIG_X11
|
#ifdef CONFIG_X11
|
||||||
if (stop_xscreensaver) {
|
if (stop_xscreensaver && vo->x11) {
|
||||||
xscreensaver_heartbeat(mpctx->x11_state);
|
xscreensaver_heartbeat(vo->x11);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (heartbeat_cmd) {
|
if (heartbeat_cmd) {
|
||||||
@ -3500,9 +3496,6 @@ int main(int argc, char *argv[])
|
|||||||
init_libav();
|
init_libav();
|
||||||
screenshot_init(mpctx);
|
screenshot_init(mpctx);
|
||||||
|
|
||||||
#ifdef CONFIG_X11
|
|
||||||
mpctx->x11_state = vo_x11_init_state();
|
|
||||||
#endif
|
|
||||||
struct MPOpts *opts = &mpctx->opts;
|
struct MPOpts *opts = &mpctx->opts;
|
||||||
set_default_mplayer_options(opts);
|
set_default_mplayer_options(opts);
|
||||||
// Create the config context and register the options
|
// Create the config context and register the options
|
||||||
|
Loading…
Reference in New Issue
Block a user