aboutsummaryrefslogtreecommitdiffhomepage
path: root/libvo
diff options
context:
space:
mode:
Diffstat (limited to 'libvo')
-rw-r--r--libvo/aspect.c123
-rw-r--r--libvo/aspect.h34
-rw-r--r--libvo/font_load.h1
-rw-r--r--libvo/font_load_ft.c4
-rw-r--r--libvo/gl_common.c1
-rw-r--r--libvo/gl_common.h8
-rw-r--r--libvo/mga_common.c28
-rw-r--r--libvo/old_vo_defines.h24
-rw-r--r--libvo/old_vo_wrapper.c116
-rw-r--r--libvo/old_vo_wrapper.h29
-rw-r--r--libvo/spuenc.c47
-rw-r--r--libvo/spuenc.h1
-rw-r--r--libvo/sub.c103
-rw-r--r--libvo/sub.h43
-rw-r--r--libvo/vesa_lvo.c12
-rw-r--r--libvo/vesa_lvo.h4
-rw-r--r--libvo/video_out.c339
-rw-r--r--libvo/video_out.h136
-rw-r--r--libvo/video_out_internal.h22
-rw-r--r--libvo/vo_3dfx.c2
-rw-r--r--libvo/vo_aa.c52
-rw-r--r--libvo/vo_bl.c2
-rw-r--r--libvo/vo_caca.c2
-rw-r--r--libvo/vo_cvidix.c22
-rw-r--r--libvo/vo_dfbmga.c22
-rw-r--r--libvo/vo_dga.c2
-rw-r--r--libvo/vo_direct3d.c2
-rw-r--r--libvo/vo_directfb2.c22
-rw-r--r--libvo/vo_directx.c22
-rw-r--r--libvo/vo_dxr2.c17
-rw-r--r--libvo/vo_dxr3.c41
-rw-r--r--libvo/vo_fbdev.c26
-rw-r--r--libvo/vo_fbdev2.c2
-rw-r--r--libvo/vo_ggi.c12
-rw-r--r--libvo/vo_gif89a.c2
-rw-r--r--libvo/vo_gl.c32
-rw-r--r--libvo/vo_gl2.c24
-rw-r--r--libvo/vo_ivtv.c4
-rw-r--r--libvo/vo_jpeg.c14
-rw-r--r--libvo/vo_kva.c22
-rw-r--r--libvo/vo_macosx.m7
-rw-r--r--libvo/vo_md5sum.c8
-rw-r--r--libvo/vo_mpegpes.c11
-rw-r--r--libvo/vo_null.c2
-rw-r--r--libvo/vo_png.c69
-rw-r--r--libvo/vo_pnm.c18
-rw-r--r--libvo/vo_quartz.c4
-rw-r--r--libvo/vo_s3fb.c2
-rw-r--r--libvo/vo_sdl.c2
-rw-r--r--libvo/vo_svga.c31
-rw-r--r--libvo/vo_tdfx_vid.c2
-rw-r--r--libvo/vo_tdfxfb.c2
-rw-r--r--libvo/vo_tga.c2
-rw-r--r--libvo/vo_v4l2.c4
-rw-r--r--libvo/vo_vdpau.c25
-rw-r--r--libvo/vo_vesa.c32
-rw-r--r--libvo/vo_wii.c2
-rw-r--r--libvo/vo_winvidix.c31
-rw-r--r--libvo/vo_x11.c22
-rw-r--r--libvo/vo_xover.c44
-rw-r--r--libvo/vo_xv.c963
-rw-r--r--libvo/vo_xvidix.c28
-rw-r--r--libvo/vo_xvmc.c22
-rw-r--r--libvo/vo_xvr100.c2
-rw-r--r--libvo/vo_yuv4mpeg.c2
-rw-r--r--libvo/vo_zr.c2
-rw-r--r--libvo/vo_zr2.c2
-rw-r--r--libvo/vosub_vidix.c66
-rw-r--r--libvo/vosub_vidix.h4
-rw-r--r--libvo/w32_common.c17
-rw-r--r--libvo/x11_common.c939
-rw-r--r--libvo/x11_common.h188
72 files changed, 2042 insertions, 1934 deletions
diff --git a/libvo/aspect.c b/libvo/aspect.c
index e54e8deb43..367cdec076 100644
--- a/libvo/aspect.c
+++ b/libvo/aspect.c
@@ -19,9 +19,11 @@
/* Stuff for correct aspect scaling. */
#include "aspect.h"
#include "geometry.h"
+#include "video_out.h"
//#ifndef ASPECT_TEST
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
//#endif
//#define ASPECT_DEBUG
@@ -30,80 +32,66 @@
#include <stdio.h>
#endif
-int vo_panscan_x = 0;
-int vo_panscan_y = 0;
-float vo_panscan_amount = 0;
-float vo_panscanrange = 1.0;
-
#include "video_out.h"
-float force_monitor_aspect=0;
-float monitor_aspect=0;
-float monitor_pixel_aspect=1;
-extern float movie_aspect;
-
-static struct {
- int orgw; // real width
- int orgh; // real height
- int prew; // prescaled width
- int preh; // prescaled height
- int scrw; // horizontal resolution
- int scrh; // vertical resolution
- float asp;
-} aspdat;
-
-void aspect_save_orig(int orgw, int orgh){
+void aspect_save_orig(struct vo *vo, int orgw, int orgh)
+{
#ifdef ASPECT_DEBUG
printf("aspect_save_orig %dx%d \n",orgw,orgh);
#endif
- aspdat.orgw = orgw;
- aspdat.orgh = orgh;
+ vo->aspdat.orgw = orgw;
+ vo->aspdat.orgh = orgh;
}
-void aspect_save_prescale(int prew, int preh){
+void aspect_save_prescale(struct vo *vo, int prew, int preh)
+{
#ifdef ASPECT_DEBUG
printf("aspect_save_prescale %dx%d \n",prew,preh);
#endif
- aspdat.prew = prew;
- aspdat.preh = preh;
+ vo->aspdat.prew = prew;
+ vo->aspdat.preh = preh;
}
-void aspect_save_screenres(int scrw, int scrh){
+void aspect_save_screenres(struct vo *vo, int scrw, int scrh)
+{
#ifdef ASPECT_DEBUG
printf("aspect_save_screenres %dx%d \n",scrw,scrh);
#endif
- aspdat.scrw = scrw;
- aspdat.scrh = scrh;
- if (force_monitor_aspect)
- monitor_aspect = force_monitor_aspect;
- else
- monitor_aspect = monitor_pixel_aspect * scrw / scrh;
+ struct MPOpts *opts = vo->opts;
+ vo->aspdat.scrw = scrw;
+ vo->aspdat.scrh = scrh;
+ if (opts->force_monitor_aspect)
+ vo->monitor_aspect = opts->force_monitor_aspect;
+ else
+ vo->monitor_aspect = opts->monitor_pixel_aspect * scrw / scrh;
}
/* aspect is called with the source resolution and the
* resolution, that the scaled image should fit into
*/
-void aspect_fit(int *srcw, int *srch, int fitw, int fith){
+void aspect_fit(struct vo *vo, int *srcw, int *srch, int fitw, int fith)
+{
+ struct aspect_data *aspdat = &vo->aspdat;
int tmpw;
#ifdef ASPECT_DEBUG
- printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
+ printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat->scrw,aspdat->scrh,
monitor_aspect);
- printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
+ printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat->prew,aspdat->preh);
#endif
*srcw = fitw;
- *srch = (int)(((float)fitw / (float)aspdat.prew * (float)aspdat.preh)
- * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
+ *srch = (int)(((float)fitw / (float)aspdat->prew * (float)aspdat->preh)
+ * ((float)aspdat->scrh / ((float)aspdat->scrw / vo->monitor_aspect)));
*srch+= *srch%2; // round
#ifdef ASPECT_DEBUG
- printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
+ printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat->prew,aspdat->preh);
#endif
- if(*srch>aspdat.scrh || *srch<aspdat.orgh){
- tmpw = (int)(((float)fith / (float)aspdat.preh * (float)aspdat.prew)
- * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
+ if(*srch>aspdat->scrh || *srch<aspdat->orgh){
+ tmpw = (int)(((float)fith / (float)aspdat->preh * (float)aspdat->prew)
+ * ((float)aspdat->scrw / ((float)aspdat->scrh / (1.0/vo->monitor_aspect))));
tmpw+= tmpw%2; // round
- if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){
+ if(tmpw<=aspdat->scrw /*&& tmpw>=aspdat->orgw*/){
*srch = fith;
*srcw = tmpw;
}else{
@@ -114,47 +102,48 @@ void aspect_fit(int *srcw, int *srch, int fitw, int fith){
#endif
}
}
- aspdat.asp=*srcw / (float)*srch;
+ aspdat->asp=*srcw / (float)*srch;
#ifdef ASPECT_DEBUG
- printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
+ printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat->prew,aspdat->preh);
#endif
}
-void aspect(int *srcw, int *srch, int zoom){
- int fitw = zoom ? aspdat.scrw : aspdat.prew;
- int fith = zoom ? aspdat.scrh : aspdat.preh;
+void aspect(struct vo *vo, int *srcw, int *srch, int zoom){
+ int fitw = zoom ? vo->aspdat.scrw : vo->aspdat.prew;
+ int fith = zoom ? vo->aspdat.scrh : vo->aspdat.preh;
if( !zoom && geometry_wh_changed ) {
#ifdef ASPECT_DEBUG
printf("aspect(0) no aspect forced!\n");
#endif
return; // the user doesn't want to fix aspect
}
- aspect_fit(srcw, srch, fitw, fith);
+ aspect_fit(vo, srcw, srch, fitw, fith);
}
-void panscan_init( void )
+void panscan_init(struct vo *vo)
{
- vo_panscan_x=0;
- vo_panscan_y=0;
- vo_panscan_amount=0.0f;
+ vo->panscan_x = 0;
+ vo->panscan_y = 0;
+ vo->panscan_amount = 0.0f;
}
-void panscan_calc( void )
+void panscan_calc(struct vo *vo)
{
int fwidth,fheight;
int vo_panscan_area;
-
- if (vo_panscanrange > 0) {
- aspect(&fwidth,&fheight,A_ZOOM);
- vo_panscan_area = (aspdat.scrh-fheight);
- if (!vo_panscan_area)
- vo_panscan_area = aspdat.scrw - fwidth;
- vo_panscan_area *= vo_panscanrange;
- } else
- vo_panscan_area = -vo_panscanrange * aspdat.scrh;
-
- vo_panscan_amount = vo_fs ? vo_panscan : 0;
- vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp;
- vo_panscan_y = vo_panscan_area * vo_panscan_amount;
+ struct MPOpts *opts = vo->opts;
+
+ if (opts->vo_panscanrange > 0) {
+ aspect(vo, &fwidth, &fheight, A_ZOOM);
+ vo_panscan_area = (vo->aspdat.scrh - fheight);
+ if (!vo_panscan_area)
+ vo_panscan_area = vo->aspdat.scrw - fwidth;
+ vo_panscan_area *= opts->vo_panscanrange;
+ } else
+ vo_panscan_area = -opts->vo_panscanrange * vo->aspdat.scrh;
+
+ vo->panscan_amount = vo_fs ? vo_panscan : 0;
+ vo->panscan_x = vo_panscan_area * vo->panscan_amount * vo->aspdat.asp;
+ vo->panscan_y = vo_panscan_area * vo->panscan_amount;
}
diff --git a/libvo/aspect.h b/libvo/aspect.h
index 0c741d4ae3..89839e2c94 100644
--- a/libvo/aspect.h
+++ b/libvo/aspect.h
@@ -20,23 +20,35 @@
#define MPLAYER_ASPECT_H
/* Stuff for correct aspect scaling. */
-extern int vo_panscan_x;
-extern int vo_panscan_y;
-extern float vo_panscan_amount;
+struct vo;
+void panscan_init(struct vo *vo);
+void panscan_calc(struct vo *vo);
-void panscan_init(void);
-void panscan_calc(void);
+void aspect_save_orig(struct vo *vo, int orgw, int orgh);
-void aspect_save_orig(int orgw, int orgh);
+void aspect_save_prescale(struct vo *vo, int prew, int preh);
-void aspect_save_prescale(int prew, int preh);
-
-void aspect_save_screenres(int scrw, int scrh);
+void aspect_save_screenres(struct vo *vo, int scrw, int scrh);
#define A_ZOOM 1
#define A_NOZOOM 0
-void aspect(int *srcw, int *srch, int zoom);
-void aspect_fit(int *srcw, int *srch, int fitw, int fith);
+void aspect(struct vo *vo, int *srcw, int *srch, int zoom);
+void aspect_fit(struct vo *vo, int *srcw, int *srch, int fitw, int fith);
+
+
+#ifdef IS_OLD_VO
+#define vo_panscan_x global_vo->panscan_x
+#define vo_panscan_y global_vo->panscan_y
+#define vo_panscan_amount global_vo->panscan_amount
+#define monitor_aspect global_vo->monitor_aspect
+
+#define panscan_init() panscan_init(global_vo)
+#define panscan_calc() panscan_calc(global_vo)
+#define aspect_save_orig(...) aspect_save_orig(global_vo, __VA_ARGS__)
+#define aspect_save_prescale(...) aspect_save_prescale(global_vo, __VA_ARGS__)
+#define aspect_save_screenres(...) aspect_save_screenres(global_vo, __VA_ARGS__)
+#define aspect(...) aspect(global_vo, __VA_ARGS__)
+#endif
#endif /* MPLAYER_ASPECT_H */
diff --git a/libvo/font_load.h b/libvo/font_load.h
index 5371b54cbf..c945d11277 100644
--- a/libvo/font_load.h
+++ b/libvo/font_load.h
@@ -80,7 +80,6 @@ typedef struct font_desc {
} font_desc_t;
extern font_desc_t* vo_font;
-extern font_desc_t* sub_font;
extern char *subtitle_font_encoding;
extern float text_font_scale_factor;
diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c
index 20d673a0fc..38b6178e5c 100644
--- a/libvo/font_load_ft.c
+++ b/libvo/font_load_ft.c
@@ -84,13 +84,13 @@ static FT_Library library;
#define OSD_CHARSET_SIZE 15
-static FT_ULong osd_charset[OSD_CHARSET_SIZE] =
+static const FT_ULong osd_charset[OSD_CHARSET_SIZE] =
{
0xe001, 0xe002, 0xe003, 0xe004, 0xe005, 0xe006, 0xe007, 0xe008,
0xe009, 0xe00a, 0xe00b, 0xe010, 0xe011, 0xe012, 0xe013
};
-static FT_ULong osd_charcodes[OSD_CHARSET_SIZE] =
+static const FT_ULong osd_charcodes[OSD_CHARSET_SIZE] =
{
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0a,0x0b,0x10,0x11,0x12,0x13
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index 596f99c0b9..b65023f93e 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -32,6 +32,7 @@
#include <string.h>
#include <ctype.h>
#include <math.h>
+#include "old_vo_defines.h"
#include "gl_common.h"
#include "libavutil/common.h"
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index 6f9ec6f1e3..978866e340 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -353,18 +353,18 @@ void glDisableYUVConversion(GLenum target, int type);
/** \} */
#ifdef GL_WIN32
-#define vo_border() vo_w32_border()
+#define vo_gl_border(vo) vo_w32_border()
#define vo_check_events() vo_w32_check_events()
#define vo_fullscreen() vo_w32_fullscreen()
-#define vo_ontop() vo_w32_ontop()
+#define vo_gl_ontop() vo_w32_ontop()
#define vo_uninit() vo_w32_uninit()
int setGlWindow(int *vinfo, HGLRC *context, HWND win);
void releaseGlContext(int *vinfo, HGLRC *context);
#else
-#define vo_border() vo_x11_border()
+#define vo_gl_border(vo) vo_x11_border(vo)
#define vo_check_events() vo_x11_check_events(mDisplay)
#define vo_fullscreen() vo_x11_fullscreen()
-#define vo_ontop() vo_x11_ontop()
+#define vo_gl_ontop() vo_x11_ontop()
#define vo_uninit() vo_x11_uninit()
int setGlWindow(XVisualInfo **vinfo, GLXContext *context, Window win);
void releaseGlContext(XVisualInfo **vinfo, GLXContext *context);
diff --git a/libvo/mga_common.c b/libvo/mga_common.c
index 69c8f6322d..06d374f9fd 100644
--- a/libvo/mga_common.c
+++ b/libvo/mga_common.c
@@ -23,6 +23,7 @@
#include "libmpcodecs/vf_scale.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "old_vo_wrapper.h"
// mga_vid drawing functions
static void set_window( void ); /* forward declaration to kill warnings */
@@ -246,7 +247,7 @@ static void mga_fullscreen(void)
}
#endif
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -257,11 +258,12 @@ static int control(uint32_t request, void *data, ...)
return draw_image(data);
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
short value;
uint32_t luma,prev;
+ struct voctrl_set_equalizer_args *args = data;
- if ( strcmp( data,"brightness" ) && strcmp( data,"contrast" ) ) return VO_FALSE;
+ if (strcmp(args->name, "brightness") && strcmp(args->name, "contrast"))
+ return VO_FALSE;
if (ioctl(f,MGA_VID_GET_LUMA,&prev)) {
perror("Error in mga_vid_config ioctl()");
@@ -271,15 +273,13 @@ static int control(uint32_t request, void *data, ...)
// printf("GET: 0x%4X 0x%4X \n",(prev>>16),(prev&0xffff));
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
+ value = args->value;
// printf("value: %d -> ",value);
value=((value+100)*255)/200-128; // maps -100=>-128 and +100=>127
// printf("%d \n",value);
- if(!strcmp(data,"contrast"))
+ if (!strcmp(args->name, "contrast"))
luma = (prev&0xFFFF0000)|(value&0xFFFF);
else
luma = (prev&0xFFFF)|(value<<16);
@@ -295,12 +295,12 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int * value;
short val;
uint32_t luma;
+ struct voctrl_get_equalizer_args *args = data;
- if ( strcmp( data,"brightness" ) && strcmp( data,"contrast" ) ) return VO_FALSE;
+ if (strcmp(args->name, "brightness") && strcmp(args->name, "contrast"))
+ return VO_FALSE;
if (ioctl(f,MGA_VID_GET_LUMA,&luma)) {
perror("Error in mga_vid_config ioctl()");
@@ -308,16 +308,12 @@ static int control(uint32_t request, void *data, ...)
return VO_FALSE;
}
- if ( !strcmp( data,"contrast" ) )
+ if (!strcmp(args->name, "contrast"))
val=(luma & 0xFFFF);
else
val=(luma >> 16);
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- *value = (val*200)/255;
+ *args->valueptr = (val*200)/255;
return VO_TRUE;
}
diff --git a/libvo/old_vo_defines.h b/libvo/old_vo_defines.h
new file mode 100644
index 0000000000..feded12d5b
--- /dev/null
+++ b/libvo/old_vo_defines.h
@@ -0,0 +1,24 @@
+#ifndef MPLAYER_OLD_VO_DEFINES_H
+#define MPLAYER_OLD_VO_DEFINES_H
+
+#include "options.h"
+#include "video_out.h"
+#include "old_vo_wrapper.h"
+
+// Triggers more defines in x11_common.h
+#define IS_OLD_VO 1
+
+#define vo_ontop global_vo->opts->vo_ontop
+#define vo_config_count global_vo->config_count
+#define vo_dx global_vo->dx
+#define vo_dy global_vo->dy
+#define vo_dwidth global_vo->dwidth
+#define vo_dheight global_vo->dheight
+#define vo_dbpp global_vo->opts->vo_dbpp
+#define vo_screenwidth global_vo->opts->vo_screenwidth
+#define vo_screenheight global_vo->opts->vo_screenheight
+#define vidmode global_vo->opts->vidmode
+#define movie_aspect global_vo->opts->movie_aspect
+
+#define calc_src_dst_rects(...) calc_src_dst_rects(global_vo, __VA_ARGS__)
+#endif
diff --git a/libvo/old_vo_wrapper.c b/libvo/old_vo_wrapper.c
new file mode 100644
index 0000000000..bdbc8b8349
--- /dev/null
+++ b/libvo/old_vo_wrapper.c
@@ -0,0 +1,116 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include <stdint.h>
+#include "old_vo_wrapper.h"
+#include "video_out.h"
+#include "sub.h"
+
+struct vo *global_vo;
+struct osd_state *global_osd;
+
+int old_vo_preinit(struct vo *vo, const char *arg)
+{
+ global_vo = vo;
+ return vo->driver->old_functions->preinit(arg);
+}
+
+
+int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height,
+ uint32_t flags, char *title, uint32_t format)
+{
+ return vo->driver->old_functions->config(width, height, d_width,
+ d_height, flags, title, format);
+}
+
+
+int old_vo_control(struct vo *vo, uint32_t request, void *data)
+{
+ return vo->driver->old_functions->control(request, data);
+}
+
+
+int old_vo_draw_frame(struct vo *vo, uint8_t *src[])
+{
+ return vo->driver->old_functions->draw_frame(src);
+}
+
+
+int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
+ int w, int h, int x, int y)
+{
+ return vo->driver->old_functions->draw_slice(src, stride, w, h, x, y);
+}
+
+
+void old_vo_draw_osd(struct vo *vo, struct osd_state *osd)
+{
+ global_osd = osd;
+ vo->driver->old_functions->draw_osd();
+}
+
+
+void old_vo_flip_page(struct vo *vo)
+{
+ vo->driver->old_functions->flip_page();
+}
+
+
+void old_vo_check_events(struct vo *vo)
+{
+ vo->driver->old_functions->check_events();
+}
+
+
+void old_vo_uninit(struct vo *vo)
+{
+ vo->driver->old_functions->uninit();
+}
+
+
+static void draw_alpha_wrapper(void *ctx, int x0, int y0, int w, int h,
+ unsigned char *src, unsigned char *srca,
+ int stride)
+{
+ void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) = ctx;
+ draw_alpha(x0, y0, w, h, src, srca, stride);
+}
+
+
+void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
+{
+ osd_draw_text(global_osd, dxs, dys, draw_alpha_wrapper, draw_alpha);
+}
+
+void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
+ int right_border, int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(int x0, int y0, int w,int h,
+ unsigned char* src,
+ unsigned char *srca, int stride))
+{
+ osd_draw_text_ext(global_osd, dxs, dys, left_border, top_border,
+ right_border, bottom_border, orig_w, orig_h,
+ draw_alpha_wrapper, draw_alpha);
+}
+
+int vo_update_osd(int dxs, int dys)
+{
+ return osd_update(global_osd, dxs, dys);
+}
diff --git a/libvo/old_vo_wrapper.h b/libvo/old_vo_wrapper.h
new file mode 100644
index 0000000000..250a1187fe
--- /dev/null
+++ b/libvo/old_vo_wrapper.h
@@ -0,0 +1,29 @@
+#ifndef MPLAYER_OLD_VO_WRAPPER_H
+#define MPLAYER_OLD_VO_WRAPPER_H
+
+#include <stdint.h>
+#include "video_out.h"
+
+extern struct vo *global_vo;
+extern struct osd_state *global_osd;
+
+int old_vo_preinit(struct vo *vo, const char *);
+int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height,
+ uint32_t flags, char *title, uint32_t format);
+int old_vo_control(struct vo *vo, uint32_t request, void *data);
+int old_vo_draw_frame(struct vo *vo, uint8_t *src[]);
+int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
+ int w, int h, int x, int y);
+void old_vo_draw_osd(struct vo *vo, struct osd_state *osd);
+void old_vo_flip_page(struct vo *vo);
+void old_vo_check_events(struct vo *vo);
+void old_vo_uninit(struct vo *vo);
+
+void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
+void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
+ int right_border, int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(int x0, int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride));
+int vo_update_osd(int dxs, int dys);
+
+#endif
diff --git a/libvo/spuenc.c b/libvo/spuenc.c
index 41303aee3f..a1e457c282 100644
--- a/libvo/spuenc.c
+++ b/libvo/spuenc.c
@@ -229,50 +229,3 @@ pixbuf_encode_rle(int x, int y, int w, int h, char *inbuf, int stride,encodedat
}
encode_do_control(x,y, ed, &pb);
}
-
-
-void
-pixbuf_load_xpm( pixbuf* pb, char* xpm[] ) {
- int colors, chrs, l, n;
- char c[4], table[256];
- unsigned char *b, *i;
-
- sscanf( xpm[0], "%d %d %d %d", &pb->x, &pb->y, &colors, &chrs);
- if( colors > 4 ) {
- fprintf( stderr, "the pixmap MUST be 4 colors or less\n");
- exit (-1);
- }
- if( chrs != 1 ) {
- fprintf( stderr, "the XPM format MUST be 1 char per pixel\n");
- exit (-1);
- }
- if( pb->x > 0xFFF || pb->y > 0xFFF ) {
- fprintf( stderr, "the size is excesive\n");
- exit (-1);
- }
-
- for( l=0; l<colors; l++ ) {
- n= sscanf( xpm[l+1], "%c c #%x", &c[l], &pb->rgb[l]);
- if( n < 2 ) {
- /* this one is transparent */
- pb->rgb[l]=0xff000000;
- }
- table[(int)c[l]]=l;
- }
-
- pb->pixels= malloc( pb->x * pb->y );
- b= pb->pixels;
-
- for( l= colors+1; l <= pb->y + colors; l++ ) {
- i= xpm[l];
- while( (int)*i) {
- *b++ = table[*i++];
- }
- }
-}
-
-void
-pixbuf_delete( pixbuf* pb ) {
- free( pb->pixels );
-}
-
diff --git a/libvo/spuenc.h b/libvo/spuenc.h
index 5f27680876..d19732a98f 100644
--- a/libvo/spuenc.h
+++ b/libvo/spuenc.h
@@ -41,6 +41,5 @@ typedef struct {
} encodedata;
void pixbuf_encode_rle(int x, int y, int w, int h, char *inbuf, int stride, encodedata *ed);
-void pixbuf_delete(pixbuf* pb);
#endif /* MPLAYER_SPUENC_H */
diff --git a/libvo/sub.c b/libvo/sub.c
index 597c121498..987ab76ba0 100644
--- a/libvo/sub.c
+++ b/libvo/sub.c
@@ -32,6 +32,7 @@
#include "stream/tv.h"
#include "osdep/timer.h"
+#include "talloc.h"
#include "mplayer.h"
#include "mp_msg.h"
#include "help_mp.h"
@@ -64,7 +65,7 @@ struct osd_text_p {
};
//^
-char * sub_osd_names[]={
+char * const sub_osd_names[]={
MSGTR_VO_SUB_Seekbar,
MSGTR_VO_SUB_Play,
MSGTR_VO_SUB_Pause,
@@ -79,13 +80,11 @@ char * sub_osd_names[]={
MSGTR_VO_SUB_Hue,
MSGTR_VO_SUB_Balance
};
-char * sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
+char * const sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
//static int vo_font_loaded=-1;
font_desc_t* vo_font=NULL;
-font_desc_t* sub_font=NULL;
-unsigned char* vo_osd_text=NULL;
#ifdef CONFIG_TV_TELETEXT
void* vo_osd_teletext_page=NULL;
int vo_osd_teletext_half = 0;
@@ -167,9 +166,11 @@ static void alloc_buf(mp_osd_obj_t* obj)
}
// renders the buffer
-inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
+inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx)
+{
if (obj->allocated > 0) {
- draw_alpha(obj->bbox.x1,obj->bbox.y1,
+ draw_alpha(ctx,
+ obj->bbox.x1,obj->bbox.y1,
obj->bbox.x2-obj->bbox.x1,
obj->bbox.y2-obj->bbox.y1,
obj->bitmap_buffer,
@@ -192,8 +193,10 @@ no_utf8:
return c;
}
-inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
- const char *cp=vo_osd_text;
+inline static void vo_update_text_osd(struct osd_state *osd, mp_osd_obj_t* obj,
+ int dxs, int dys)
+{
+ const char *cp = osd->osd_text;
int x=20;
int h=0;
int font;
@@ -214,7 +217,7 @@ inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
alloc_buf(obj);
- cp=vo_osd_text;
+ cp = osd->osd_text;
x = obj->x;
while (*cp){
uint16_t c=utf8_get_char(&cp);
@@ -669,7 +672,7 @@ inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){
subtitle* vo_sub=NULL;
-inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
+inline static void vo_update_text_sub(struct osd_state *osd, mp_osd_obj_t* obj,int dxs,int dys){
unsigned char *t;
int c,i,j,l,x,y,font,prevc,counter;
int k;
@@ -678,10 +681,11 @@ inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
int xmin=dxs,xmax=0;
int h,lasth;
int xtblc, utblc;
+ struct font_desc *sub_font = osd->sub_font;
obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
- if(!vo_sub || !sub_font || !sub_visibility || (sub_font->font[40]<0)){
+ if(!vo_sub || !osd->sub_font || !sub_visibility || (sub_font->font[40]<0)){
obj->flags&=~OSDFLAG_VISIBLE;
return;
}
@@ -1052,9 +1056,9 @@ inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys)
obj->flags |= OSDFLAG_BBOX;
}
-inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride))
+inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride), void *ctx)
{
- spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha);
+ spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha, ctx);
}
void *vo_spudec=NULL;
@@ -1078,7 +1082,8 @@ static mp_osd_obj_t* new_osd_obj(int type){
return osd;
}
-void free_osd_list(void){
+void osd_free(struct osd_state *osd)
+{
mp_osd_obj_t* obj=vo_osd_list;
while(obj){
mp_osd_obj_t* next=obj->next;
@@ -1088,12 +1093,15 @@ void free_osd_list(void){
obj=next;
}
vo_osd_list=NULL;
+ talloc_free(osd);
}
#define FONT_LOAD_DEFER 6
-int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
- int right_border, int bottom_border, int orig_w, int orig_h){
+int osd_update_ext(struct osd_state *osd, int dxs, int dys, int left_border,
+ int top_border, int right_border, int bottom_border,
+ int orig_w, int orig_h)
+{
mp_osd_obj_t* obj=vo_osd_list;
int chg=0;
#ifdef CONFIG_FREETYPE
@@ -1123,20 +1131,20 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
force_load_font = 0;
load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
if (sub_font_name)
- load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, sub_font_name, text_font_scale_factor);
else
- load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, font_name, text_font_scale_factor);
prev_dxs = dxs;
prev_dys = dys;
defer_counter = 0;
} else {
if (!vo_font)
load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
- if (!sub_font) {
+ if (!osd->sub_font) {
if (sub_font_name)
- load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, sub_font_name, text_font_scale_factor);
else
- load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, font_name, text_font_scale_factor);
}
}
#endif
@@ -1152,7 +1160,7 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
break;
#endif
case OSDTYPE_SUBTITLE:
- vo_update_text_sub(obj,dxs,dys);
+ vo_update_text_sub(osd, obj,dxs,dys);
break;
#ifdef CONFIG_TV_TELETEXT
case OSDTYPE_TELETEXT:
@@ -1171,8 +1179,8 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
obj->flags&=~OSDFLAG_VISIBLE;
break;
case OSDTYPE_OSD:
- if(vo_font && vo_osd_text && vo_osd_text[0]){
- vo_update_text_osd(obj,dxs,dys); // update bbox
+ if(vo_font && osd->osd_text[0]){
+ vo_update_text_osd(osd, obj, dxs, dys); // update bbox
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
} else
obj->flags&=~OSDFLAG_VISIBLE;
@@ -1212,16 +1220,20 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
return chg;
}
-int vo_update_osd(int dxs, int dys) {
- return vo_update_osd_ext(dxs, dys, 0, 0, 0, 0, dxs, dys);
+int osd_update(struct osd_state *osd, int dxs, int dys)
+{
+ return osd_update_ext(osd, dxs, dys, 0, 0, 0, 0, dxs, dys);
}
-void vo_init_osd(void){
+struct osd_state *osd_create(void)
+{
+ struct osd_state *osd = talloc_zero(NULL, struct osd_state);
+ *osd = (struct osd_state){
+ };
if(!draw_alpha_init_flag){
draw_alpha_init_flag=1;
vo_draw_alpha_init();
}
- if(vo_osd_list) free_osd_list();
// temp hack, should be moved to mplayer/mencoder later
new_osd_obj(OSDTYPE_OSD);
new_osd_obj(OSDTYPE_SUBTITLE);
@@ -1236,13 +1248,16 @@ void vo_init_osd(void){
#ifdef CONFIG_FREETYPE
force_load_font = 1;
#endif
+ return osd;
}
int vo_osd_changed_flag=0;
-void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
+void osd_remove_text(struct osd_state *osd, int dxs, int dys,
+ void (*remove)(int x0, int y0, int w, int h))
+{
mp_osd_obj_t* obj=vo_osd_list;
- vo_update_osd(dxs,dys);
+ osd_update(osd, dxs, dys);
while(obj){
if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) &&
(obj->flags&OSDFLAG_OLD_BBOX)){
@@ -1258,17 +1273,24 @@ void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
}
}
-void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
- int right_border, int bottom_border, int orig_w, int orig_h,
- void (*draw_alpha)(int x0, int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) {
+void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys,
+ int left_border, int top_border, int right_border,
+ int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w,
+ int h, unsigned char* src,
+ unsigned char *srca,
+ int stride),
+ void *ctx)
+{
mp_osd_obj_t* obj=vo_osd_list;
- vo_update_osd_ext(dxs, dys, left_border, top_border, right_border, bottom_border, orig_w, orig_h);
+ osd_update_ext(osd, dxs, dys, left_border, top_border, right_border,
+ bottom_border, orig_w, orig_h);
while(obj){
if(obj->flags&OSDFLAG_VISIBLE){
vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
switch(obj->type){
case OSDTYPE_SPU:
- vo_draw_spudec_sub(obj, draw_alpha); // FIXME
+ vo_draw_spudec_sub(obj, draw_alpha, ctx); // FIXME
break;
#ifdef CONFIG_DVDNAV
case OSDTYPE_DVDNAV:
@@ -1279,7 +1301,7 @@ void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
case OSDTYPE_OSD:
case OSDTYPE_SUBTITLE:
case OSDTYPE_PROGBAR:
- vo_draw_text_from_buffer(obj,draw_alpha);
+ vo_draw_text_from_buffer(obj, draw_alpha, ctx);
break;
}
obj->old_bbox=obj->bbox;
@@ -1290,8 +1312,13 @@ void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
}
}
-void vo_draw_text(int dxs, int dys, void (*draw_alpha)(int x0, int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) {
- vo_draw_text_ext(dxs, dys, 0, 0, 0, 0, dxs, dys, draw_alpha);
+void osd_draw_text(struct osd_state *osd, int dxs, int dys,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h,
+ unsigned char* src, unsigned char *srca,
+ int stride),
+ void *ctx)
+{
+ osd_draw_text_ext(osd, dxs, dys, 0, 0, 0, 0, dxs, dys, draw_alpha, ctx);
}
static int vo_osd_changed_status = 0;
diff --git a/libvo/sub.h b/libvo/sub.h
index 978b4c940d..d5a30e0b86 100644
--- a/libvo/sub.h
+++ b/libvo/sub.h
@@ -66,14 +66,16 @@ typedef struct mp_osd_obj_s {
unsigned char *bitmap_buffer;
} mp_osd_obj_t;
+struct osd_state {
+ unsigned char osd_text[128];
+ struct font_desc *sub_font;
+};
#include "subreader.h"
extern sub_data* subdata; //currently used subtitles
extern subtitle* vo_sub;
-extern unsigned char* vo_osd_text;
-
extern void* vo_osd_teletext_page;
extern int vo_osd_teletext_half;
extern int vo_osd_teletext_mode;
@@ -105,8 +107,8 @@ extern void* vo_vobsub;
#define OSD_PB_1 0x13
/* now in textform */
-extern char * sub_osd_names[];
-extern char * sub_osd_names_short[];
+extern char * const sub_osd_names[];
+extern char * const sub_osd_names_short[];
extern int sub_unicode;
extern int sub_utf8;
@@ -122,17 +124,27 @@ extern int spu_alignment;
extern int spu_aamode;
extern float spu_gaussvar;
-void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
-void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
- int right_border, int bottom_border, int orig_w, int orig_h,
- void (*draw_alpha)(int x0, int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
-void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h));
-
-void vo_init_osd(void);
-int vo_update_osd(int dxs,int dys);
+void osd_draw_text(struct osd_state *osd, int dxs, int dys,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h,
+ unsigned char* src, unsigned char *srca,
+ int stride),
+ void *ctx);
+void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys,
+ int left_border, int top_border, int right_border,
+ int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w,
+ int h, unsigned char* src,
+ unsigned char *srca,
+ int stride),
+ void *ctx);
+void osd_remove_text(struct osd_state *osd, int dxs, int dys,
+ void (*remove)(int x0, int y0, int w, int h));
+
+struct osd_state *osd_create(void);
+int osd_update(struct osd_state *osd, int dxs, int dys);
int vo_osd_changed(int new_value);
int vo_osd_check_range_update(int,int,int,int);
-void free_osd_list(void);
+void osd_free(struct osd_state *osd);
extern int vo_osd_changed_flag;
@@ -143,4 +155,9 @@ unsigned utf8_get_char(const char **str);
void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey);
#endif
+
+#ifdef IS_OLD_VO
+#define vo_remove_text(...) osd_remove_text(global_osd, __VA_ARGS__)
+#endif
+
#endif /* MPLAYER_SUB_H */
diff --git a/libvo/vesa_lvo.c b/libvo/vesa_lvo.c
index 53779a1c13..8875c3aa80 100644
--- a/libvo/vesa_lvo.c
+++ b/libvo/vesa_lvo.c
@@ -54,13 +54,13 @@ static uint8_t *lvo_mem = NULL;
static uint8_t next_frame;
static mga_vid_config_t mga_vid_config;
static unsigned image_bpp,image_height,image_width,src_format;
-uint32_t vlvo_control(uint32_t request, void *data, ...);
+int vlvo_control(uint32_t request, void *data);
#define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8)
#define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) )
#define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size))
-extern vo_functions_t video_out_vesa;
+extern struct vo_old_functions video_out_vesa;
int vlvo_preinit(const char *drvname)
{
@@ -166,7 +166,7 @@ void vlvo_term( void )
if(lvo_handler != -1) close(lvo_handler);
}
-uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
+int vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -206,7 +206,7 @@ uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,i
return 0;
}
-uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
+int vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
mp_msg(MSGT_VO,MSGL_DBG2, "vesa_lvo: vlvo_draw_slice() was called\n");}
@@ -224,7 +224,7 @@ uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y
return 0;
}
-uint32_t vlvo_draw_frame(uint8_t *image[])
+int vlvo_draw_frame(uint8_t *image[])
{
/* Note it's very strange but sometime for YUY2 draw_frame is called */
fast_memcpy(lvo_mem,image[0],mga_vid_config.frame_size);
@@ -314,7 +314,7 @@ uint32_t vlvo_query_info(uint32_t format)
return VFCAP_CSP_SUPPORTED;
}
-uint32_t vlvo_control(uint32_t request, void *data, ...)
+int vlvo_control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vesa_lvo.h b/libvo/vesa_lvo.h
index 1e7887c8ae..9d77f60045 100644
--- a/libvo/vesa_lvo.h
+++ b/libvo/vesa_lvo.h
@@ -32,8 +32,8 @@ int vlvo_init(unsigned src_width,unsigned src_height,
void vlvo_term( void );
uint32_t vlvo_query_info(uint32_t format);
-uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y);
-uint32_t vlvo_draw_frame(uint8_t *src[]);
+int vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y);
+int vlvo_draw_frame(uint8_t *src[]);
void vlvo_flip_page(void);
void vlvo_draw_osd(void);
diff --git a/libvo/video_out.c b/libvo/video_out.c
index fac5ed90c9..eb348dd086 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -26,6 +26,8 @@
//#include <sys/mman.h>
#include "config.h"
+#include "options.h"
+#include "talloc.h"
#include "video_out.h"
#include "aspect.h"
#include "geometry.h"
@@ -34,27 +36,14 @@
#include "help_mp.h"
#include "osdep/shmem.h"
-
-//int vo_flags=0;
+#ifdef CONFIG_X11
+#include "x11_common.h"
+#endif
int xinerama_screen = -1;
int xinerama_x;
int xinerama_y;
-// currect resolution/bpp on screen: (should be autodetected by vo_init())
-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;
-int vo_dwidth=0;
-int vo_dheight=0;
-int vo_dbpp=0;
-
int vo_nomouse_input = 0;
int vo_grabpointer = 1;
int vo_doublebuffering = 1;
@@ -62,7 +51,6 @@ int vo_vsync = 0;
int vo_fs = 0;
int vo_fsmode = 0;
float vo_panscan = 0.0f;
-int vo_ontop = 0;
int vo_adapter_num=0;
int vo_refresh_rate=0;
int vo_keepaspect=1;
@@ -82,58 +70,58 @@ int vo_colorkey = 0x0000ff00; // default colorkey is green
//
// Externally visible list of all vo drivers
//
-extern vo_functions_t video_out_mga;
-extern vo_functions_t video_out_xmga;
-extern vo_functions_t video_out_x11;
-extern vo_functions_t video_out_xover;
-extern vo_functions_t video_out_xvmc;
-extern vo_functions_t video_out_vdpau;
-extern vo_functions_t video_out_xv;
-extern vo_functions_t video_out_gl;
-extern vo_functions_t video_out_gl2;
-extern vo_functions_t video_out_dga;
-extern vo_functions_t video_out_sdl;
-extern vo_functions_t video_out_3dfx;
-extern vo_functions_t video_out_tdfxfb;
-extern vo_functions_t video_out_s3fb;
-extern vo_functions_t video_out_wii;
-extern vo_functions_t video_out_null;
-extern vo_functions_t video_out_zr;
-extern vo_functions_t video_out_zr2;
-extern vo_functions_t video_out_bl;
-extern vo_functions_t video_out_fbdev;
-extern vo_functions_t video_out_fbdev2;
-extern vo_functions_t video_out_svga;
-extern vo_functions_t video_out_png;
-extern vo_functions_t video_out_ggi;
-extern vo_functions_t video_out_aa;
-extern vo_functions_t video_out_caca;
-extern vo_functions_t video_out_mpegpes;
-extern vo_functions_t video_out_yuv4mpeg;
-extern vo_functions_t video_out_direct3d;
-extern vo_functions_t video_out_directx;
-extern vo_functions_t video_out_kva;
-extern vo_functions_t video_out_dxr2;
-extern vo_functions_t video_out_dxr3;
-extern vo_functions_t video_out_ivtv;
-extern vo_functions_t video_out_v4l2;
-extern vo_functions_t video_out_jpeg;
-extern vo_functions_t video_out_gif89a;
-extern vo_functions_t video_out_vesa;
-extern vo_functions_t video_out_directfb;
-extern vo_functions_t video_out_dfbmga;
-extern vo_functions_t video_out_xvidix;
-extern vo_functions_t video_out_winvidix;
-extern vo_functions_t video_out_cvidix;
-extern vo_functions_t video_out_tdfx_vid;
-extern vo_functions_t video_out_xvr100;
-extern vo_functions_t video_out_tga;
-extern vo_functions_t video_out_macosx;
-extern vo_functions_t video_out_quartz;
-extern vo_functions_t video_out_pnm;
-extern vo_functions_t video_out_md5sum;
-
-const vo_functions_t* const video_out_drivers[] =
+extern struct vo_driver video_out_mga;
+extern struct vo_driver video_out_xmga;
+extern struct vo_driver video_out_x11;
+extern struct vo_driver video_out_xover;
+extern struct vo_driver video_out_xvmc;
+extern struct vo_driver video_out_vdpau;
+extern struct vo_driver video_out_xv;
+extern struct vo_driver video_out_gl;
+extern struct vo_driver video_out_gl2;
+extern struct vo_driver video_out_dga;
+extern struct vo_driver video_out_sdl;
+extern struct vo_driver video_out_3dfx;
+extern struct vo_driver video_out_tdfxfb;
+extern struct vo_driver video_out_s3fb;
+extern struct vo_driver video_out_wii;
+extern struct vo_driver video_out_null;
+extern struct vo_driver video_out_zr;
+extern struct vo_driver video_out_zr2;
+extern struct vo_driver video_out_bl;
+extern struct vo_driver video_out_fbdev;
+extern struct vo_driver video_out_fbdev2;
+extern struct vo_driver video_out_svga;
+extern struct vo_driver video_out_png;
+extern struct vo_driver video_out_ggi;
+extern struct vo_driver video_out_aa;
+extern struct vo_driver video_out_caca;
+extern struct vo_driver video_out_mpegpes;
+extern struct vo_driver video_out_yuv4mpeg;
+extern struct vo_driver video_out_direct3d;
+extern struct vo_driver video_out_directx;
+extern struct vo_driver video_out_kva;
+extern struct vo_driver video_out_dxr2;
+extern struct vo_driver video_out_dxr3;
+extern struct vo_driver video_out_ivtv;
+extern struct vo_driver video_out_v4l2;
+extern struct vo_driver video_out_jpeg;
+extern struct vo_driver video_out_gif89a;
+extern struct vo_driver video_out_vesa;
+extern struct vo_driver video_out_directfb;
+extern struct vo_driver video_out_dfbmga;
+extern struct vo_driver video_out_xvidix;
+extern struct vo_driver video_out_winvidix;
+extern struct vo_driver video_out_cvidix;
+extern struct vo_driver video_out_tdfx_vid;
+extern struct vo_driver video_out_xvr100;
+extern struct vo_driver video_out_tga;
+extern struct vo_driver video_out_macosx;
+extern struct vo_driver video_out_quartz;
+extern struct vo_driver video_out_pnm;
+extern struct vo_driver video_out_md5sum;
+
+const struct vo_driver *video_out_drivers[] =
{
#ifdef CONFIG_XVR100
&video_out_xvr100,
@@ -277,79 +265,152 @@ const vo_functions_t* const video_out_drivers[] =
NULL
};
-void list_video_out(void){
- int i=0;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
- while (video_out_drivers[i]) {
+
+static int vo_preinit(struct vo *vo, const char *arg)
+{
+ return vo->driver->preinit(vo, arg);
+}
+
+int vo_control(struct vo *vo, uint32_t request, void *data)
+{
+ return vo->driver->control(vo, request, data);
+}
+
+int vo_draw_frame(struct vo *vo, uint8_t *src[])
+{
+ if (!vo->config_ok)
+ return 0;
+ return vo->driver->draw_frame(vo, src);
+}
+
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y)
+{
+ return vo->driver->draw_slice(vo, src, stride, w, h, x, y);
+}
+
+void vo_draw_osd(struct vo *vo, struct osd_state *osd)
+{
+ if (!vo->config_ok)
+ return;
+ vo->driver->draw_osd(vo, osd);
+}
+
+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);
+}
+
+void vo_destroy(struct vo *vo)
+{
+ vo->driver->uninit(vo);
+ talloc_free(vo);
+}
+
+void list_video_out(void)
+{
+ int i = 0;
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
+ while (video_out_drivers[i]) {
const vo_info_t *info = video_out_drivers[i++]->info;
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
- }
- mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
+ }
+ mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
}
-const vo_functions_t* init_best_video_out(char** vo_list){
+struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
+ struct mp_fifo *key_fifo,
+ struct input_ctx *input_ctx)
+{
+ char **vo_list = opts->video_driver_list;
int i;
+ struct vo *vo = talloc_ptrtype(NULL, vo);
+ struct vo initial_values = {
+ .opts = opts,
+ .x11 = x11,
+ .key_fifo = key_fifo,
+ .input_ctx = input_ctx,
+ };
// first try the preferred drivers, with their optional subdevice param:
- if(vo_list && vo_list[0])
- while(vo_list[0][0]){
- char* vo=strdup(vo_list[0]);
- vo_subdevice=strchr(vo,':');
- if (!strcmp(vo, "pgm"))
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_PGM_HasBeenReplaced);
- if (!strcmp(vo, "md5"))
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_MD5_HasBeenReplaced);
- if(vo_subdevice){
- vo_subdevice[0]=0;
- ++vo_subdevice;
- }
- for(i=0;video_out_drivers[i];i++){
- const vo_functions_t* video_driver=video_out_drivers[i];
- const vo_info_t *info = video_driver->info;
- if(!strcmp(info->short_name,vo)){
- // name matches, try it
- if(!video_driver->preinit(vo_subdevice))
- {
- free(vo);
- return video_driver; // success!
+ if (vo_list && vo_list[0])
+ while (vo_list[0][0]) {
+ char *name = strdup(vo_list[0]);
+ vo_subdevice = strchr(name,':');
+ if (!strcmp(name, "pgm"))
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_PGM_HasBeenReplaced);
+ if (!strcmp(name, "md5"))
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_MD5_HasBeenReplaced);
+ if (vo_subdevice) {
+ vo_subdevice[0] = 0;
+ ++vo_subdevice;
+ }
+ for (i = 0; video_out_drivers[i]; i++) {
+ const struct vo_driver *video_driver = video_out_drivers[i];
+ const vo_info_t *info = video_driver->info;
+ if (!strcmp(info->short_name, name)) {
+ // name matches, try it
+ *vo = initial_values;
+ vo->driver = video_driver;
+ if (!vo_preinit(vo, vo_subdevice)) {
+ free(name);
+ return vo; // success!
+ }
}
}
+ // continue...
+ free(name);
+ ++vo_list;
+ if (!(vo_list[0]))
+ return NULL; // do NOT fallback to others
}
- // continue...
- free(vo);
- ++vo_list;
- if(!(vo_list[0])) return NULL; // do NOT fallback to others
- }
// now try the rest...
- vo_subdevice=NULL;
- for(i=0;video_out_drivers[i];i++){
- const vo_functions_t* video_driver=video_out_drivers[i];
- if(!video_driver->preinit(vo_subdevice))
- return video_driver; // success!
+ vo_subdevice = NULL;
+ for (i = 0; video_out_drivers[i]; i++) {
+ const struct vo_driver *video_driver = video_out_drivers[i];
+ *vo = initial_values;
+ vo->driver = video_driver;
+ if (!vo_preinit(vo, vo_subdevice))
+ return vo; // success!
}
+ free(vo);
return NULL;
}
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
- char *title, uint32_t format) {
- panscan_init();
- aspect_save_orig(width,height);
- aspect_save_prescale(d_width,d_height);
-
- if (vo->control(VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
- aspect(&d_width,&d_height,A_NOZOOM);
- vo_dx = (int)(vo_screenwidth - d_width) / 2;
- vo_dy = (int)(vo_screenheight - d_height) / 2;
- geometry(&vo_dx, &vo_dy, &d_width, &d_height,
- vo_screenwidth, vo_screenheight);
- vo_dx += xinerama_x;
- vo_dy += xinerama_y;
- vo_dwidth = d_width;
- vo_dheight = d_height;
- }
+ char *title, uint32_t format)
+{
+ struct MPOpts *opts = vo->opts;
+ panscan_init(vo);
+ aspect_save_orig(vo, width, height);
+ aspect_save_prescale(vo, d_width, d_height);
+
+ if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
+ aspect(vo, &d_width, &d_height, A_NOZOOM);
+ vo->dx = (int)(opts->vo_screenwidth - d_width) / 2;
+ vo->dy = (int)(opts->vo_screenheight - d_height) / 2;
+ geometry(&vo->dx, &vo->dy, &d_width, &d_height,
+ opts->vo_screenwidth, opts->vo_screenheight);
+ vo->dx += xinerama_x;
+ vo->dy += xinerama_y;
+ vo->dwidth = d_width;
+ vo->dheight = d_height;
+ }
- return vo->config(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;
}
/**
@@ -394,8 +455,10 @@ static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_siz
* \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires,
* may be NULL and only left and top are currently valid.
*/
-void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst,
- struct vo_rect *borders, const struct vo_rect *crop) {
+void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
+ struct vo_rect *src, struct vo_rect *dst,
+ struct vo_rect *borders, const struct vo_rect *crop)
+{
static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0};
int scaled_width = 0;
int scaled_height = 0;
@@ -404,25 +467,25 @@ void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, stru
src_height -= crop->top + crop->bottom;
if (src_width < 2) src_width = 2;
if (src_height < 2) src_height = 2;
- dst->left = 0; dst->right = vo_dwidth;
- dst->top = 0; dst->bottom = vo_dheight;
+ dst->left = 0; dst->right = vo->dwidth;
+ dst->top = 0; dst->bottom = vo->dheight;
src->left = 0; src->right = src_width;
src->top = 0; src->bottom = src_height;
if (borders) {
borders->left = 0; borders->top = 0;
}
if (vo_fs) {
- aspect(&scaled_width, &scaled_height, A_ZOOM);
- panscan_calc();
- scaled_width += vo_panscan_x;
- scaled_height += vo_panscan_y;
+ aspect(vo, &scaled_width, &scaled_height, A_ZOOM);
+ panscan_calc(vo);
+ scaled_width += vo->panscan_x;
+ scaled_height += vo->panscan_y;
if (borders) {
- borders->left = (vo_dwidth - scaled_width ) / 2;
- borders->top = (vo_dheight - scaled_height) / 2;
+ borders->left = (vo->dwidth - scaled_width ) / 2;
+ borders->top = (vo->dheight - scaled_height) / 2;
}
- src_dst_split_scaling(src_width, vo_dwidth, scaled_width,
+ src_dst_split_scaling(src_width, vo->dwidth, scaled_width,
&src->left, &src->right, &dst->left, &dst->right);
- src_dst_split_scaling(src_height, vo_dheight, scaled_height,
+ src_dst_split_scaling(src_height, vo->dheight, scaled_height,
&src->top, &src->bottom, &dst->top, &dst->bottom);
}
src->left += crop->left; src->right += crop->left;
diff --git a/libvo/video_out.h b/libvo/video_out.h
index f90123ddee..6d4b405e56 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -60,7 +60,15 @@
#define VOCTRL_SET_PANSCAN 16
/* equalizer controls */
#define VOCTRL_SET_EQUALIZER 17
+struct voctrl_set_equalizer_args {
+ const char *name;
+ int value;
+};
#define VOCTRL_GET_EQUALIZER 18
+struct voctrl_get_equalizer_args {
+ const char *name;
+ int *valueptr;
+};
//#define VOCTRL_GUI_NOWINDOW 19
/* Frame duplication */
#define VOCTRL_DUPLICATE_FRAME 20
@@ -92,6 +100,8 @@ typedef struct {
} mp_colorkey_t;
#define VOCTRL_XOVERLAY_SET_WIN 23
+#define VOCTRL_REDRAW_OSD 24
+
typedef struct {
int x,y;
int w,h;
@@ -121,15 +131,24 @@ typedef struct vo_info_s
const char *comment;
} vo_info_t;
-typedef struct vo_functions_s
-{
+struct vo;
+struct osd_state;
+
+struct vo_driver {
+ // Driver uses new API
+ int is_new;
+
+ // This is set if the driver is not new and contains pointers to
+ // old-API functions to be used instead of the ones below.
+ struct vo_old_functions *old_functions;
+
const vo_info_t *info;
/*
* Preinitializes driver (real INITIALIZATION)
* arg - currently it's vo_subdevice
* returns: zero on successful initialization, non-zero on error.
*/
- int (*preinit)(const char *arg);
+ int (*preinit)(struct vo *vo, const char *arg);
/*
* Initialize (means CONFIGURE) the display driver.
* params:
@@ -140,21 +159,21 @@ typedef struct vo_functions_s
* format: fourcc of pixel format
* returns : zero on successful initialization, non-zero on error.
*/
- int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
- uint32_t d_height, uint32_t fullscreen, char *title,
- uint32_t format);
+ int (*config)(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
+ char *title, uint32_t format);
/*
* Control interface
*/
- int (*control)(uint32_t request, void *data, ...);
+ int (*control)(struct vo *vo, uint32_t request, void *data);
/*
* Display a new RGB/BGR frame of the video to the screen.
* params:
* src[0] - pointer to the image
*/
- int (*draw_frame)(uint8_t *src[]);
+ int (*draw_frame)(struct vo *vo, uint8_t *src[]);
/*
* Draw a planar YUV slice to the buffer:
@@ -164,60 +183,100 @@ typedef struct vo_functions_s
* w,h = width*height of area to be copied (in Y pixels)
* x,y = position at the destination image (in Y pixels)
*/
- int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
+ int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
+ int h, int x, int y);
/*
* Draws OSD to the screen buffer
*/
- void (*draw_osd)(void);
+ void (*draw_osd)(struct vo *vo, struct osd_state *osd);
/*
* Blit/Flip buffer to the screen. Must be called after each frame!
*/
- void (*flip_page)(void);
+ void (*flip_page)(struct vo *vo);
/*
* This func is called after every frames to handle keyboard and
* other events. It's called in PAUSE mode too!
*/
- void (*check_events)(void);
+ void (*check_events)(struct vo *vo);
/*
* Closes driver. Should restore the original state of the system.
*/
- void (*uninit)(void);
+ void (*uninit)(struct vo *vo);
+};
-} vo_functions_t;
+struct vo_old_functions {
+ int (*preinit)(const char *arg);
+ int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
+ uint32_t d_height, uint32_t fullscreen, char *title,
+ uint32_t format);
+ int (*control)(uint32_t request, void *data);
+ int (*draw_frame)(uint8_t *src[]);
+ int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
+ void (*draw_osd)(void);
+ void (*flip_page)(void);
+ void (*check_events)(void);
+ void (*uninit)(void);
+};
+
+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;
+ struct vo_x11_state *x11;
+ struct mp_fifo *key_fifo;
+ struct input_ctx *input_ctx;
+
+ // requested position/resolution
+ int dx;
+ int dy;
+ int dwidth;
+ int dheight;
+
+ int panscan_x;
+ int panscan_y;
+ float panscan_amount;
+ float monitor_aspect;
+ struct aspect_data {
+ int orgw; // real width
+ int orgh; // real height
+ int prew; // prescaled width
+ int preh; // prescaled height
+ int scrw; // horizontal resolution
+ int scrh; // vertical resolution
+ float asp;
+ } aspdat;
+};
-const vo_functions_t* init_best_video_out(char** vo_list);
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
+struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
+ struct mp_fifo *key_fifo,
+ struct input_ctx *input_ctx);
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format);
void list_video_out(void);
-// NULL terminated array of all drivers
-extern const vo_functions_t* const video_out_drivers[];
+int vo_control(struct vo *vo, uint32_t request, void *data);
+int vo_draw_frame(struct vo *vo, uint8_t *src[]);
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
+void vo_draw_osd(struct vo *vo, struct osd_state *osd);
+void vo_flip_page(struct vo *vo);
+void vo_check_events(struct vo *vo);
+void vo_destroy(struct vo *vo);
-extern int vo_flags;
-extern int vo_config_count;
+// NULL terminated array of all drivers
+extern const struct vo_driver *video_out_drivers[];
extern int xinerama_screen;
extern int xinerama_x;
extern int xinerama_y;
-// correct resolution/bpp on screen: (should be autodetected by vo_init())
-extern int vo_depthonscreen;
-extern int vo_screenwidth;
-extern int vo_screenheight;
-
-// requested resolution/bpp: (-x -y -bpp options)
-extern int vo_dx;
-extern int vo_dy;
-extern int vo_dwidth;
-extern int vo_dheight;
-extern int vo_dbpp;
-
extern int vo_grabpointer;
extern int vo_doublebuffering;
extern int vo_directrendering;
@@ -229,18 +288,8 @@ extern int vo_adapter_num;
extern int vo_refresh_rate;
extern int vo_keepaspect;
extern int vo_rootwin;
-extern int vo_ontop;
extern int vo_border;
-extern int vo_gamma_gamma;
-extern int vo_gamma_brightness;
-extern int vo_gamma_saturation;
-extern int vo_gamma_contrast;
-extern int vo_gamma_hue;
-extern int vo_gamma_red_intensity;
-extern int vo_gamma_green_intensity;
-extern int vo_gamma_blue_intensity;
-
extern int vo_nomouse_input;
extern int vo_pts;
@@ -272,7 +321,8 @@ int lookup_keymap_table(const struct keymap *map, int key);
struct vo_rect {
int left, right, top, bottom, width, height;
};
-void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst,
+void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
+ struct vo_rect *src, struct vo_rect *dst,
struct vo_rect *borders, const struct vo_rect *crop);
#endif /* MPLAYER_VIDEO_OUT_H */
diff --git a/libvo/video_out_internal.h b/libvo/video_out_internal.h
index 36aa210fdd..166a91cc1c 100644
--- a/libvo/video_out_internal.h
+++ b/libvo/video_out_internal.h
@@ -27,8 +27,10 @@
#include "libmpcodecs/vfcap.h"
#include "libmpcodecs/mp_image.h"
#include "geometry.h"
+#include "old_vo_wrapper.h"
+#include "old_vo_defines.h"
-static int control(uint32_t request, void *data, ...);
+static int control(uint32_t request, void *data);
static int config(uint32_t width, uint32_t height, uint32_t d_width,
uint32_t d_height, uint32_t fullscreen, char *title,
uint32_t format);
@@ -41,9 +43,20 @@ static void uninit(void);
static int query_format(uint32_t format);
static int preinit(const char *);
-#define LIBVO_EXTERN(x) vo_functions_t video_out_##x =\
+#define LIBVO_EXTERN(x) struct vo_driver video_out_##x =\
{\
- &info,\
+ .is_new = 0,\
+ .info = &info,\
+ .preinit = old_vo_preinit,\
+ .config = old_vo_config,\
+ .control = old_vo_control,\
+ .draw_frame = old_vo_draw_frame,\
+ .draw_slice = old_vo_draw_slice,\
+ .draw_osd = old_vo_draw_osd,\
+ .flip_page = old_vo_flip_page,\
+ .check_events = old_vo_check_events,\
+ .uninit = old_vo_uninit,\
+ .old_functions = &(struct vo_old_functions){\
preinit,\
config,\
control,\
@@ -52,7 +65,8 @@ static int preinit(const char *);
draw_osd,\
flip_page,\
check_events,\
- uninit\
+ uninit,\
+ }\
};
#include "osd.h"
diff --git a/libvo/vo_3dfx.c b/libvo/vo_3dfx.c
index 93776d4318..da52a57a01 100644
--- a/libvo/vo_3dfx.c
+++ b/libvo/vo_3dfx.c
@@ -497,7 +497,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_aa.c b/libvo/vo_aa.c
index d4b596b40a..48b9f2f2ad 100644
--- a/libvo/vo_aa.c
+++ b/libvo/vo_aa.c
@@ -96,7 +96,9 @@ static struct SwsContext *sws=NULL;
int aaopt_osdcolor = AA_SPECIAL;
int aaopt_subcolor = AA_SPECIAL;
-void
+static unsigned char vo_osd_text[64];
+
+static void
resize(void){
/*
* this function is called by aa lib if windows resizes
@@ -192,15 +194,10 @@ osdpercent(int duration, int deko, int min, int max, int val, const char * desc,
static void
printosdtext(void)
{
- if(osd_text_length > 0 && !vo_osd_text) {
- memset(c->textbuffer,' ',osd_text_length);
- memset(c->attrbuffer,0,osd_text_length);
- osd_text_length = 0;
- }
/*
* places the mplayer status osd
*/
- if (vo_osd_text && vo_osd_text[0] != 0) {
+ if (vo_osd_text[0] != 0) {
int len;
if(vo_osd_text[0] < 32) {
len = strlen(sub_osd_names_short[vo_osd_text[0]]) + strlen(vo_osd_text+1) + 2;
@@ -544,18 +541,18 @@ static void clear_alpha(int x0,int y0, int w,int h) {
static void
draw_osd(void){
- char * vo_osd_text_save;
+ char vo_osd_text_save;
int vo_osd_progbar_type_save;
printosdprogbar();
/* let vo_draw_text only write subtitle */
- vo_osd_text_save=vo_osd_text; /* we have to save the osd_text */
- vo_osd_text=NULL;
+ vo_osd_text_save = global_osd->osd_text[0];
+ global_osd->osd_text[0] = 0;
vo_osd_progbar_type_save=vo_osd_progbar_type;
vo_osd_progbar_type=-1;
vo_remove_text(aa_scrwidth(c), aa_scrheight(c),clear_alpha);
vo_draw_text(aa_scrwidth(c), aa_scrheight(c), draw_alpha);
- vo_osd_text=vo_osd_text_save;
+ global_osd->osd_text[0] = vo_osd_text_save;
vo_osd_progbar_type=vo_osd_progbar_type_save;
}
@@ -728,37 +725,26 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
case VOCTRL_SET_EQUALIZER: {
- va_list ap;
- int val;
-
- va_start(ap, data);
- val = va_arg(ap, int);
- va_end(ap);
-
- if(strcmp((char*)data,"contrast") == 0)
- p->contrast = ( val + 100 ) * 64 / 100;
- else if(strcmp((char*)data,"brightness") == 0)
- p->bright = ( val + 100) * 128 / 100;
+ struct voctrl_set_equalizer_args *args = data;
+ if (strcmp(args->name, "contrast") == 0)
+ p->contrast = (args->value + 100) * 64 / 100;
+ else if (strcmp(args->name, "brightness") == 0)
+ p->bright = (args->value + 100) * 128 / 100;
return VO_TRUE;
}
case VOCTRL_GET_EQUALIZER: {
- va_list ap;
- int* val;
-
- va_start(ap, data);
- val = va_arg(ap, int*);
- va_end(ap);
+ struct voctrl_get_equalizer_args *args = data;
- if(strcmp((char*)data,"contrast") == 0)
- *val = (p->contrast - 64) * 100 / 64;
- else if(strcmp((char*)data,"brightness") == 0)
- *val = (p->bright - 128) * 100 / 128;
+ if (strcmp(args->name, "contrast") == 0)
+ *args->valueptr = (p->contrast - 64) * 100 / 64;
+ else if (strcmp(args->name, "brightness") == 0)
+ *args->valueptr = (p->bright - 128) * 100 / 128;
return VO_TRUE;
}
diff --git a/libvo/vo_bl.c b/libvo/vo_bl.c
index bacec3acbb..38fdb0c9c4 100644
--- a/libvo/vo_bl.c
+++ b/libvo/vo_bl.c
@@ -470,7 +470,7 @@ static int preinit(const char *arg) {
return 0;
}
-static int control(uint32_t request, void *data, ...) {
+static int control(uint32_t request, void *data) {
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
diff --git a/libvo/vo_caca.c b/libvo/vo_caca.c
index 36ceb03762..c9bdd19568 100644
--- a/libvo/vo_caca.c
+++ b/libvo/vo_caca.c
@@ -335,7 +335,7 @@ static int query_format(uint32_t format)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch(request)
{
diff --git a/libvo/vo_cvidix.c b/libvo/vo_cvidix.c
index 68c779a2c0..9fa24fa7c4 100644
--- a/libvo/vo_cvidix.c
+++ b/libvo/vo_cvidix.c
@@ -171,11 +171,11 @@ static int preinit(const char *arg){
mp_msg(MSGT_VO, MSGL_INFO, "vo_cvidix: No vidix driver name provided, probing available ones (-v option for details)!\n");
vidix_name = NULL;
}
- if(vidix_preinit(vidix_name, &video_out_cvidix))return 1;
+ if (vidix_preinit(vidix_name, video_out_cvidix.old_functions))return 1;
return 0;
}
-static int control(uint32_t request, void *data, ...){
+static int control(uint32_t request, void *data){
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
@@ -184,24 +184,6 @@ static int control(uint32_t request, void *data, ...){
else vo_fs=1;
setup_vidix();
return VO_TRUE;
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
- return vidix_control(request, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
- va_start(ap, data);
- value = va_arg(ap, int *);
- va_end(ap);
- return vidix_control(request, data, value);
- }
}
return vidix_control(request, data);
}
diff --git a/libvo/vo_dfbmga.c b/libvo/vo_dfbmga.c
index fd1a3638db..73d67c4f8e 100644
--- a/libvo/vo_dfbmga.c
+++ b/libvo/vo_dfbmga.c
@@ -1465,7 +1465,7 @@ get_equalizer( char *data, int *value )
}
static int
-control( uint32_t request, void *data, ... )
+control( uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GUISUPPORT:
@@ -1483,25 +1483,13 @@ control( uint32_t request, void *data, ... )
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start( ap, data );
- value = va_arg( ap, int );
- va_end( ap );
-
- return set_equalizer( data, value );
+ struct voctrl_set_equalizer_args *args = data;
+ return set_equalizer(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start( ap, data );
- value = va_arg( ap, int* );
- va_end( ap );
-
- return get_equalizer( data, value );
+ struct voctrl_get_equalizer_args *args = data;
+ return get_equalizer(args->name, args->valueptr);
}
}
diff --git a/libvo/vo_dga.c b/libvo/vo_dga.c
index a3f2901eb3..3383a30df5 100644
--- a/libvo/vo_dga.c
+++ b/libvo/vo_dga.c
@@ -984,7 +984,7 @@ static uint32_t get_image(mp_image_t * mpi)
return VO_FALSE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index bfeb82e562..c0f79d45d4 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -740,7 +740,7 @@ static int preinit(const char *arg)
/** @brief libvo Callback: Handle control requests.
* @return VO_TRUE on success, VO_NOTIMPL when not implemented
*/
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_directfb2.c b/libvo/vo_directfb2.c
index 7aafe091e9..caff687d02 100644
--- a/libvo/vo_directfb2.c
+++ b/libvo/vo_directfb2.c
@@ -1412,7 +1412,7 @@ static uint32_t put_image(mp_image_t *mpi){
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -1423,25 +1423,13 @@ static int control(uint32_t request, void *data, ...)
return put_image(data);
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return directfb_set_video_eq(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return directfb_set_video_eq(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return directfb_get_video_eq(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return directfb_get_video_eq(args->name, args->valueptr);
}
};
return VO_NOTIMPL;
diff --git a/libvo/vo_directx.c b/libvo/vo_directx.c
index 224af242c2..7d4feaa5e5 100644
--- a/libvo/vo_directx.c
+++ b/libvo/vo_directx.c
@@ -90,8 +90,6 @@ static float window_aspect;
static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL;
static RECT last_rect = {0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE};
-extern int vidmode;
-
/*****************************************************************************
* DirectDraw GUIDs.
* Defining them here allows us to get rid of the dxguid library during
@@ -1474,7 +1472,7 @@ static uint32_t color_ctrl_get(char *what, int *value)
return r;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
@@ -1566,22 +1564,12 @@ static int control(uint32_t request, void *data, ...)
return VO_TRUE;
}
case VOCTRL_SET_EQUALIZER: {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
- return color_ctrl_set(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return color_ctrl_set(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER: {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
- return color_ctrl_get(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return color_ctrl_get(args->name, args->valueptr);
}
case VOCTRL_UPDATE_SCREENINFO:
if (vidmode) {
diff --git a/libvo/vo_dxr2.c b/libvo/vo_dxr2.c
index 0bf64f58d6..ccbef40b61 100644
--- a/libvo/vo_dxr2.c
+++ b/libvo/vo_dxr2.c
@@ -42,8 +42,7 @@
#include <dxr2ioctl.h>
-extern float monitor_aspect;
-extern float movie_aspect;
+#include "aspect.h"
int dxr2_fd = -1;
@@ -51,7 +50,8 @@ static int movie_w,movie_h;
static int playing = 0;
// vo device used to blank the screen for the overlay init
-static const vo_functions_t* sub_vo = NULL;
+static const struct vo_old_functions *sub_vo = NULL;
+static const struct vo_info_s *sub_info;
static uint8_t* sub_img = NULL;
static int sub_x,sub_y,sub_w,sub_h;
@@ -446,7 +446,7 @@ static int dxr2_load_vga_params(dxr2_vgaParams_t* vga,char* name) {
}
static int dxr2_setup_vga_params(void) {
- const vo_info_t* vi = sub_vo->info;
+ const vo_info_t* vi = sub_info;
dxr2_vgaParams_t vga;
int loaded = dxr2_load_vga_params(&vga,(char*)vi->short_name);
@@ -660,7 +660,7 @@ static int config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t
}
// Does the sub vo support the x11 stuff
// Fix me : test the other x11 vo's and enable them
- if(strcmp(sub_vo->info->short_name,"x11") == 0)
+ if(strcmp(sub_info->short_name,"x11") == 0)
sub_vo_win = 1;
else
sub_vo_win = 0;
@@ -834,10 +834,11 @@ static int preinit(const char *arg) {
const vo_info_t* vi = video_out_drivers[n]->info;
if(!vi)
continue;
- if(strcasecmp(arg,vi->short_name) == 0)
+ if(!video_out_drivers[n]->is_new && strcasecmp(arg,vi->short_name) == 0)
break;
}
- sub_vo = video_out_drivers[n];
+ sub_vo = video_out_drivers[n]->old_functions;
+ sub_info = video_out_drivers[n]->info;
} else {
mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] We need a sub driver to initialize the overlay\n");
use_ol = 0;
@@ -920,7 +921,7 @@ static int preinit(const char *arg) {
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_dxr3.c b/libvo/vo_dxr3.c
index c5fa8a970d..e9474a0eb2 100644
--- a/libvo/vo_dxr3.c
+++ b/libvo/vo_dxr3.c
@@ -177,7 +177,7 @@ static overlay_t *overlay_data;
/* Functions for working with the em8300's internal clock */
/* End of internal clock functions */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GUISUPPORT:
@@ -255,22 +255,17 @@ static int control(uint32_t request, void *data, ...)
}
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
em8300_bcs_t bcs;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
+ struct voctrl_set_equalizer_args *args = data;
if (ioctl(fd_control, EM8300_IOCTL_GETBCS, &bcs) < 0)
return VO_FALSE;
- if (!strcasecmp(data, "brightness"))
- bcs.brightness = (value+100)*5;
- else if (!strcasecmp(data, "contrast"))
- bcs.contrast = (value+100)*5;
- else if (!strcasecmp(data, "saturation"))
- bcs.saturation = (value+100)*5;
+ if (!strcasecmp(args->name, "brightness"))
+ bcs.brightness = (args->value+100)*5;
+ else if (!strcasecmp(args->name, "contrast"))
+ bcs.contrast = (args->value+100)*5;
+ else if (!strcasecmp(args->name, "saturation"))
+ bcs.saturation = (args->value+100)*5;
else return VO_FALSE;
if (ioctl(fd_control, EM8300_IOCTL_SETBCS, &bcs) < 0)
@@ -279,23 +274,18 @@ static int control(uint32_t request, void *data, ...)
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
em8300_bcs_t bcs;
+ struct voctrl_get_equalizer_args *args = data;
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
if (ioctl(fd_control, EM8300_IOCTL_GETBCS, &bcs) < 0)
return VO_FALSE;
- if (!strcasecmp(data, "brightness"))
- *value = (bcs.brightness/5)-100;
- else if (!strcasecmp(data, "contrast"))
- *value = (bcs.contrast/5)-100;
- else if (!strcasecmp(data, "saturation"))
- *value = (bcs.saturation/5)-100;
+ if (!strcasecmp(args->name, "brightness"))
+ *args->valueptr = (bcs.brightness/5)-100;
+ else if (!strcasecmp(args->name, "contrast"))
+ *args->valueptr = (bcs.contrast/5)-100;
+ else if (!strcasecmp(args->name, "saturation"))
+ *args->valueptr = (bcs.saturation/5)-100;
else return VO_FALSE;
return VO_TRUE;
@@ -325,7 +315,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
{
int tmp1, tmp2, size;
em8300_register_t reg;
- extern float monitor_aspect;
/* Softzoom turned on, downscale */
/* This activates the subpicture processor, you can safely disable this and still send */
diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c
index 5f621967cf..a5e51c31f0 100644
--- a/libvo/vo_fbdev.c
+++ b/libvo/vo_fbdev.c
@@ -1085,7 +1085,8 @@ static int preinit(const char *vo_subdevice)
if (memcmp(vo_subdevice, "vidix", 5) == 0)
vidix_name = &vo_subdevice[5];
if (vidix_name)
- pre_init_err = vidix_preinit(vidix_name, &video_out_fbdev);
+ pre_init_err = vidix_preinit(vidix_name,
+ video_out_fbdev.old_functions);
else
#endif
{
@@ -1117,7 +1118,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_IMAGE:
@@ -1130,27 +1131,8 @@ static int control(uint32_t request, void *data, ...)
if (vidix_name) {
switch (request) {
case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
+ return vidix_control(request, data);
}
}
#endif
diff --git a/libvo/vo_fbdev2.c b/libvo/vo_fbdev2.c
index a18e9f2f47..2a64ed0612 100644
--- a/libvo/vo_fbdev2.c
+++ b/libvo/vo_fbdev2.c
@@ -413,7 +413,7 @@ static void uninit(void)
fb_preinit(1); // so that later calls to preinit don't fail
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_ggi.c b/libvo/vo_ggi.c
index 645bed2577..2be65696f5 100644
--- a/libvo/vo_ggi.c
+++ b/libvo/vo_ggi.c
@@ -83,6 +83,8 @@ static struct ggi_conf_s {
} flushregion;
int voflags;
+
+ int depthonscreen;
} ggi_conf;
@@ -210,7 +212,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
ggiSetFlags(ggi_conf.drawvis, GGIFLAG_ASYNC);
}
- vo_depthonscreen = GT_DEPTH(mode.graphtype);
+ ggi_conf.depthonscreen = GT_DEPTH(mode.graphtype);
vo_screenwidth = mode.virt.x;
vo_screenheight = mode.virt.y;
@@ -374,9 +376,9 @@ static int query_format(uint32_t format)
| VFCAP_CSP_SUPPORTED_BY_HW
| VFCAP_ACCEPT_STRIDE;
- if ((!vo_depthonscreen || !vo_dbpp) && ggi_conf.vis) {
+ if ((!ggi_conf.depthonscreen || !vo_dbpp) && ggi_conf.vis) {
if (ggiGetMode(ggi_conf.vis, &mode) == 0) {
- vo_depthonscreen = GT_DEPTH(mode.graphtype);
+ ggi_conf.depthonscreen = GT_DEPTH(mode.graphtype);
vo_dbpp = GT_SIZE(mode.graphtype);
}
if (GT_SCHEME(mode.graphtype) == GT_AUTO) {
@@ -384,7 +386,7 @@ static int query_format(uint32_t format)
}
if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) {
mode.graphtype = GT_32BIT;
- vo_depthonscreen = GT_DEPTH(mode.graphtype);
+ ggi_conf.depthonscreen = GT_DEPTH(mode.graphtype);
vo_dbpp = GT_SIZE(mode.graphtype);
}
}
@@ -468,7 +470,7 @@ static void uninit(void)
ggiExit();
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_gif89a.c b/libvo/vo_gif89a.c
index 3ad230a20b..78dd5249fd 100644
--- a/libvo/vo_gif89a.c
+++ b/libvo/vo_gif89a.c
@@ -335,7 +335,7 @@ static int query_format(uint32_t format)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
if (request == VOCTRL_QUERY_FORMAT) {
return query_format(*((uint32_t*)data));
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index e1db6622bf..2e85163833 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -1120,7 +1120,7 @@ static const struct {
{NULL, NULL, 0 }
};
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_PAUSE:
@@ -1156,14 +1156,14 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_GUISUPPORT:
return VO_TRUE;
case VOCTRL_ONTOP:
- vo_ontop();
+ vo_gl_ontop();
return VO_TRUE;
case VOCTRL_FULLSCREEN:
vo_fullscreen();
resize(vo_dwidth, vo_dheight);
return VO_TRUE;
case VOCTRL_BORDER:
- vo_border();
+ vo_gl_border();
resize(vo_dwidth, vo_dheight);
return VO_TRUE;
case VOCTRL_GET_PANSCAN:
@@ -1175,33 +1175,25 @@ static int control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_GET_EQUALIZER:
if (image_format == IMGFMT_YV12) {
+ struct voctrl_get_equalizer_args *args = data;
int i;
- va_list va;
- int *value;
- va_start(va, data);
- value = va_arg(va, int *);
- va_end(va);
for (i = 0; eq_map[i].name; i++)
- if (strcmp(data, eq_map[i].name) == 0) break;
+ if (strcmp(args->name, eq_map[i].name) == 0) break;
if (!(eq_map[i].supportmask & (1 << use_yuv)))
break;
- *value = *eq_map[i].value;
+ *args->valueptr = *eq_map[i].value;
return VO_TRUE;
}
break;
case VOCTRL_SET_EQUALIZER:
if (image_format == IMGFMT_YV12) {
+ struct voctrl_set_equalizer_args *args = data;
int i;
- va_list va;
- int value;
- va_start(va, data);
- value = va_arg(va, int);
- va_end(va);
for (i = 0; eq_map[i].name; i++)
- if (strcmp(data, eq_map[i].name) == 0) break;
+ if (strcmp(args->name, eq_map[i].name) == 0) break;
if (!(eq_map[i].supportmask & (1 << use_yuv)))
break;
- *eq_map[i].value = value;
+ *eq_map[i].value = args->value;
update_yuvconv();
return VO_TRUE;
}
@@ -1209,6 +1201,12 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_UPDATE_SCREENINFO:
update_xinerama_info();
return VO_TRUE;
+ case VOCTRL_REDRAW_OSD:
+ if (vo_doublebuffering)
+ do_render();
+ draw_osd();
+ flip_page();
+ return VO_TRUE;
}
return VO_NOTIMPL;
}
diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c
index 9509001165..382994e318 100644
--- a/libvo/vo_gl2.c
+++ b/libvo/vo_gl2.c
@@ -876,7 +876,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_PAUSE:
@@ -888,7 +888,7 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_GUISUPPORT:
return VO_TRUE;
case VOCTRL_ONTOP:
- vo_ontop();
+ vo_gl_ontop();
return VO_TRUE;
case VOCTRL_FULLSCREEN:
vo_fullscreen();
@@ -897,7 +897,7 @@ static int control(uint32_t request, void *data, ...)
resize(&vo_dwidth, &vo_dheight);
return VO_TRUE;
case VOCTRL_BORDER:
- vo_border();
+ vo_gl_border();
return VO_TRUE;
case VOCTRL_GET_PANSCAN:
return VO_TRUE;
@@ -907,23 +907,13 @@ static int control(uint32_t request, void *data, ...)
#ifndef GL_WIN32
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
- return vo_x11_set_equalizer(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_x11_set_equalizer(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
- va_end(ap);
- return vo_x11_get_equalizer(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_x11_get_equalizer(args->name, args->valueptr);
}
#endif
case VOCTRL_UPDATE_SCREENINFO:
diff --git a/libvo/vo_ivtv.c b/libvo/vo_ivtv.c
index 7dd9279f38..94daaa577b 100644
--- a/libvo/vo_ivtv.c
+++ b/libvo/vo_ivtv.c
@@ -108,7 +108,7 @@ ivtv_reset (int blank_screen)
}
int
-ivtv_write (unsigned char *data, int len)
+ivtv_write (const unsigned char *data, int len)
{
if (ivtv_fd < 0)
return 0;
@@ -285,7 +285,7 @@ query_format (uint32_t format)
}
static int
-control (uint32_t request, void *data, ...)
+control (uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_jpeg.c b/libvo/vo_jpeg.c
index bcd86c6eec..cd6a83a938 100644
--- a/libvo/vo_jpeg.c
+++ b/libvo/vo_jpeg.c
@@ -44,7 +44,7 @@
#include "mp_msg.h"
#include "video_out.h"
#include "video_out_internal.h"
-#include "mplayer.h" /* for exit_player() */
+#include "mplayer.h" /* for exit_player_bad() */
#include "help_mp.h"
/* ------------------------------------------------------------------------- */
@@ -121,17 +121,17 @@ static void jpeg_mkdir(char *buf, int verbose) {
MSGTR_VO_GenericError, strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
MSGTR_VO_UnableToAccess,buf);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
if ( !S_ISDIR(stat_p.st_mode) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
buf, MSGTR_VO_ExistsButNoDirectory);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
if ( !(stat_p.st_mode & S_IWUSR) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
buf, MSGTR_VO_DirExistsButNotWritable);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
@@ -143,7 +143,7 @@ static void jpeg_mkdir(char *buf, int verbose) {
MSGTR_VO_GenericError, strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
buf, MSGTR_VO_CantCreateDirectory);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
} /* end switch */
} else if ( verbose ) {
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
@@ -192,7 +192,7 @@ static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer)
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
info.short_name, MSGTR_VO_GenericError,
strerror(errno) );
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
cinfo.err = jpeg_std_error(&jerr);
@@ -404,7 +404,7 @@ static int preinit(const char *arg)
/* ------------------------------------------------------------------------- */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_kva.c b/libvo/vo_kva.c
index 57df14b358..6b126ed592 100644
--- a/libvo/vo_kva.c
+++ b/libvo/vo_kva.c
@@ -931,7 +931,7 @@ static int color_ctrl_get(char *what, int *value)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_IMAGE:
@@ -948,26 +948,14 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return color_ctrl_set(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ color_ctrl_set(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
- va_end(ap);
-
- return color_ctrl_get(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return color_ctrl_get(args->name, args->valueptr);
}
case VOCTRL_UPDATE_SCREENINFO:
diff --git a/libvo/vo_macosx.m b/libvo/vo_macosx.m
index 8a238191c7..eaa08c3316 100644
--- a/libvo/vo_macosx.m
+++ b/libvo/vo_macosx.m
@@ -47,6 +47,7 @@
#include "input/mouse.h"
#include "osdep/keycodes.h"
+#include "mp_fifo.h"
//Cocoa
NSDistantObject *mplayerosxProxy;
@@ -83,8 +84,6 @@ static uint32_t image_format;
static int isFullscreen;
static int isOntop;
static int isRootwin;
-extern float monitor_aspect;
-extern float movie_aspect;
static float old_movie_aspect;
extern int enable_mouse_movements;
@@ -411,7 +410,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
@@ -1060,7 +1059,7 @@ static int control(uint32_t request, void *data, ...)
snprintf(cmdstr, sizeof(cmdstr), "set_mouse_pos %i %i",
(int)(vo_fs ? p.x : (p.x - textureFrame.origin.x)),
(int)(vo_fs ? [self frame].size.height - p.y: (NSMaxY(textureFrame) - p.y)));
- mp_input_queue_cmd(mp_input_parse_cmd(cmdstr));
+ mp_input_queue_cmd(global_vo->input_ctx, mp_input_parse_cmd(cmdstr));
}
}
}
diff --git a/libvo/vo_md5sum.c b/libvo/vo_md5sum.c
index 08dc49d548..c0996354e5 100644
--- a/libvo/vo_md5sum.c
+++ b/libvo/vo_md5sum.c
@@ -40,7 +40,7 @@
#include "mp_msg.h"
#include "video_out.h"
#include "video_out_internal.h"
-#include "mplayer.h" /* for exit_player() */
+#include "mplayer.h" /* for exit_player_bad() */
#include "help_mp.h"
#include "libavutil/md5.h"
@@ -86,7 +86,7 @@ int framenum = 0;
static void md5sum_write_error(void) {
mp_msg(MSGT_VO, MSGL_ERR, MSGTR_ErrorWritingFile, info.short_name);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
/* ------------------------------------------------------------------------- */
@@ -152,7 +152,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
MSGTR_VO_CantCreateFile);
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
info.short_name, MSGTR_VO_GenericError, strerror(errno) );
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
return 0;
@@ -264,7 +264,7 @@ static int query_format(uint32_t format)
/* ------------------------------------------------------------------------- */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_mpegpes.c b/libvo/vo_mpegpes.c
index 35d5f188ef..3ff03bf205 100644
--- a/libvo/vo_mpegpes.c
+++ b/libvo/vo_mpegpes.c
@@ -185,7 +185,7 @@ static void draw_osd(void)
}
-static int my_write(unsigned char* data,int len){
+static int my_write(const unsigned char* data,int len){
int orig_len = len;
#ifdef CONFIG_DVB
#define NFD 2
@@ -220,15 +220,10 @@ static int my_write(unsigned char* data,int len){
return orig_len;
}
-void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
+static void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
send_mpeg_pes_packet (data, len, id, timestamp, 1, my_write);
}
-void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){
- send_mpeg_lpcm_packet(data, len, id, timestamp, freq_id, my_write);
-}
-
-
static int draw_frame(uint8_t * src[])
{
vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
@@ -266,7 +261,7 @@ static void check_events(void)
{
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_null.c b/libvo/vo_null.c
index 33c86580c5..81438898ed 100644
--- a/libvo/vo_null.c
+++ b/libvo/vo_null.c
@@ -98,7 +98,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_png.c b/libvo/vo_png.c
index b2e75897ea..608a9a63c0 100644
--- a/libvo/vo_png.c
+++ b/libvo/vo_png.c
@@ -26,9 +26,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
#include <png.h>
@@ -39,9 +36,6 @@
#include "video_out.h"
#include "video_out_internal.h"
#include "subopt-helper.h"
-#include "mplayer.h"
-
-#define BUFLENGTH 512
static const vo_info_t info =
{
@@ -54,7 +48,6 @@ static const vo_info_t info =
const LIBVO_EXTERN (png)
static int z_compression = Z_NO_COMPRESSION;
-static char *png_outdir = NULL;
static int framenum = 0;
static int use_alpha;
@@ -65,56 +58,9 @@ struct pngdata {
enum {OK,ERROR} status;
};
-static void png_mkdir(char *buf, int verbose) {
- struct stat stat_p;
-
-#ifndef __MINGW32__
- if ( mkdir(buf, 0755) < 0 ) {
-#else
- if ( mkdir(buf) < 0 ) {
-#endif
- switch (errno) { /* use switch in case other errors need to be caught
- and handled in the future */
- case EEXIST:
- if ( stat(buf, &stat_p ) < 0 ) {
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- MSGTR_VO_UnableToAccess,buf);
- exit_player(MSGTR_Exit_error);
- }
- if ( !S_ISDIR(stat_p.st_mode) ) {
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- buf, MSGTR_VO_ExistsButNoDirectory);
- exit_player(MSGTR_Exit_error);
- }
- if ( !(stat_p.st_mode & S_IWUSR) ) {
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsButNotWritable);
- exit_player(MSGTR_Exit_error);
- }
-
- mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsAndIsWritable);
- break;
-
- default:
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_CantCreateDirectory);
- exit_player(MSGTR_Exit_error);
- } /* end switch */
- } else if ( verbose ) {
- mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirectoryCreateSuccess);
- } /* end if */
-}
-
static int
config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
- char buf[BUFLENGTH];
if(z_compression == 0) {
mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1);
@@ -122,8 +68,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3);
}
- snprintf(buf, BUFLENGTH, "%s", png_outdir);
- png_mkdir(buf, 1);
mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression);
return 0;
@@ -220,7 +164,7 @@ static uint32_t draw_image(mp_image_t* mpi){
// if -dr or -slices then do nothing:
if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
- snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum);
+ snprintf (buf, 100, "%08d.png", ++framenum);
png = create_png(buf, mpi->w, mpi->h, IMGFMT_IS_BGR(mpi->imgfmt));
@@ -274,12 +218,7 @@ query_format(uint32_t format)
return 0;
}
-static void uninit(void){
- if (png_outdir) {
- free(png_outdir);
- png_outdir = NULL;
- }
-}
+static void uninit(void){}
static void check_events(void){}
@@ -293,14 +232,12 @@ static int int_zero_to_nine(int *sh)
static const opt_t subopts[] = {
{"alpha", OPT_ARG_BOOL, &use_alpha, NULL, 0},
{"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine},
- {"outdir", OPT_ARG_MSTRZ, &png_outdir, NULL, 0},
{NULL}
};
static int preinit(const char *arg)
{
z_compression = 0;
- png_outdir = strdup(".");
use_alpha = 0;
if (subopt_parse(arg, subopts) != 0) {
return -1;
@@ -308,7 +245,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_DRAW_IMAGE:
diff --git a/libvo/vo_pnm.c b/libvo/vo_pnm.c
index 6525a2141d..2defb37ba5 100644
--- a/libvo/vo_pnm.c
+++ b/libvo/vo_pnm.c
@@ -39,7 +39,7 @@
#include "mp_msg.h"
#include "video_out.h"
#include "video_out_internal.h"
-#include "mplayer.h" /* for exit_player() */
+#include "mplayer.h" /* for exit_player_bad() */
#include "help_mp.h"
/* ------------------------------------------------------------------------- */
@@ -98,7 +98,7 @@ char *pnm_file_extension = NULL;
static void pnm_write_error(void) {
mp_msg(MSGT_VO, MSGL_ERR, MSGTR_ErrorWritingFile, info.short_name);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
/* ------------------------------------------------------------------------- */
@@ -214,17 +214,17 @@ static void pnm_mkdir(char *buf, int verbose) {
MSGTR_VO_GenericError, strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
MSGTR_VO_UnableToAccess,buf);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
if ( !S_ISDIR(stat_p.st_mode) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
buf, MSGTR_VO_ExistsButNoDirectory);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
if ( !(stat_p.st_mode & S_IWUSR) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
buf, MSGTR_VO_DirExistsButNotWritable);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
if (strcmp(buf, ".") != 0) {
@@ -238,7 +238,7 @@ static void pnm_mkdir(char *buf, int verbose) {
MSGTR_VO_GenericError, strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
buf, MSGTR_VO_CantCreateDirectory);
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
} /* end switch */
} else if ( verbose ) {
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
@@ -442,7 +442,7 @@ static void pnm_write_image(mp_image_t *mpi)
if (!mpi) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: No image data suplied to video output driver\n", info.short_name );
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
/* Start writing to new subdirectory after a certain amount of frames */
@@ -474,7 +474,7 @@ static void pnm_write_image(mp_image_t *mpi)
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
info.short_name, MSGTR_VO_GenericError,
strerror(errno) );
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(MSGTR_Exit_error);
}
pnm_write_pnm(outfile, mpi);
@@ -542,7 +542,7 @@ static int query_format(uint32_t format)
/* ------------------------------------------------------------------------- */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_quartz.c b/libvo/vo_quartz.c
index edc99ab445..97ca656b8d 100644
--- a/libvo/vo_quartz.c
+++ b/libvo/vo_quartz.c
@@ -87,8 +87,6 @@ static int EnterMoviesDone = 0;
static int get_image_done = 0;
static int vo_quartz_fs; // we are in fullscreen
-extern float monitor_aspect;
-extern float movie_aspect;
static float old_movie_aspect;
static int winLevel = 1;
@@ -1273,7 +1271,7 @@ static uint32_t get_yuv_image(mp_image_t * mpi)
return VO_FALSE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_s3fb.c b/libvo/vo_s3fb.c
index 930dcc80c4..da2408f146 100644
--- a/libvo/vo_s3fb.c
+++ b/libvo/vo_s3fb.c
@@ -521,7 +521,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch(request) {
case VOCTRL_GET_IMAGE:
diff --git a/libvo/vo_sdl.c b/libvo/vo_sdl.c
index 8ec6d4fbc3..d4c0e75041 100644
--- a/libvo/vo_sdl.c
+++ b/libvo/vo_sdl.c
@@ -1635,7 +1635,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_FALSE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
struct sdl_priv_s *priv = &sdl_priv;
switch (request) {
diff --git a/libvo/vo_svga.c b/libvo/vo_svga.c
index 2dcaf6401f..0b313a44ab 100644
--- a/libvo/vo_svga.c
+++ b/libvo/vo_svga.c
@@ -152,7 +152,7 @@ static int preinit(const char *arg)
vidix_name[i-5]=0;
if(arg[i]==':')i++;
arg+=i;
- vidix_preinit(vidix_name, &video_out_svga);
+ vidix_preinit(vidix_name, video_out_svga.old_functions);
}
#endif
if(!strncmp(arg,"sq",2)) {
@@ -358,7 +358,7 @@ static int find_best_svga_mode(int req_w,int req_h, int req_bpp){
return bestmode;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -370,33 +370,8 @@ static int control(uint32_t request, void *data, ...)
}
#ifdef CONFIG_VIDIX
- if (vidix_name[0]) {
- switch (request) {
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- }
+ if (vidix_name[0])
return vidix_control(request, data);
- }
#endif
return VO_NOTIMPL;
diff --git a/libvo/vo_tdfx_vid.c b/libvo/vo_tdfx_vid.c
index 5c7f917d4e..3112a82540 100644
--- a/libvo/vo_tdfx_vid.c
+++ b/libvo/vo_tdfx_vid.c
@@ -644,7 +644,7 @@ static uint32_t set_colorkey(mp_colorkey_t* colork) {
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_tdfxfb.c b/libvo/vo_tdfxfb.c
index 1b63147817..c40cae7b82 100644
--- a/libvo/vo_tdfxfb.c
+++ b/libvo/vo_tdfxfb.c
@@ -496,7 +496,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch(request) {
case VOCTRL_GET_IMAGE:
diff --git a/libvo/vo_tga.c b/libvo/vo_tga.c
index 0b338f994c..70408cc0e4 100644
--- a/libvo/vo_tga.c
+++ b/libvo/vo_tga.c
@@ -260,7 +260,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_DRAW_IMAGE:
diff --git a/libvo/vo_v4l2.c b/libvo/vo_v4l2.c
index 1f611d864a..633612743c 100644
--- a/libvo/vo_v4l2.c
+++ b/libvo/vo_v4l2.c
@@ -69,7 +69,7 @@ static const vo_info_t info =
const LIBVO_EXTERN (v4l2)
int
-v4l2_write (unsigned char *data, int len)
+v4l2_write (const unsigned char *data, int len)
{
if (v4l2_fd < 0)
return 0;
@@ -253,7 +253,7 @@ query_format (uint32_t format)
}
static int
-control (uint32_t request, void *data, ...)
+control (uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index f7f2450751..085dfb4156 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -1077,7 +1077,7 @@ static int set_equalizer(char *name, int value) {
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_DEINTERLACE:
@@ -1114,24 +1114,13 @@ static int control(uint32_t request, void *data, ...)
resize();
return VO_TRUE;
case VOCTRL_SET_EQUALIZER: {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
- return set_equalizer(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return set_equalizer(args->name, args->value);
}
- case VOCTRL_GET_EQUALIZER: {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
- return get_equalizer(data, value);
+ case VOCTRL_GET_EQUALIZER:
+ {
+ struct voctrl_get_equalizer_args *args = data;
+ return get_equalizer(args->name, args->valueptr);
}
case VOCTRL_ONTOP:
vo_x11_ontop();
diff --git a/libvo/vo_vesa.c b/libvo/vo_vesa.c
index f3d3ff1519..8b9e05a731 100644
--- a/libvo/vo_vesa.c
+++ b/libvo/vo_vesa.c
@@ -1087,7 +1087,8 @@ static int preinit(const char *arg)
if(arg) subdev_flags = parseSubDevice(arg);
if(lvo_name) pre_init_err = vlvo_preinit(lvo_name);
#ifdef CONFIG_VIDIX
- else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa);
+ else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,
+ video_out_vesa.old_functions);
#endif
// check if we can open /dev/mem (it will be opened later in config(), but if we
// detect now that we can't we can exit cleanly)
@@ -1101,7 +1102,7 @@ static int preinit(const char *arg)
return pre_init_err;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -1109,33 +1110,8 @@ static int control(uint32_t request, void *data, ...)
}
#ifdef CONFIG_VIDIX
- if (vidix_name) {
- switch (request) {
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, (int *)value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- }
+ if (vidix_name)
return vidix_control(request, data);
- }
#endif
return VO_NOTIMPL;
diff --git a/libvo/vo_wii.c b/libvo/vo_wii.c
index 030b19dd05..8999852d80 100644
--- a/libvo/vo_wii.c
+++ b/libvo/vo_wii.c
@@ -351,7 +351,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
if (request == VOCTRL_GET_IMAGE)
return get_image(data);
diff --git a/libvo/vo_winvidix.c b/libvo/vo_winvidix.c
index 337863fbf8..054e13730e 100644
--- a/libvo/vo_winvidix.c
+++ b/libvo/vo_winvidix.c
@@ -57,6 +57,7 @@ LIBVO_EXTERN(winvidix)
/* VIDIX related */
static char *vidix_name;
+static int depthonscreen;
/* Image parameters */
static uint32_t image_width;
static uint32_t image_height;
@@ -129,7 +130,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
/*update vidix*/
/* FIXME: implement runtime resize/move if possible, this way is very ugly! */
vidix_stop();
- if(vidix_init(image_width, image_height, vo_dx, vo_dy, vo_dwidth, vo_dheight, image_format, vo_depthonscreen, vo_screenwidth, vo_screenheight) != 0)
+ if(vidix_init(image_width, image_height, vo_dx, vo_dy, vo_dwidth, vo_dheight, image_format, depthonscreen, vo_screenwidth, vo_screenheight) != 0)
mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s\n", strerror(errno));
/*set colorkey*/
vidix_start();
@@ -203,7 +204,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,uint32_t d_h
image_format = format;
vo_screenwidth = GetSystemMetrics(SM_CXSCREEN);
vo_screenheight = GetSystemMetrics(SM_CYSCREEN);
- vo_depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL);
+ depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL);
aspect_save_orig(width, height);
@@ -336,13 +337,13 @@ static int preinit(const char *arg){
vidix_name = NULL;
}
- if (vidix_preinit(vidix_name, &video_out_winvidix) != 0)
+ if (vidix_preinit(vidix_name, video_out_winvidix.old_functions) != 0)
return 1;
return 0;
}
-static int control(uint32_t request, void *data, ...){
+static int control(uint32_t request, void *data){
switch (request) {
case VOCTRL_FULLSCREEN:
if(!vo_fs){vo_fs=1;ShowWindow(hWndFS,SW_SHOW);SetForegroundWindow(hWndFS);}
@@ -350,28 +351,6 @@ static int control(uint32_t request, void *data, ...){
break;
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, (int *)value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
}
return vidix_control(request, data);
// return VO_NOTIMPL;
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index d06c4394ed..4e6b1b79fb 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -667,7 +667,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
@@ -687,25 +687,13 @@ static int control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
- return vo_x11_set_equalizer(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_x11_set_equalizer(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
- return vo_x11_get_equalizer(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_x11_get_equalizer(args->name, args->valueptr);
}
case VOCTRL_ONTOP:
vo_x11_ontop();
diff --git a/libvo/vo_xover.c b/libvo/vo_xover.c
index f20d60f1d6..4935ca0fd7 100644
--- a/libvo/vo_xover.c
+++ b/libvo/vo_xover.c
@@ -82,8 +82,8 @@ static uint32_t window_width, window_height;
static uint32_t drwX, drwY, drwWidth, drwHeight, drwBorderWidth,
drwDepth, drwcX, drwcY, dwidth, dheight;
-static const vo_functions_t* sub_vo = NULL;
-
+static const struct vo_old_functions *sub_vo = NULL;
+static const struct vo_info_s *sub_info;
static void set_window(int force_update)
{
@@ -224,7 +224,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
mp_colorkey_t colork;
char _title[255];
- sprintf(_title,"MPlayer %s X11 Overlay",sub_vo->info->name);
+ sprintf(_title,"MPlayer %s X11 Overlay", sub_info->name);
title = _title;
panscan_init();
@@ -378,10 +378,10 @@ static void uninit(void)
sub_vo = NULL;
vo_x11_uninit();
// Restore our callbacks
- video_out_xover.draw_frame = draw_frame;
- video_out_xover.draw_slice = draw_slice;
- video_out_xover.flip_page = flip_page;
- video_out_xover.draw_osd = draw_osd;
+ video_out_xover.old_functions->draw_frame = draw_frame;
+ video_out_xover.old_functions->draw_slice = draw_slice;
+ video_out_xover.old_functions->flip_page = flip_page;
+ video_out_xover.old_functions->draw_osd = draw_osd;
}
static int preinit(const char *arg)
@@ -393,35 +393,38 @@ static int preinit(const char *arg)
return 1;
}
- for(i = 0 ; video_out_drivers[i] != NULL ; i++) {
- if(!strcmp(video_out_drivers[i]->info->short_name,arg) &&
- strcmp(video_out_drivers[i]->info->short_name,"xover"))
+ const struct vo_driver *candidate;
+ for(i = 0; (candidate = video_out_drivers[i]) != NULL; i++)
+ if (!candidate->is_new && !strcmp(candidate->info->short_name,arg) &&
+ strcmp(candidate->info->short_name,"xover"))
break;
- }
- if(!video_out_drivers[i]) {
+ if (!candidate) {
mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: Subdriver %s not found\n", arg);
return 1;
}
- if(video_out_drivers[i]->control(VOCTRL_XOVERLAY_SUPPORT,NULL) != VO_TRUE) {
+
+ const struct vo_old_functions *functions = candidate->old_functions;
+ if (functions->control(VOCTRL_XOVERLAY_SUPPORT,NULL) != VO_TRUE) {
mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: %s doesn't support XOverlay\n", arg);
return 1;
}
// X11 init
if (!vo_init()) return VO_FALSE;
- if(video_out_drivers[i]->preinit(NULL)) {
+ if(functions->preinit(NULL)) {
mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: Subvo init failed\n");
return 1;
}
- sub_vo = video_out_drivers[i];
+ sub_vo = functions;
+ sub_info = candidate->info;
// Setup the sub vo callbacks
- video_out_xover.draw_frame = sub_vo->draw_frame;
- video_out_xover.draw_slice = sub_vo->draw_slice;
- video_out_xover.flip_page = sub_vo->flip_page;
- video_out_xover.draw_osd = sub_vo->draw_osd;
+ video_out_xover.old_functions->draw_frame = sub_vo->draw_frame;
+ video_out_xover.old_functions->draw_slice = sub_vo->draw_slice;
+ video_out_xover.old_functions->flip_page = sub_vo->flip_page;
+ video_out_xover.old_functions->draw_osd = sub_vo->draw_osd;
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
if(!sub_vo) return VO_ERROR;
switch (request) {
@@ -443,7 +446,6 @@ static int control(uint32_t request, void *data, ...)
}
return VO_TRUE;
default:
- // Safe atm bcs nothing use more than 1 arg
return sub_vo->control(request,data);
}
return VO_NOTIMPL;
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index d9325eb9a9..178c9c4ca9 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -37,13 +37,18 @@ Buffer allocation:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
+#include <stdbool.h>
#include "config.h"
+#include "options.h"
+#include "talloc.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "video_out.h"
-#include "video_out_internal.h"
-
+#include "libmpcodecs/vfcap.h"
+#include "libmpcodecs/mp_image.h"
+#include "osd.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -58,6 +63,7 @@ Buffer allocation:
#include "subopt-helper.h"
#include "input/input.h"
+#include "mp_fifo.h"
#ifdef CONFIG_GUI
#include "gui/interface.h"
@@ -72,153 +78,167 @@ static const vo_info_t info = {
""
};
-const LIBVO_EXTERN(xv)
#ifdef HAVE_SHM
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
-
-static XShmSegmentInfo Shminfo[NUM_BUFFERS];
-static int Shmem_Flag;
#endif
// Note: depends on the inclusion of X11/extensions/XShm.h
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvlib.h>
-// FIXME: dynamically allocate this stuff
-static void allocate_xvimage(int);
-static unsigned int ver, rel, req, ev, err;
-static unsigned int formats, adaptors, xv_format;
-static XvAdaptorInfo *ai = NULL;
-static XvImageFormatValues *fo=NULL;
-
-static int current_buf = 0;
-static int current_ip_buf = 0;
-static int num_buffers = 1; // default
-static int visible_buf = -1; // -1 means: no buffer was drawn yet
-static XvImage *xvimage[NUM_BUFFERS];
-
-
-static uint32_t image_width;
-static uint32_t image_height;
-static uint32_t image_format;
-
-static int int_pause;
+struct xvctx {
+ XvAdaptorInfo *ai;
+ XvImageFormatValues *fo;
+ unsigned int formats, adaptors, xv_format;
+ int current_buf;
+ int current_ip_buf;
+ int num_buffers;
+ int total_buffers;
+ int have_visible_image_copy;
+ int have_next_image_copy;
+ int unchanged_visible_image;
+ int unchanged_next_image;
+ int visible_buf;
+ XvImage *xvimage[NUM_BUFFERS + 1];
+ uint32_t image_width;
+ uint32_t image_height;
+ uint32_t image_format;
+ int is_paused;
+ struct vo_rect src_rect;
+ struct vo_rect dst_rect;
+ uint32_t max_width, max_height; // zero means: not set
+ int event_fd_registered; // for uninit called from preinit
+ int mode_switched;
+ int osd_objects_drawn;
+ void (*draw_alpha_fnc)(void *ctx, int x0, int y0, int w, int h,
+ unsigned char *src, unsigned char *srca,
+ int stride);
+#ifdef HAVE_SHM
+ XShmSegmentInfo Shminfo[NUM_BUFFERS];
+ int Shmem_Flag;
+#endif
+};
-static struct vo_rect src_rect;
-static struct vo_rect dst_rect;
-static uint32_t max_width = 0, max_height = 0; // zero means: not set
+static void allocate_xvimage(struct vo *, int);
-static void (*draw_alpha_fnc) (int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride);
-static void draw_alpha_yv12(int x0, int y0, int w, int h,
+static void draw_alpha_yv12(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ struct vo *vo = p;
+ struct xvctx *ctx = vo->priv;
+ x0 += ctx->image_width * (vo->panscan_x >> 1)
+ / (vo->dwidth + vo->panscan_x);
vo_draw_alpha_yv12(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + x0,
- xvimage[current_buf]->pitches[0]);
+ ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0] +
+ ctx->xvimage[ctx->current_buf]->pitches[0] * y0 + x0,
+ ctx->xvimage[ctx->current_buf]->pitches[0]);
+ ctx->osd_objects_drawn++;
}
-static void draw_alpha_yuy2(int x0, int y0, int w, int h,
+static void draw_alpha_yuy2(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ struct vo *vo = p;
+ struct xvctx *ctx = vo->priv;
+ x0 += ctx->image_width * (vo->panscan_x >> 1)
+ / (vo->dwidth + vo->panscan_x);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + 2 * x0,
- xvimage[current_buf]->pitches[0]);
+ ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0] +
+ ctx->xvimage[ctx->current_buf]->pitches[0] * y0 + 2 * x0,
+ ctx->xvimage[ctx->current_buf]->pitches[0]);
+ ctx->osd_objects_drawn++;
}
-static void draw_alpha_uyvy(int x0, int y0, int w, int h,
+static void draw_alpha_uyvy(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ struct vo *vo = p;
+ struct xvctx *ctx = vo->priv;
+ x0 += ctx->image_width * (vo->panscan_x >> 1)
+ / (vo->dwidth + vo->panscan_x);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + 2 * x0 + 1,
- xvimage[current_buf]->pitches[0]);
+ ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0] +
+ ctx->xvimage[ctx->current_buf]->pitches[0] * y0 + 2 * x0 + 1,
+ ctx->xvimage[ctx->current_buf]->pitches[0]);
+ ctx->osd_objects_drawn++;
}
-static void draw_alpha_null(int x0, int y0, int w, int h,
+static void draw_alpha_null(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
}
-static void deallocate_xvimage(int foo);
+static void deallocate_xvimage(struct vo *vo, int foo);
-static void resize(void)
+static void resize(struct vo *vo)
{
- calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL, NULL);
- vo_x11_clearwindow_part(mDisplay, vo_window, dst_rect.width, dst_rect.height, 1);
- vo_xv_draw_colorkey(dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height);
+ struct xvctx *ctx = vo->priv;
+
+ calc_src_dst_rects(vo, ctx->image_width, ctx->image_height, &ctx->src_rect,
+ &ctx->dst_rect, NULL, NULL);
+ struct vo_rect *dst = &ctx->dst_rect;
+ vo_x11_clearwindow_part(vo, vo->x11->window, dst->width, dst->height, 1);
+ vo_xv_draw_colorkey(vo, dst->left, dst->top, dst->width, dst->height);
}
/*
* connect to server, create and map window,
* allocate colors and (shared) memory
*/
-static int config(uint32_t width, uint32_t height, uint32_t d_width,
- uint32_t d_height, uint32_t flags, char *title,
- uint32_t format)
+static int config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height, uint32_t flags,
+ char *title, uint32_t format)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
XVisualInfo vinfo;
XSetWindowAttributes xswa;
XWindowAttributes attribs;
unsigned long xswamask;
int depth;
+ struct xvctx *ctx = vo->priv;
+ int i;
-#ifdef CONFIG_XF86VM
- int vm = flags & VOFLAG_MODESWITCHING;
-#endif
-
- image_height = height;
- image_width = width;
- image_format = format;
+ ctx->image_height = height;
+ ctx->image_width = width;
+ ctx->image_format = format;
- if ((max_width != 0 && max_height != 0) &&
- (image_width > max_width || image_height > max_height))
- {
- mp_msg( MSGT_VO, MSGL_ERR, MSGTR_VO_XV_ImagedimTooHigh,
- image_width, image_height, max_width, max_height);
+ if ((ctx->max_width != 0 && ctx->max_height != 0)
+ && (ctx->image_width > ctx->max_width
+ || ctx->image_height > ctx->max_height)) {
+ mp_msg(MSGT_VO, MSGL_ERR, MSGTR_VO_XV_ImagedimTooHigh,
+ ctx->image_width, ctx->image_height, ctx->max_width,
+ ctx->max_height);
return -1;
}
- int_pause = 0;
- visible_buf = -1;
-
- num_buffers =
- vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1;
+ ctx->is_paused = 0;
+ ctx->visible_buf = -1;
+ ctx->have_visible_image_copy = false;
+ ctx->have_next_image_copy = false;
/* check image formats */
- {
- unsigned int i;
-
- xv_format = 0;
- for (i = 0; i < formats; i++)
- {
- mp_msg(MSGT_VO, MSGL_V,
- "Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,
- (char *) &fo[i].id,
- (fo[i].format == XvPacked) ? "packed" : "planar");
- if (fo[i].id == format)
- xv_format = fo[i].id;
- }
- if (!xv_format)
- return -1;
+ ctx->xv_format = 0;
+ for (i = 0; i < ctx->formats; i++) {
+ mp_msg(MSGT_VO, MSGL_V, "Xvideo image format: 0x%x (%4.4s) %s\n",
+ ctx->fo[i].id, (char *) &ctx->fo[i].id,
+ (ctx->fo[i].format == XvPacked) ? "packed" : "planar");
+ if (ctx->fo[i].id == format)
+ ctx->xv_format = ctx->fo[i].id;
}
+ if (!ctx->xv_format)
+ return -1;
#ifdef CONFIG_GUI
if (use_gui)
@@ -227,578 +247,619 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
#endif
{
#ifdef CONFIG_XF86VM
- if (vm)
- {
- vo_vm_switch();
+ int vm = flags & VOFLAG_MODESWITCHING;
+ if (vm) {
+ vo_vm_switch(vo);
+ ctx->mode_switched = 1;
}
#endif
- XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay),
+ XGetWindowAttributes(x11->display, DefaultRootWindow(x11->display),
&attribs);
depth = attribs.depth;
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
depth = 24;
- XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
+ XMatchVisualInfo(x11->display, x11->screen, depth, TrueColor, &vinfo);
xswa.background_pixel = 0;
- if (xv_ck_info.method == CK_METHOD_BACKGROUND)
- {
- xswa.background_pixel = xv_colorkey;
- }
+ if (x11->xv_ck_info.method == CK_METHOD_BACKGROUND)
+ xswa.background_pixel = x11->xv_colorkey;
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
- vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, vo_dwidth, vo_dheight,
- flags, CopyFromParent, "xv", title);
- XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
+ vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, vo->dwidth,
+ vo->dheight, flags, CopyFromParent, "xv",
+ title);
+ XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa);
#ifdef CONFIG_XF86VM
- if (vm)
- {
+ if (vm) {
/* Grab the mouse pointer in our window */
if (vo_grabpointer)
- XGrabPointer(mDisplay, vo_window, True, 0,
- GrabModeAsync, GrabModeAsync,
- vo_window, None, CurrentTime);
- XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime);
+ XGrabPointer(x11->display, x11->window, True, 0, GrabModeAsync,
+ GrabModeAsync, x11->window, None, CurrentTime);
+ XSetInputFocus(x11->display, x11->window, RevertToNone,
+ CurrentTime);
}
#endif
}
mp_msg(MSGT_VO, MSGL_V, "using Xvideo port %d for hw scaling\n",
- xv_port);
-
- switch (xv_format)
- {
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_IYUV:
- draw_alpha_fnc = draw_alpha_yv12;
- break;
- case IMGFMT_YUY2:
- case IMGFMT_YVYU:
- draw_alpha_fnc = draw_alpha_yuy2;
- break;
- case IMGFMT_UYVY:
- draw_alpha_fnc = draw_alpha_uyvy;
- break;
- default:
- draw_alpha_fnc = draw_alpha_null;
+ x11->xv_port);
+
+ switch (ctx->xv_format) {
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ ctx->draw_alpha_fnc = draw_alpha_yv12;
+ break;
+ case IMGFMT_YUY2:
+ case IMGFMT_YVYU:
+ ctx->draw_alpha_fnc = draw_alpha_yuy2;
+ break;
+ case IMGFMT_UYVY:
+ ctx->draw_alpha_fnc = draw_alpha_uyvy;
+ break;
+ default:
+ ctx->draw_alpha_fnc = draw_alpha_null;
}
- if (vo_config_count)
- for (current_buf = 0; current_buf < num_buffers; ++current_buf)
- deallocate_xvimage(current_buf);
+ // In case config has been called before
+ for (i = 0; i < ctx->total_buffers; i++)
+ deallocate_xvimage(vo, i);
- for (current_buf = 0; current_buf < num_buffers; ++current_buf)
- allocate_xvimage(current_buf);
+ ctx->num_buffers =
+ vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1;
+ ctx->total_buffers = ctx->num_buffers + 1;
+
+ for (i = 0; i < ctx->total_buffers; i++)
+ allocate_xvimage(vo, i);
- current_buf = 0;
- current_ip_buf = 0;
+ ctx->current_buf = 0;
+ ctx->current_ip_buf = 0;
- resize();
+
+ resize(vo);
return 0;
}
-static void allocate_xvimage(int foo)
+static void allocate_xvimage(struct vo *vo, int foo)
{
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
/*
* allocate XvImages. FIXME: no error checking, without
* mit-shm this will bomb... trzing to fix ::atmos
*/
#ifdef HAVE_SHM
- if (mLocalDisplay && XShmQueryExtension(mDisplay))
- Shmem_Flag = 1;
- else
- {
- Shmem_Flag = 0;
- mp_msg(MSGT_VO, MSGL_INFO,
- MSGTR_LIBVO_XV_SharedMemoryNotSupported);
+ if (x11->display_is_local && XShmQueryExtension(x11->display))
+ ctx->Shmem_Flag = 1;
+ else {
+ ctx->Shmem_Flag = 0;
+ mp_msg(MSGT_VO, MSGL_INFO, MSGTR_LIBVO_XV_SharedMemoryNotSupported);
}
- if (Shmem_Flag)
- {
- xvimage[foo] =
- (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format,
- NULL, image_width, image_height,
- &Shminfo[foo]);
-
- Shminfo[foo].shmid =
- shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
- Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
- Shminfo[foo].readOnly = False;
-
- xvimage[foo]->data = Shminfo[foo].shmaddr;
- XShmAttach(mDisplay, &Shminfo[foo]);
- XSync(mDisplay, False);
- shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
+ if (ctx->Shmem_Flag) {
+ ctx->xvimage[foo] =
+ (XvImage *) XvShmCreateImage(x11->display, x11->xv_port,
+ ctx->xv_format, NULL,
+ ctx->image_width, ctx->image_height,
+ &ctx->Shminfo[foo]);
+
+ ctx->Shminfo[foo].shmid = shmget(IPC_PRIVATE,
+ ctx->xvimage[foo]->data_size,
+ IPC_CREAT | 0777);
+ ctx->Shminfo[foo].shmaddr = (char *) shmat(ctx->Shminfo[foo].shmid, 0,
+ 0);
+ ctx->Shminfo[foo].readOnly = False;
+
+ ctx->xvimage[foo]->data = ctx->Shminfo[foo].shmaddr;
+ XShmAttach(x11->display, &ctx->Shminfo[foo]);
+ XSync(x11->display, False);
+ shmctl(ctx->Shminfo[foo].shmid, IPC_RMID, 0);
} else
#endif
{
- xvimage[foo] =
- (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL,
- image_width, image_height);
- xvimage[foo]->data = malloc(xvimage[foo]->data_size);
- XSync(mDisplay, False);
+ ctx->xvimage[foo] =
+ (XvImage *) XvCreateImage(x11->display, x11->xv_port,
+ ctx->xv_format, NULL, ctx->image_width,
+ ctx->image_height);
+ ctx->xvimage[foo]->data = malloc(ctx->xvimage[foo]->data_size);
+ XSync(x11->display, False);
}
- memset(xvimage[foo]->data, 128, xvimage[foo]->data_size);
+ memset(ctx->xvimage[foo]->data, 128, ctx->xvimage[foo]->data_size);
return;
}
-static void deallocate_xvimage(int foo)
+static void deallocate_xvimage(struct vo *vo, int foo)
{
+ struct xvctx *ctx = vo->priv;
#ifdef HAVE_SHM
- if (Shmem_Flag)
- {
- XShmDetach(mDisplay, &Shminfo[foo]);
- shmdt(Shminfo[foo].shmaddr);
+ if (ctx->Shmem_Flag) {
+ XShmDetach(vo->x11->display, &ctx->Shminfo[foo]);
+ shmdt(ctx->Shminfo[foo].shmaddr);
} else
#endif
{
- free(xvimage[foo]->data);
+ free(ctx->xvimage[foo]->data);
}
- XFree(xvimage[foo]);
+ XFree(ctx->xvimage[foo]);
- XSync(mDisplay, False);
+ XSync(vo->x11->display, False);
return;
}
-static inline void put_xvimage( XvImage * xvi )
+static inline void put_xvimage(struct vo *vo, XvImage *xvi)
{
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
+ struct vo_rect *src = &ctx->src_rect;
+ struct vo_rect *dst = &ctx->dst_rect;
#ifdef HAVE_SHM
- if (Shmem_Flag)
- {
- XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc,
- xvi,
- src_rect.left, src_rect.top, src_rect.width, src_rect.height,
- dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height,
+ if (ctx->Shmem_Flag) {
+ XvShmPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi,
+ src->left, src->top, src->width, src->height,
+ dst->left, dst->top, dst->width, dst->height,
False);
} else
#endif
{
- XvPutImage(mDisplay, xv_port, vo_window, vo_gc,
- xvi,
- src_rect.left, src_rect.top, src_rect.width, src_rect.height,
- dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height);
+ XvPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi,
+ src->left, src->top, src->width, src->height,
+ dst->left, dst->top, dst->width, dst->height);
}
}
-static void check_events(void)
+// Only copies luma for planar formats as draw_alpha doesn't change others */
+void copy_backup_image(struct vo *vo, int dest, int src)
{
- int e = vo_x11_check_events(mDisplay);
+ struct xvctx *ctx = vo->priv;
+
+ XvImage *vb = ctx->xvimage[dest];
+ XvImage *cp = ctx->xvimage[src];
+ memcpy_pic(vb->data + vb->offsets[0], cp->data + cp->offsets[0],
+ vb->width, vb->height,
+ vb->pitches[0], cp->pitches[0]);
+}
+
+static void check_events(struct vo *vo)
+{
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
+ int e = vo_x11_check_events(vo);
if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE)
- {
- resize();
- }
+ resize(vo);
- if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause)
- {
+ if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && ctx->is_paused) {
/* did we already draw a buffer */
- if ( visible_buf != -1 )
- {
- /* redraw the last visible buffer */
- put_xvimage( xvimage[visible_buf] );
+ if (ctx->visible_buf != -1) {
+ /* redraw the last visible buffer */
+ put_xvimage(vo, ctx->xvimage[ctx->visible_buf]);
}
}
}
-static void draw_osd(void)
+static void draw_osd(struct vo *vo, struct osd_state *osd)
{
- vo_draw_text(image_width -
- image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x),
- image_height, draw_alpha_fnc);
+ struct xvctx *ctx = vo->priv;
+
+ ctx->osd_objects_drawn = 0;
+ osd_draw_text(osd,
+ ctx->image_width -
+ ctx->image_width * vo->panscan_x / (vo->dwidth +
+ vo->panscan_x),
+ ctx->image_height, ctx->draw_alpha_fnc, vo);
+ if (ctx->osd_objects_drawn)
+ ctx->unchanged_next_image = false;
+}
+
+static int redraw_osd(struct vo *vo, struct osd_state *osd)
+{
+ struct xvctx *ctx = vo->priv;
+
+ if (ctx->have_visible_image_copy)
+ copy_backup_image(vo, ctx->visible_buf, ctx->num_buffers);
+ else if (ctx->unchanged_visible_image) {
+ copy_backup_image(vo, ctx->num_buffers, ctx->visible_buf);
+ ctx->have_visible_image_copy = true;
+ }
+ else
+ return false;
+ int temp = ctx->current_buf;
+ ctx->current_buf = ctx->visible_buf;
+ draw_osd(vo, osd);
+ ctx->current_buf = temp;
+ put_xvimage(vo, ctx->xvimage[ctx->visible_buf]);
+ return true;
}
-static void flip_page(void)
+static void flip_page(struct vo *vo)
{
- put_xvimage( xvimage[current_buf] );
+ struct xvctx *ctx = vo->priv;
+ put_xvimage(vo, ctx->xvimage[ctx->current_buf]);
/* remember the currently visible buffer */
- visible_buf = current_buf;
+ ctx->visible_buf = ctx->current_buf;
- if (num_buffers > 1)
- {
- current_buf =
- vo_directrendering ? 0 : ((current_buf + 1) % num_buffers);
- XFlush(mDisplay);
+ ctx->have_visible_image_copy = ctx->have_next_image_copy;
+ ctx->have_next_image_copy = false;
+ ctx->unchanged_visible_image = ctx->unchanged_next_image;
+ ctx->unchanged_next_image = false;
+
+ if (ctx->num_buffers > 1) {
+ ctx->current_buf = vo_directrendering ? 0 : ((ctx->current_buf + 1) %
+ ctx->num_buffers);
+ XFlush(vo->x11->display);
} else
- XSync(mDisplay, False);
+ XSync(vo->x11->display, False);
return;
}
-static int draw_slice(uint8_t * image[], int stride[], int w, int h,
- int x, int y)
+static int draw_slice(struct vo *vo, uint8_t *image[], int stride[], int w,
+ int h, int x, int y)
{
+ struct xvctx *ctx = vo->priv;
uint8_t *dst;
+ XvImage *current_image = ctx->xvimage[ctx->current_buf];
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y + x;
- memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0],
- stride[0]);
+ dst = current_image->data + current_image->offsets[0]
+ + current_image->pitches[0] * y + x;
+ memcpy_pic(dst, image[0], w, h, current_image->pitches[0], stride[0]);
x /= 2;
y /= 2;
w /= 2;
h /= 2;
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] +
- xvimage[current_buf]->pitches[1] * y + x;
- if (image_format != IMGFMT_YV12)
- memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
- stride[1]);
+ dst = current_image->data + current_image->offsets[1]
+ + current_image->pitches[1] * y + x;
+ if (ctx->image_format != IMGFMT_YV12)
+ memcpy_pic(dst, image[1], w, h, current_image->pitches[1], stride[1]);
else
- memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
- stride[2]);
-
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] +
- xvimage[current_buf]->pitches[2] * y + x;
- if (image_format == IMGFMT_YV12)
- memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
- stride[1]);
+ memcpy_pic(dst, image[2], w, h, current_image->pitches[1], stride[2]);
+
+ dst = current_image->data + current_image->offsets[2]
+ + current_image->pitches[2] * y + x;
+ if (ctx->image_format == IMGFMT_YV12)
+ memcpy_pic(dst, image[1], w, h, current_image->pitches[1], stride[1]);
else
- memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
- stride[2]);
+ memcpy_pic(dst, image[2], w, h, current_image->pitches[1], stride[2]);
return 0;
}
-static int draw_frame(uint8_t * src[])
+static int draw_frame(struct vo *vo, uint8_t *src[])
{
return VO_ERROR;
}
-static uint32_t draw_image(mp_image_t * mpi)
+static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
{
+ struct xvctx *ctx = vo->priv;
+
+ ctx->have_next_image_copy = false;
+
if (mpi->flags & MP_IMGFLAG_DIRECT)
- {
// direct rendering:
- current_buf = (int) (mpi->priv); // hack!
- return VO_TRUE;
- }
- if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
- return VO_TRUE; // done
- if (mpi->flags & MP_IMGFLAG_PLANAR)
- {
- draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
- return VO_TRUE;
- }
- if (mpi->flags & MP_IMGFLAG_YUV)
- {
+ ctx->current_buf = (int) (mpi->priv); // hack!
+ else if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
+ ; // done
+ else if (mpi->flags & MP_IMGFLAG_PLANAR)
+ draw_slice(vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
+ else if (mpi->flags & MP_IMGFLAG_YUV)
// packed YUV:
- memcpy_pic(xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0], mpi->planes[0],
+ memcpy_pic(ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0], mpi->planes[0],
mpi->w * (mpi->bpp / 8), mpi->h,
- xvimage[current_buf]->pitches[0], mpi->stride[0]);
- return VO_TRUE;
+ ctx->xvimage[ctx->current_buf]->pitches[0], mpi->stride[0]);
+ else
+ return false;
+
+ if (ctx->is_paused) {
+ copy_backup_image(vo, ctx->num_buffers, ctx->current_buf);
+ ctx->have_next_image_copy = true;
}
- return VO_FALSE; // not (yet) supported
+ ctx->unchanged_next_image = true;
+ return true;
}
-static uint32_t get_image(mp_image_t * mpi)
+static uint32_t get_image(struct xvctx *ctx, mp_image_t *mpi)
{
- int buf = current_buf; // we shouldn't change current_buf unless we do DR!
+ // we shouldn't change current_buf unless we do DR!
+ int buf = ctx->current_buf;
- if (mpi->type == MP_IMGTYPE_STATIC && num_buffers > 1)
+ if (mpi->type == MP_IMGTYPE_STATIC && ctx->num_buffers > 1)
return VO_FALSE; // it is not static
- if (mpi->imgfmt != image_format)
+ if (mpi->imgfmt != ctx->image_format)
return VO_FALSE; // needs conversion :(
-// if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
- if (mpi->flags & MP_IMGFLAG_READABLE &&
- (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP))
- {
+ if (mpi->flags & MP_IMGFLAG_READABLE
+ && (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) {
// reference (I/P) frame of IP or IPB:
- if (num_buffers < 2)
+ if (ctx->num_buffers < 2)
return VO_FALSE; // not enough
- current_ip_buf ^= 1;
+ ctx->current_ip_buf ^= 1;
// for IPB with 2 buffers we can DR only one of the 2 P frames:
- if (mpi->type == MP_IMGTYPE_IPB && num_buffers < 3
- && current_ip_buf)
+ if (mpi->type == MP_IMGTYPE_IPB && ctx->num_buffers < 3
+ && ctx->current_ip_buf)
return VO_FALSE;
- buf = current_ip_buf;
+ buf = ctx->current_ip_buf;
if (mpi->type == MP_IMGTYPE_IPB)
++buf; // preserve space for B
}
- if (mpi->height > xvimage[buf]->height)
+ if (mpi->height > ctx->xvimage[buf]->height)
return VO_FALSE; //buffer to small
- if (mpi->width * (mpi->bpp / 8) > xvimage[buf]->pitches[0])
+ if (mpi->width * (mpi->bpp / 8) > ctx->xvimage[buf]->pitches[0])
return VO_FALSE; //buffer to small
if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH))
- || (mpi->width * (mpi->bpp / 8) == xvimage[buf]->pitches[0]))
- {
- current_buf = buf;
- mpi->planes[0] =
- xvimage[current_buf]->data + xvimage[current_buf]->offsets[0];
- mpi->stride[0] = xvimage[current_buf]->pitches[0];
+ || (mpi->width * (mpi->bpp / 8) == ctx->xvimage[buf]->pitches[0])) {
+ ctx->current_buf = buf;
+ XvImage *current_image = ctx->xvimage[ctx->current_buf];
+ mpi->planes[0] = current_image->data + current_image->offsets[0];
+ mpi->stride[0] = current_image->pitches[0];
mpi->width = mpi->stride[0] / (mpi->bpp / 8);
- if (mpi->flags & MP_IMGFLAG_PLANAR)
- {
- if (mpi->flags & MP_IMGFLAG_SWAPPED)
- {
+ if (mpi->flags & MP_IMGFLAG_PLANAR) {
+ if (mpi->flags & MP_IMGFLAG_SWAPPED) {
// I420
- mpi->planes[1] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[1];
- mpi->planes[2] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[2];
- mpi->stride[1] = xvimage[current_buf]->pitches[1];
- mpi->stride[2] = xvimage[current_buf]->pitches[2];
- } else
- {
+ mpi->planes[1] = current_image->data
+ + current_image->offsets[1];
+ mpi->planes[2] = current_image->data
+ + current_image->offsets[2];
+ mpi->stride[1] = current_image->pitches[1];
+ mpi->stride[2] = current_image->pitches[2];
+ } else {
// YV12
- mpi->planes[1] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[2];
- mpi->planes[2] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[1];
- mpi->stride[1] = xvimage[current_buf]->pitches[2];
- mpi->stride[2] = xvimage[current_buf]->pitches[1];
+ mpi->planes[1] = current_image->data
+ + current_image->offsets[2];
+ mpi->planes[2] = current_image->data
+ + current_image->offsets[1];
+ mpi->stride[1] = current_image->pitches[2];
+ mpi->stride[2] = current_image->pitches[1];
}
}
mpi->flags |= MP_IMGFLAG_DIRECT;
- mpi->priv = (void *) current_buf;
-// printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n");
+ mpi->priv = (void *) ctx->current_buf;
return VO_TRUE;
}
return VO_FALSE;
}
-static int query_format(uint32_t format)
+static int query_format(struct xvctx *ctx, uint32_t format)
{
uint32_t i;
int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN
/* check image formats */
- for (i = 0; i < formats; i++)
- {
- if (fo[i].id == format)
+ for (i = 0; i < ctx->formats; i++) {
+ if (ctx->fo[i].id == format)
return flag; //xv_format = fo[i].id;
}
return 0;
}
-static void uninit(void)
+static void uninit(struct vo *vo)
{
+ struct xvctx *ctx = vo->priv;
int i;
- if (!vo_config_count)
- return;
- visible_buf = -1;
- XvFreeAdaptorInfo(ai);
- ai = NULL;
- if(fo){
- XFree(fo);
- fo=NULL;
+ ctx->visible_buf = -1;
+ if (ctx->ai)
+ XvFreeAdaptorInfo(ctx->ai);
+ ctx->ai = NULL;
+ if (ctx->fo) {
+ XFree(ctx->fo);
+ ctx->fo = NULL;
}
- for (i = 0; i < num_buffers; i++)
- deallocate_xvimage(i);
+ for (i = 0; i < ctx->total_buffers; i++)
+ deallocate_xvimage(vo, i);
#ifdef CONFIG_XF86VM
- vo_vm_close();
+ if (ctx->mode_switched)
+ vo_vm_close(vo);
#endif
- mp_input_rm_event_fd(ConnectionNumber(mDisplay));
- vo_x11_uninit();
+ if (ctx->event_fd_registered)
+ mp_input_rm_key_fd(vo->input_ctx, ConnectionNumber(vo->x11->display));
+ // uninit() shouldn't get called unless initialization went past vo_init()
+ vo_x11_uninit(vo);
+}
+
+static int x11_fd_callback(void *ctx, int fd)
+{
+ struct vo *vo = ctx;
+ check_events(vo);
+ return mplayer_get_key(vo->key_fifo, 0);
}
-static int preinit(const char *arg)
+static int preinit(struct vo *vo, const char *arg)
{
XvPortID xv_p;
int busy_ports = 0;
unsigned int i;
strarg_t ck_src_arg = { 0, NULL };
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;
- const opt_t subopts[] =
- {
- /* name arg type arg var test */
- { "port", OPT_ARG_INT, &xv_port, (opt_test_f)int_pos },
- { "adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f)int_non_neg },
- { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck },
- { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm },
- { NULL }
+ const opt_t subopts[] = {
+ /* name arg type arg var test */
+ {"port", OPT_ARG_INT, &x11->xv_port, (opt_test_f) int_pos},
+ {"adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f) int_non_neg},
+ {"ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck},
+ {"ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm},
+ {NULL}
};
- xv_port = 0;
+ x11->xv_port = 0;
/* parse suboptions */
- if ( subopt_parse( arg, subopts ) != 0 )
- {
- return -1;
+ if (subopt_parse(arg, subopts) != 0) {
+ return -1;
}
/* modify colorkey settings according to the given options */
- xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str );
+ xv_setup_colorkeyhandling(vo, ck_method_arg.str, ck_src_arg.str);
- if (!vo_init())
+ if (!vo_init(vo))
return -1;
/* check for Xvideo extension */
- if (Success != XvQueryExtension(mDisplay, &ver, &rel, &req, &ev, &err))
- {
- mp_msg(MSGT_VO, MSGL_ERR,
- MSGTR_LIBVO_XV_XvNotSupportedByX11);
- return -1;
+ unsigned int ver, rel, req, ev, err;
+ if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err)) {
+ mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_XvNotSupportedByX11);
+ goto error;
}
/* check for Xvideo support */
if (Success !=
- XvQueryAdaptors(mDisplay, DefaultRootWindow(mDisplay), &adaptors,
- &ai))
- {
+ XvQueryAdaptors(x11->display, DefaultRootWindow(x11->display),
+ &ctx->adaptors, &ctx->ai)) {
mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_XvQueryAdaptorsFailed);
- return -1;
+ goto error;
}
/* check adaptors */
- if (xv_port)
- {
+ if (x11->xv_port) {
int port_found;
- for (port_found = 0, i = 0; !port_found && i < adaptors; i++)
- {
- if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask))
- {
- for (xv_p = ai[i].base_id;
- xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p)
- {
- if (xv_p == xv_port)
- {
+ for (port_found = 0, i = 0; !port_found && i < ctx->adaptors; i++) {
+ if ((ctx->ai[i].type & XvInputMask)
+ && (ctx->ai[i].type & XvImageMask)) {
+ for (xv_p = ctx->ai[i].base_id;
+ xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports;
+ ++xv_p) {
+ if (xv_p == x11->xv_port) {
port_found = 1;
break;
}
}
}
}
- if (port_found)
- {
- if (XvGrabPort(mDisplay, xv_port, CurrentTime))
- xv_port = 0;
- } else
- {
- mp_msg(MSGT_VO, MSGL_WARN,
- MSGTR_LIBVO_XV_InvalidPortParameter);
- xv_port = 0;
+ if (port_found) {
+ if (XvGrabPort(x11->display, x11->xv_port, CurrentTime))
+ x11->xv_port = 0;
+ } else {
+ mp_msg(MSGT_VO, MSGL_WARN, MSGTR_LIBVO_XV_InvalidPortParameter);
+ x11->xv_port = 0;
}
}
- for (i = 0; i < adaptors && xv_port == 0; i++)
- {
+ for (i = 0; i < ctx->adaptors && x11->xv_port == 0; i++) {
/* check if adaptor number has been specified */
if (xv_adaptor != -1 && xv_adaptor != i)
- continue;
-
- if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask))
- {
- for (xv_p = ai[i].base_id;
- xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p)
- if (!XvGrabPort(mDisplay, xv_p, CurrentTime))
- {
- xv_port = xv_p;
+ continue;
+
+ if ((ctx->ai[i].type & XvInputMask) && (ctx->ai[i].type & XvImageMask)) {
+ for (xv_p = ctx->ai[i].base_id;
+ xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports; ++xv_p)
+ if (!XvGrabPort(x11->display, xv_p, CurrentTime)) {
+ x11->xv_port = xv_p;
mp_msg(MSGT_VO, MSGL_V,
"[VO_XV] Using Xv Adapter #%d (%s)\n",
- i, ai[i].name);
+ i, ctx->ai[i].name);
break;
- } else
- {
- mp_msg(MSGT_VO, MSGL_WARN,
- MSGTR_LIBVO_XV_CouldNotGrabPort, (int) xv_p);
+ } else {
+ mp_msg(MSGT_VO, MSGL_WARN, MSGTR_LIBVO_XV_CouldNotGrabPort,
+ (int) xv_p);
++busy_ports;
}
}
}
- if (!xv_port)
- {
+ if (!x11->xv_port) {
if (busy_ports)
- mp_msg(MSGT_VO, MSGL_ERR,
- MSGTR_LIBVO_XV_CouldNotFindFreePort);
+ mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_CouldNotFindFreePort);
else
- mp_msg(MSGT_VO, MSGL_ERR,
- MSGTR_LIBVO_XV_NoXvideoSupport);
- return -1;
+ mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_NoXvideoSupport);
+ goto error;
}
- if ( !vo_xv_init_colorkey() )
- {
- return -1; // bail out, colorkey setup failed
+ if (!vo_xv_init_colorkey(vo)) {
+ goto error; // bail out, colorkey setup failed
}
- vo_xv_enable_vsync();
- vo_xv_get_max_img_dim( &max_width, &max_height );
+ vo_xv_enable_vsync(vo);
+ vo_xv_get_max_img_dim(vo, &ctx->max_width, &ctx->max_height);
- fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats);
+ ctx->fo = XvListImageFormats(x11->display, x11->xv_port,
+ (int *) &ctx->formats);
- mp_input_add_event_fd(ConnectionNumber(mDisplay), check_events);
+ mp_input_add_key_fd(vo->input_ctx, ConnectionNumber(x11->display), 1,
+ x11_fd_callback, NULL, vo);
+ ctx->event_fd_registered = 1;
return 0;
+
+ error:
+ uninit(vo); // free resources
+ return -1;
}
-static int control(uint32_t request, void *data, ...)
+static int control(struct vo *vo, uint32_t request, void *data)
{
- switch (request)
- {
- case VOCTRL_PAUSE:
- return int_pause = 1;
- case VOCTRL_RESUME:
- return int_pause = 0;
- case VOCTRL_QUERY_FORMAT:
- return query_format(*((uint32_t *) data));
- case VOCTRL_GET_IMAGE:
- return get_image(data);
- case VOCTRL_DRAW_IMAGE:
- return draw_image(data);
- case VOCTRL_GUISUPPORT:
- return VO_TRUE;
- case VOCTRL_GET_PANSCAN:
- if (!vo_config_count || !vo_fs)
- return VO_FALSE;
- return VO_TRUE;
- case VOCTRL_FULLSCREEN:
- vo_x11_fullscreen();
- /* indended, fallthrough to update panscan on fullscreen/windowed switch */
- case VOCTRL_SET_PANSCAN:
- if ((vo_fs && (vo_panscan != vo_panscan_amount))
- || (!vo_fs && vo_panscan_amount))
- {
- int old_y = vo_panscan_y;
-
- panscan_calc();
-
- if (old_y != vo_panscan_y)
- {
- resize();
- flip_page();
- }
- }
- return VO_TRUE;
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
-
- return vo_xv_set_eq(xv_port, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
-
- return vo_xv_get_eq(xv_port, data, value);
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
+ switch (request) {
+ case VOCTRL_PAUSE:
+ return (ctx->is_paused = 1);
+ case VOCTRL_RESUME:
+ return (ctx->is_paused = 0);
+ case VOCTRL_QUERY_FORMAT:
+ return query_format(ctx, *((uint32_t *) data));
+ case VOCTRL_GET_IMAGE:
+ return get_image(ctx, data);
+ case VOCTRL_DRAW_IMAGE:
+ return draw_image(vo, data);
+ case VOCTRL_GUISUPPORT:
+ return VO_TRUE;
+ case VOCTRL_GET_PANSCAN:
+ if (!vo->config_ok || !vo_fs)
+ return VO_FALSE;
+ return VO_TRUE;
+ case VOCTRL_FULLSCREEN:
+ vo_x11_fullscreen(vo);
+ /* indended, fallthrough to update panscan on fullscreen/windowed switch */
+ case VOCTRL_SET_PANSCAN:
+ if ((vo_fs && (vo_panscan != vo->panscan_amount))
+ || (!vo_fs && vo->panscan_amount)) {
+ int old_y = vo->panscan_y;
+
+ panscan_calc(vo);
+
+ if (old_y != vo->panscan_y) {
+ resize(vo);
+ flip_page(vo);
}
- case VOCTRL_ONTOP:
- vo_x11_ontop();
- return VO_TRUE;
- case VOCTRL_UPDATE_SCREENINFO:
- update_xinerama_info();
- return VO_TRUE;
+ }
+ return VO_TRUE;
+ case VOCTRL_SET_EQUALIZER:
+ {
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_xv_set_eq(vo, x11->xv_port, args->name, args->value);
+ }
+ case VOCTRL_GET_EQUALIZER:
+ {
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_xv_get_eq(vo, x11->xv_port, args->name, args->valueptr);
+ }
+ case VOCTRL_ONTOP:
+ vo_x11_ontop(vo);
+ return VO_TRUE;
+ case VOCTRL_UPDATE_SCREENINFO:
+ update_xinerama_info(vo);
+ return VO_TRUE;
+ case VOCTRL_REDRAW_OSD:
+ return redraw_osd(vo, data);
}
return VO_NOTIMPL;
}
+
+const struct vo_driver video_out_xv = {
+ .is_new = 1,
+ .info = &info,
+ .preinit = preinit,
+ .config = config,
+ .control = control,
+ .draw_frame = draw_frame,
+ .draw_slice = draw_slice,
+ .draw_osd = draw_osd,
+ .flip_page = flip_page,
+ .check_events = check_events,
+ .uninit = uninit
+};
diff --git a/libvo/vo_xvidix.c b/libvo/vo_xvidix.c
index b48168e6d5..620d6df3b5 100644
--- a/libvo/vo_xvidix.c
+++ b/libvo/vo_xvidix.c
@@ -409,13 +409,13 @@ static int preinit(const char *arg)
if (!vo_init())
return -1;
- if (vidix_preinit(vidix_name, &video_out_xvidix) != 0)
+ if (vidix_preinit(vidix_name, video_out_xvidix.old_functions) != 0)
return 1;
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
@@ -439,30 +439,6 @@ static int control(uint32_t request, void *data, ...)
set_window(0);
}
return VO_TRUE;
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
case VOCTRL_UPDATE_SCREENINFO:
aspect_save_screenres(vo_screenwidth, vo_screenheight);
return VO_TRUE;
diff --git a/libvo/vo_xvmc.c b/libvo/vo_xvmc.c
index 38b3a80b14..696fc682ba 100644
--- a/libvo/vo_xvmc.c
+++ b/libvo/vo_xvmc.c
@@ -1269,7 +1269,7 @@ assert(rndr->next_free_data_block_num == 0);
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ... )
+static int control(uint32_t request, void *data)
{
switch (request){
case VOCTRL_GET_DEINTERLACE:
@@ -1311,26 +1311,14 @@ static int control(uint32_t request, void *data, ... )
return VO_TRUE;
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vo_xv_set_eq(xv_port, data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_xv_set_eq(xv_port, args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vo_xv_get_eq(xv_port, data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_xv_get_eq(xv_port, args->name, args->valueptr);
}
case VOCTRL_UPDATE_SCREENINFO:
update_xinerama_info();
diff --git a/libvo/vo_xvr100.c b/libvo/vo_xvr100.c
index 476744729c..7a82c436fb 100644
--- a/libvo/vo_xvr100.c
+++ b/libvo/vo_xvr100.c
@@ -428,7 +428,7 @@ static int query_format(uint32_t format)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_IMAGE:
diff --git a/libvo/vo_yuv4mpeg.c b/libvo/vo_yuv4mpeg.c
index a7790fcc52..3a7a9a9d5c 100644
--- a/libvo/vo_yuv4mpeg.c
+++ b/libvo/vo_yuv4mpeg.c
@@ -553,7 +553,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_zr.c b/libvo/vo_zr.c
index b73150c3d0..a34744739c 100644
--- a/libvo/vo_zr.c
+++ b/libvo/vo_zr.c
@@ -830,7 +830,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_zr2.c b/libvo/vo_zr2.c
index 34a92c4172..d3fe6604de 100644
--- a/libvo/vo_zr2.c
+++ b/libvo/vo_zr2.c
@@ -449,7 +449,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
return 0;
}
-static int control(uint32_t request, void *data, ...) {
+static int control(uint32_t request, void *data) {
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
diff --git a/libvo/vosub_vidix.c b/libvo/vosub_vidix.c
index 688311b3ab..1c52c31094 100644
--- a/libvo/vosub_vidix.c
+++ b/libvo/vosub_vidix.c
@@ -44,6 +44,7 @@
#include "video_out.h"
#include "sub.h"
#include "vosub_vidix.h"
+#include "old_vo_wrapper.h"
#include "libmpcodecs/vfcap.h"
#include "libmpcodecs/mp_image.h"
@@ -59,7 +60,7 @@ static int video_on=0;
static vidix_capability_t vidix_cap;
static vidix_playback_t vidix_play;
static vidix_fourcc_t vidix_fourcc;
-static vo_functions_t * vo_server;
+static struct vo_old_functions *vo_server;
static vidix_yuv_t dstrides;
/*static uint32_t (*server_control)(uint32_t request, void *data, ...);*/
@@ -96,7 +97,7 @@ void vidix_term( void )
// vo_server->control=server_control;
}
-static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -160,7 +161,7 @@ static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h
return -1;
}
-static uint32_t vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -206,7 +207,7 @@ static uint32_t vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h
return -1;
}
-static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -223,7 +224,7 @@ static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,in
return 0;
}
-static uint32_t vidix_draw_slice_nv12(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_nv12(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -251,7 +252,7 @@ static uint32_t vidix_draw_slice_nv12(uint8_t *image[], int stride[], int w,int
return 0;
}
-static uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawsliceWasCalled);
return -1;
@@ -269,7 +270,7 @@ static uint32_t vidix_draw_image(mp_image_t *mpi){
return VO_TRUE;
}
-static uint32_t vidix_draw_frame(uint8_t *image[])
+static int vidix_draw_frame(uint8_t *image[])
{
mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawframeWasCalled);
return -1;
@@ -576,7 +577,7 @@ static uint32_t vidix_get_image(mp_image_t *mpi)
return VO_FALSE;
}
-uint32_t vidix_control(uint32_t request, void *data, ...)
+uint32_t vidix_control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -596,36 +597,31 @@ uint32_t vidix_control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
vidix_video_eq_t info;
if(!video_on) return VO_FALSE;
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
-// printf("vidix seteq %s -> %d \n",data,value);
+
+ struct voctrl_set_equalizer_args *args = data;
/* vidix eq ranges are -1000..1000 */
- if (!strcasecmp(data, "brightness"))
+ if (!strcasecmp(args->name, "brightness"))
{
- info.brightness = value*10;
+ info.brightness = args->value*10;
info.cap = VEQ_CAP_BRIGHTNESS;
}
- else if (!strcasecmp(data, "contrast"))
+ else if (!strcasecmp(args->name, "contrast"))
{
- info.contrast = value*10;
+ info.contrast = args->value*10;
info.cap = VEQ_CAP_CONTRAST;
}
- else if (!strcasecmp(data, "saturation"))
+ else if (!strcasecmp(args->name, "saturation"))
{
- info.saturation = value*10;
+ info.saturation = args->value*10;
info.cap = VEQ_CAP_SATURATION;
}
- else if (!strcasecmp(data, "hue"))
+ else if (!strcasecmp(args->name, "hue"))
{
- info.hue = value*10;
+ info.hue = args->value*10;
info.cap = VEQ_CAP_HUE;
}
@@ -635,38 +631,34 @@ uint32_t vidix_control(uint32_t request, void *data, ...)
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
vidix_video_eq_t info;
if(!video_on) return VO_FALSE;
if (vdlPlaybackGetEq(vidix_handler, &info) != 0)
return VO_FALSE;
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
+ struct voctrl_get_equalizer_args *args = data;
/* vidix eq ranges are -1000..1000 */
- if (!strcasecmp(data, "brightness"))
+ if (!strcasecmp(args->name, "brightness"))
{
if (info.cap & VEQ_CAP_BRIGHTNESS)
- *value = info.brightness/10;
+ *args->valueptr = info.brightness/10;
}
- else if (!strcasecmp(data, "contrast"))
+ else if (!strcasecmp(args->name, "contrast"))
{
if (info.cap & VEQ_CAP_CONTRAST)
- *value = info.contrast/10;
+ *args->valueptr = info.contrast/10;
}
- else if (!strcasecmp(data, "saturation"))
+ else if (!strcasecmp(args->name, "saturation"))
{
if (info.cap & VEQ_CAP_SATURATION)
- *value = info.saturation/10;
+ *args->valueptr = info.saturation/10;
}
- else if (!strcasecmp(data, "hue"))
+ else if (!strcasecmp(args->name, "hue"))
{
if (info.cap & VEQ_CAP_HUE)
- *value = info.hue/10;
+ *args->valueptr = info.hue/10;
}
return VO_TRUE;
@@ -677,7 +669,7 @@ uint32_t vidix_control(uint32_t request, void *data, ...)
// return server_control(request,data); //VO_NOTIMPL;
}
-int vidix_preinit(const char *drvname,vo_functions_t *server)
+int vidix_preinit(const char *drvname, struct vo_old_functions *server)
{
int err;
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
diff --git a/libvo/vosub_vidix.h b/libvo/vosub_vidix.h
index 128409e95a..7b05607de6 100644
--- a/libvo/vosub_vidix.h
+++ b/libvo/vosub_vidix.h
@@ -27,7 +27,7 @@
#include "video_out.h"
/* drvname can be NULL */
-int vidix_preinit(const char *drvname,vo_functions_t *server);
+int vidix_preinit(const char *drvname, struct vo_old_functions *server);
int vidix_init(unsigned src_width,unsigned src_height,
unsigned dest_x,unsigned dest_y,unsigned dst_width,
unsigned dst_height,unsigned format,unsigned dest_bpp,
@@ -35,7 +35,7 @@ int vidix_init(unsigned src_width,unsigned src_height,
int vidix_start(void);
int vidix_stop(void);
void vidix_term( void );
-uint32_t vidix_control(uint32_t request, void *data, ...);
+uint32_t vidix_control(uint32_t request, void *data);
uint32_t vidix_query_fourcc(uint32_t fourcc);
#include "vidix/vidix.h"
diff --git a/libvo/w32_common.c b/libvo/w32_common.c
index e482536ab2..a23ec8ea42 100644
--- a/libvo/w32_common.c
+++ b/libvo/w32_common.c
@@ -21,6 +21,8 @@
#include <windows.h>
#include <windowsx.h>
+// To get "#define vo_ontop global_vo->opts->vo_ontop" etc
+#include "old_vo_defines.h"
#include "osdep/keycodes.h"
#include "input/input.h"
#include "input/mouse.h"
@@ -39,6 +41,7 @@ extern int enable_mouse_movements;
static const char classname[] = "MPlayer - Media player for Win32";
int vo_vm = 0;
+static int depthonscreen;
// last non-fullscreen extends
static int prev_width;
static int prev_height;
@@ -116,7 +119,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
xborder = (r.right - r.left) - wpos->cx;
yborder = (r.bottom - r.top) - wpos->cy;
wpos->cx -= xborder; wpos->cy -= yborder;
- aspect_fit(&wpos->cx, &wpos->cy, wpos->cx, wpos->cy);
+ aspect_fit(global_vo, &wpos->cx, &wpos->cy, wpos->cx, wpos->cy);
wpos->cx += xborder; wpos->cy += yborder;
}
return 0;
@@ -163,7 +166,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
char cmd_str[40];
snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i",
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
- mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
+ mp_input_queue_cmd(global_vo->input_ctx, mp_input_parse_cmd(cmd_str));
}
break;
case WM_MOUSEWHEEL:
@@ -283,7 +286,7 @@ static void updateScreenProperties(void) {
vo_screenwidth = dm.dmPelsWidth;
vo_screenheight = dm.dmPelsHeight;
- vo_depthonscreen = dm.dmBitsPerPel;
+ depthonscreen = dm.dmBitsPerPel;
w32_update_xinerama_info();
}
@@ -293,7 +296,7 @@ static void changeMode(void) {
dm.dmDriverExtra = 0;
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
- dm.dmBitsPerPel = vo_depthonscreen;
+ dm.dmBitsPerPel = depthonscreen;
dm.dmPelsWidth = vo_screenwidth;
dm.dmPelsHeight = vo_screenheight;
@@ -303,7 +306,7 @@ static void changeMode(void) {
int i;
for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) {
int score = (dm.dmPelsWidth - o_dwidth) * (dm.dmPelsHeight - o_dheight);
- if (dm.dmBitsPerPel != vo_depthonscreen) continue;
+ if (dm.dmBitsPerPel != depthonscreen) continue;
if (dm.dmPelsWidth < o_dwidth) continue;
if (dm.dmPelsHeight < o_dheight) continue;
@@ -393,7 +396,7 @@ static int createRenderingContext(void) {
SetPixelFormat(vo_hdc, pf, &pfd);
- mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen);
+ mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, depthonscreen);
ReleaseDC(vo_window, vo_hdc);
return 1;
@@ -563,7 +566,7 @@ void vo_w32_uninit(void) {
mp_msg(MSGT_VO, MSGL_V, "vo: win32: uninit\n");
resetMode();
ShowCursor(1);
- vo_depthonscreen = 0;
+ depthonscreen = 0;
DestroyWindow(vo_window);
vo_window = 0;
UnregisterClass(classname, 0);
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 16a97d578c..b70c0b8dd6 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -23,10 +23,12 @@
#include <limits.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "mp_fifo.h"
#include "libavutil/common.h"
#include "x11_common.h"
+#include "talloc.h"
#ifdef X11_FULLSCREEN
@@ -87,56 +89,26 @@
extern int enable_mouse_movements;
int fs_layer = WIN_LAYER_ABOVE_DOCK;
-static int orig_layer = 0;
-static int old_gravity = NorthWestGravity;
int stop_xscreensaver = 0;
static int dpms_disabled = 0;
char *mDisplayName = NULL;
-Display *mDisplay = NULL;
-Window mRootWin;
-int mScreen;
-int mLocalDisplay;
-
-/* output window id */
-int vo_mouse_autohide = 0;
-int vo_wm_type = 0;
-int vo_fs_type = 0; // needs to be accessible for GUI X11 code
-static int vo_fs_flip = 0;
+
char **vo_fstype_list;
/* 1 means that the WM is metacity (broken as hell) */
int metacity_hack = 0;
-static Atom XA_NET_SUPPORTED;
-static Atom XA_NET_WM_STATE;
-static Atom XA_NET_WM_STATE_FULLSCREEN;
-static Atom XA_NET_WM_STATE_ABOVE;
-static Atom XA_NET_WM_STATE_STAYS_ON_TOP;
-static Atom XA_NET_WM_STATE_BELOW;
-static Atom XA_NET_WM_PID;
-static Atom XA_WIN_PROTOCOLS;
-static Atom XA_WIN_LAYER;
-static Atom XA_WIN_HINTS;
-static Atom XAWM_PROTOCOLS;
-static Atom XAWM_DELETE_WINDOW;
-
-#define XA_INIT(x) XA##x = XInternAtom(mDisplay, #x, False)
-
-static int vo_old_x = 0;
-static int vo_old_y = 0;
-static int vo_old_width = 0;
-static int vo_old_height = 0;
-
#ifdef CONFIG_XF86VM
XF86VidModeModeInfo **vidmodes = NULL;
XF86VidModeModeLine modeline;
#endif
static int vo_x11_get_fs_type(int supported);
-
+static void saver_off(Display *);
+static void saver_on(Display *);
/*
* Sends the EWMH fullscreen state event.
@@ -145,12 +117,12 @@ static int vo_x11_get_fs_type(int supported);
* _NET_WM_STATE_ADD -- add state
* _NET_WM_STATE_TOGGLE -- toggle
*/
-void vo_x11_ewmh_fullscreen(int action)
+void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action)
{
assert(action == _NET_WM_STATE_REMOVE ||
action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE);
- if (vo_fs_type & vo_wm_FULLSCREEN)
+ if (x11->fs_type & vo_wm_FULLSCREEN)
{
XEvent xev;
@@ -158,17 +130,17 @@ void vo_x11_ewmh_fullscreen(int action)
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
- xev.xclient.message_type = XA_NET_WM_STATE;
- xev.xclient.window = vo_window;
+ xev.xclient.message_type = x11->XA_NET_WM_STATE;
+ xev.xclient.window = x11->window;
xev.xclient.format = 32;
xev.xclient.data.l[0] = action;
- xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
+ xev.xclient.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
/* finally send that damn thing */
- if (!XSendEvent(mDisplay, DefaultRootWindow(mDisplay), False,
+ if (!XSendEvent(x11->display, DefaultRootWindow(x11->display), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev))
{
@@ -177,13 +149,13 @@ void vo_x11_ewmh_fullscreen(int action)
}
}
-void vo_hidecursor(Display * disp, Window win)
+static void vo_hidecursor(Display * disp, Window win)
{
Cursor no_ptr;
Pixmap bm_no;
XColor black, dummy;
Colormap colormap;
- static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ const char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if (WinID == 0)
return; // do not hide if playing on the root window
@@ -202,7 +174,7 @@ void vo_hidecursor(Display * disp, Window win)
XFreeColors(disp,colormap,&black.pixel,1,0);
}
-void vo_showcursor(Display * disp, Window win)
+static void vo_showcursor(Display * disp, Window win)
{
if (WinID == 0)
return;
@@ -278,9 +250,9 @@ static void fstype_dump(int fstype)
"[x11] Current fstype setting doesn't honour any X atoms\n");
}
-static int net_wm_support_state_test(Atom atom)
+static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom)
{
-#define NET_WM_STATE_TEST(x) { if (atom == XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } }
+#define NET_WM_STATE_TEST(x) { if (atom == x11->XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } }
NET_WM_STATE_TEST(FULLSCREEN);
NET_WM_STATE_TEST(ABOVE);
@@ -289,20 +261,22 @@ static int net_wm_support_state_test(Atom atom)
return 0;
}
-static int x11_get_property(Atom type, Atom ** args, unsigned long *nitems)
+static int x11_get_property(struct vo_x11_state *x11, Atom type, Atom ** args,
+ unsigned long *nitems)
{
int format;
unsigned long bytesafter;
return Success ==
- XGetWindowProperty(mDisplay, mRootWin, type, 0, 16384, False,
+ XGetWindowProperty(x11->display, x11->rootwin, type, 0, 16384, False,
AnyPropertyType, &type, &format, nitems,
&bytesafter, (unsigned char **) args)
&& *nitems > 0;
}
-static int vo_wm_detect(void)
+static int vo_wm_detect(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
int i;
int wm = 0;
unsigned long nitems;
@@ -312,12 +286,12 @@ static int vo_wm_detect(void)
return 0;
// -- supports layers
- if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems))
+ if (x11_get_property(x11, x11->XA_WIN_PROTOCOLS, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n");
for (i = 0; i < nitems; i++)
{
- if (args[i] == XA_WIN_LAYER)
+ if (args[i] == x11->XA_WIN_LAYER)
{
wm |= vo_wm_LAYER;
metacity_hack |= 1;
@@ -337,11 +311,11 @@ static int vo_wm_detect(void)
}
}
// --- netwm
- if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems))
+ if (x11_get_property(x11, x11->XA_NET_SUPPORTED, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n");
for (i = 0; i < nitems; i++)
- wm |= net_wm_support_state_test(args[i]);
+ wm |= net_wm_support_state_test(vo->x11, args[i]);
XFree(args);
}
@@ -350,7 +324,8 @@ static int vo_wm_detect(void)
return wm;
}
-static void init_atoms(void)
+#define XA_INIT(x) x11->XA##x = XInternAtom(x11->display, #x, False)
+static void init_atoms(struct vo_x11_state *x11)
{
XA_INIT(_NET_SUPPORTED);
XA_INIT(_NET_WM_STATE);
@@ -366,21 +341,22 @@ static void init_atoms(void)
XA_INIT(WM_DELETE_WINDOW);
}
-void update_xinerama_info(void) {
+void update_xinerama_info(struct vo *vo) {
+ struct MPOpts *opts = vo->opts;
int screen = xinerama_screen;
xinerama_x = xinerama_y = 0;
#ifdef CONFIG_XINERAMA
- if (screen >= -1 && XineramaIsActive(mDisplay))
+ if (screen >= -1 && XineramaIsActive(vo->x11->display))
{
XineramaScreenInfo *screens;
int num_screens;
- screens = XineramaQueryScreens(mDisplay, &num_screens);
+ screens = XineramaQueryScreens(vo->x11->display, &num_screens);
if (screen >= num_screens)
screen = num_screens - 1;
if (screen == -1) {
- int x = vo_dx + vo_dwidth / 2;
- int y = vo_dy + vo_dheight / 2;
+ int x = vo->dx + vo->dwidth / 2;
+ int y = vo->dy + vo->dheight / 2;
for (screen = num_screens - 1; screen > 0; screen--) {
int left = screens[screen].x_org;
int right = left + screens[screen].width;
@@ -392,19 +368,21 @@ void update_xinerama_info(void) {
}
if (screen < 0)
screen = 0;
- vo_screenwidth = screens[screen].width;
- vo_screenheight = screens[screen].height;
+ opts->vo_screenwidth = screens[screen].width;
+ opts->vo_screenheight = screens[screen].height;
xinerama_x = screens[screen].x_org;
xinerama_y = screens[screen].y_org;
XFree(screens);
}
#endif
- aspect_save_screenres(vo_screenwidth, vo_screenheight);
+ aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight);
}
-int vo_init(void)
+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;
@@ -420,9 +398,9 @@ int vo_init(void)
if (vo_rootwin)
WinID = 0; // use root window
- if (vo_depthonscreen)
+ if (x11->depthonscreen)
{
- saver_off(mDisplay);
+ saver_off(x11->display);
return 1; // already called
}
@@ -438,52 +416,52 @@ int vo_init(void)
mp_msg(MSGT_VO, MSGL_V, "X11 opening display: %s\n", dispName);
- mDisplay = XOpenDisplay(dispName);
- if (!mDisplay)
+ x11->display = XOpenDisplay(dispName);
+ if (!x11->display)
{
mp_msg(MSGT_VO, MSGL_ERR,
"vo: couldn't open the X11 display (%s)!\n", dispName);
return 0;
}
- mScreen = DefaultScreen(mDisplay); // screen ID
- mRootWin = RootWindow(mDisplay, mScreen); // root window ID
+ x11->screen = DefaultScreen(x11->display); // screen ID
+ x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID
- init_atoms();
+ init_atoms(vo->x11);
#ifdef CONFIG_XF86VM
{
int clock;
- XF86VidModeGetModeLine(mDisplay, mScreen, &clock, &modeline);
- if (!vo_screenwidth)
- vo_screenwidth = modeline.hdisplay;
- if (!vo_screenheight)
- vo_screenheight = modeline.vdisplay;
+ XF86VidModeGetModeLine(x11->display, x11->screen, &clock, &modeline);
+ if (!opts->vo_screenwidth)
+ opts->vo_screenwidth = modeline.hdisplay;
+ if (!opts->vo_screenheight)
+ opts->vo_screenheight = modeline.vdisplay;
}
#endif
{
- if (!vo_screenwidth)
- vo_screenwidth = DisplayWidth(mDisplay, mScreen);
- if (!vo_screenheight)
- vo_screenheight = DisplayHeight(mDisplay, mScreen);
+ if (!opts->vo_screenwidth)
+ opts->vo_screenwidth = DisplayWidth(x11->display, x11->screen);
+ if (!opts->vo_screenheight)
+ opts->vo_screenheight = DisplayHeight(x11->display, x11->screen);
}
// get color depth (from root window, or the best visual):
- XGetWindowAttributes(mDisplay, mRootWin, &attribs);
+ XGetWindowAttributes(x11->display, x11->rootwin, &attribs);
depth = attribs.depth;
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
{
Visual *visual;
- depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual);
+ depth = vo_find_depth_from_visuals(x11->display, x11->screen, &visual);
if (depth != -1)
- mXImage = XCreateImage(mDisplay, visual, depth, ZPixmap,
+ mXImage = XCreateImage(x11->display, visual, depth, ZPixmap,
0, NULL, 1, 1, 8, 1);
} else
mXImage =
- XGetImage(mDisplay, mRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
+ XGetImage(x11->display, x11->rootwin, 0, 0, 1, 1, AllPlanes, ZPixmap);
- vo_depthonscreen = depth; // display depth on screen
+ x11->depthonscreen = depth; // display depth on screen
// get bits/pixel from XImage structure:
if (mXImage == NULL)
@@ -493,15 +471,15 @@ int vo_init(void)
{
/*
* for the depth==24 case, the XImage structures might use
- * 24 or 32 bits of data per pixel. The global variable
- * vo_depthonscreen stores the amount of data per pixel in the
+ * 24 or 32 bits of data per pixel. The x11->depthonscreen
+ * field stores the amount of data per pixel in the
* XImage structure!
*
* Maybe we should rename vo_depthonscreen to (or add) vo_bpp?
*/
bpp = mXImage->bits_per_pixel;
- if ((vo_depthonscreen + 7) / 8 != (bpp + 7) / 8)
- vo_depthonscreen = bpp; // by A'rpi
+ if ((x11->depthonscreen + 7) / 8 != (bpp + 7) / 8)
+ x11->depthonscreen = bpp; // by A'rpi
mask =
mXImage->red_mask | mXImage->green_mask | mXImage->blue_mask;
mp_msg(MSGT_VO, MSGL_V,
@@ -509,12 +487,12 @@ int vo_init(void)
mXImage->red_mask, mXImage->green_mask, mXImage->blue_mask);
XDestroyImage(mXImage);
}
- if (((vo_depthonscreen + 7) / 8) == 2)
+ if (((x11->depthonscreen + 7) / 8) == 2)
{
if (mask == 0x7FFF)
- vo_depthonscreen = 15;
+ x11->depthonscreen = 15;
else if (mask == 0xFFFF)
- vo_depthonscreen = 16;
+ x11->depthonscreen = 16;
}
// XCloseDisplay( mDisplay );
/* slightly improved local display detection AST */
@@ -523,27 +501,27 @@ int vo_init(void)
else if (strncmp(dispName, "localhost:", 10) == 0)
dispName += 9;
if (*dispName == ':' && atoi(dispName + 1) < 10)
- mLocalDisplay = 1;
+ x11->display_is_local = 1;
else
- mLocalDisplay = 0;
+ x11->display_is_local = 0;
mp_msg(MSGT_VO, MSGL_V,
"vo: X11 running at %dx%d with depth %d and %d bpp (\"%s\" => %s display)\n",
- vo_screenwidth, vo_screenheight, depth, vo_depthonscreen,
- dispName, mLocalDisplay ? "local" : "remote");
+ opts->vo_screenwidth, opts->vo_screenheight, depth, x11->depthonscreen,
+ dispName, x11->display_is_local ? "local" : "remote");
- vo_wm_type = vo_wm_detect();
+ x11->wm_type = vo_wm_detect(vo);
- vo_fs_type = vo_x11_get_fs_type(vo_wm_type);
+ x11->fs_type = vo_x11_get_fs_type(x11->wm_type);
- fstype_dump(vo_fs_type);
+ fstype_dump(x11->fs_type);
- saver_off(mDisplay);
+ saver_off(x11->display);
return 1;
}
-void vo_uninit(void)
+void vo_uninit(struct vo_x11_state *x11)
{
- if (!mDisplay)
+ if (!x11->display)
{
mp_msg(MSGT_VO, MSGL_V,
"vo: x11 uninit called but X11 not initialized..\n");
@@ -552,9 +530,10 @@ void vo_uninit(void)
// if( !vo_depthonscreen ) return;
mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
XSetErrorHandler(NULL);
- XCloseDisplay(mDisplay);
- vo_depthonscreen = 0;
- mDisplay = NULL;
+ XCloseDisplay(x11->display);
+ x11->depthonscreen = 0;
+ x11->display = NULL;
+ talloc_free(x11);
}
#include "osdep/keycodes.h"
@@ -569,11 +548,12 @@ static const struct keymap keysym_map[] = {
{0, 0}
};
-static void vo_x11_putkey_ext(int keysym)
+static void vo_x11_putkey_ext(struct vo *vo, int keysym)
{
+ struct mp_fifo *f = vo->key_fifo;
int mpkey = lookup_keymap_table(keysym_map, keysym);
if (mpkey)
- mplayer_put_key(mpkey);
+ mplayer_put_key(f, mpkey);
}
#endif
@@ -612,7 +592,7 @@ static const struct keymap keymap[] = {
{0, 0}
};
-void vo_x11_putkey(int key)
+void vo_x11_putkey(struct vo *vo, int key)
{
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
@@ -626,7 +606,7 @@ void vo_x11_putkey(int key)
mpkey = lookup_keymap_table(keymap, key);
if (mpkey)
- mplayer_put_key(mpkey);
+ mplayer_put_key(vo->key_fifo, mpkey);
}
@@ -672,12 +652,9 @@ typedef struct
static MotifWmHints vo_MotifWmHints;
static Atom vo_MotifHints = None;
-void vo_x11_decoration(Display * vo_Display, Window w, int d)
+void vo_x11_decoration(struct vo *vo, int d)
{
- static unsigned int olddecor = MWM_DECOR_ALL;
- static unsigned int oldfuncs =
- MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
- MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE;
+ struct vo_x11_state *x11 = vo->x11;
Atom mtype;
int mformat;
unsigned long mn, mb;
@@ -687,26 +664,27 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
if (vo_fsmode & 8)
{
- XSetTransientForHint(vo_Display, w,
- RootWindow(vo_Display, mScreen));
+ XSetTransientForHint(x11->display, x11->window,
+ RootWindow(x11->display, x11->screen));
}
- vo_MotifHints = XInternAtom(vo_Display, "_MOTIF_WM_HINTS", 0);
+ vo_MotifHints = XInternAtom(x11->display, "_MOTIF_WM_HINTS", 0);
if (vo_MotifHints != None)
{
if (!d)
{
MotifWmHints *mhints = NULL;
- XGetWindowProperty(vo_Display, w, vo_MotifHints, 0, 20, False,
+ XGetWindowProperty(x11->display, x11->window,
+ vo_MotifHints, 0, 20, False,
vo_MotifHints, &mtype, &mformat, &mn,
&mb, (unsigned char **) &mhints);
if (mhints)
{
if (mhints->flags & MWM_HINTS_DECORATIONS)
- olddecor = mhints->decorations;
+ x11->olddecor = mhints->decorations;
if (mhints->flags & MWM_HINTS_FUNCTIONS)
- oldfuncs = mhints->functions;
+ x11->oldfuncs = mhints->functions;
XFree(mhints);
}
}
@@ -716,8 +694,8 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
if (d)
{
- vo_MotifWmHints.functions = oldfuncs;
- d = olddecor;
+ vo_MotifWmHints.functions = x11->oldfuncs;
+ d = x11->olddecor;
}
#if 0
vo_MotifWmHints.decorations =
@@ -726,110 +704,99 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
vo_MotifWmHints.decorations =
d | ((vo_fsmode & 2) ? MWM_DECOR_MENU : 0);
#endif
- XChangeProperty(vo_Display, w, vo_MotifHints, vo_MotifHints, 32,
+ XChangeProperty(x11->display, x11->window, vo_MotifHints,
+ vo_MotifHints, 32,
PropModeReplace,
(unsigned char *) &vo_MotifWmHints,
(vo_fsmode & 4) ? 4 : 5);
}
}
-void vo_x11_classhint(Display * display, Window window, char *name)
+void vo_x11_classhint(struct vo *vo, Window window, char *name)
{
+ struct vo_x11_state *x11 = vo->x11;
XClassHint wmClass;
pid_t pid = getpid();
wmClass.res_name = name;
wmClass.res_class = "MPlayer";
- XSetClassHint(display, window, &wmClass);
- XChangeProperty(display, window, XA_NET_WM_PID, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *) &pid, 1);
-}
-
-Window vo_window = None;
-GC vo_gc = NULL;
-GC f_gc = NULL;
-XSizeHints vo_hint;
-
-#ifdef CONFIG_GUI
-void vo_setwindow(Window w, GC g)
-{
- vo_window = w;
- vo_gc = g;
+ XSetClassHint(x11->display, window, &wmClass);
+ XChangeProperty(x11->display, window, x11->XA_NET_WM_PID, XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) &pid, 1);
}
-#endif
-void vo_x11_uninit(void)
+void vo_x11_uninit(struct vo *vo)
{
- saver_on(mDisplay);
- if (vo_window != None)
- vo_showcursor(mDisplay, vo_window);
+ struct vo_x11_state *x11 = vo->x11;
+ saver_on(x11->display);
+ if (x11->window != None)
+ vo_showcursor(x11->display, x11->window);
- if (f_gc)
+ if (x11->f_gc)
{
- XFreeGC(mDisplay, f_gc);
- f_gc = NULL;
+ XFreeGC(vo->x11->display, x11->f_gc);
+ x11->f_gc = NULL;
}
#ifdef CONFIG_GUI
/* destroy window only if it's not controlled by the GUI */
if (!use_gui)
#endif
{
- if (vo_gc)
+ if (x11->vo_gc)
{
- XSetBackground(mDisplay, vo_gc, 0);
- XFreeGC(mDisplay, vo_gc);
- vo_gc = NULL;
+ XSetBackground(vo->x11->display, x11->vo_gc, 0);
+ XFreeGC(vo->x11->display, x11->vo_gc);
+ x11->vo_gc = NULL;
}
- if (vo_window != None)
+ if (x11->window != None)
{
- XClearWindow(mDisplay, vo_window);
+ XClearWindow(x11->display, x11->window);
if (WinID < 0)
{
XEvent xev;
- XUnmapWindow(mDisplay, vo_window);
- XDestroyWindow(mDisplay, vo_window);
+ XUnmapWindow(x11->display, x11->window);
+ XDestroyWindow(x11->display, x11->window);
do
{
- XNextEvent(mDisplay, &xev);
+ XNextEvent(x11->display, &xev);
}
while (xev.type != DestroyNotify
- || xev.xdestroywindow.event != vo_window);
+ || xev.xdestroywindow.event != x11->window);
}
- vo_window = None;
+ x11->window = None;
}
vo_fs = 0;
- vo_old_width = vo_old_height = 0;
+ x11->vo_old_width = x11->vo_old_height = 0;
}
}
-static unsigned int mouse_timer;
-static int mouse_waiting_hide;
-
-int vo_x11_check_events(Display * mydisplay)
+int vo_x11_check_events(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ Display *display = vo->x11->display;
int ret = 0;
XEvent Event;
char buf[100];
KeySym keySym;
- static XComposeStatus stat;
// unsigned long vo_KeyTable[512];
- if ((vo_mouse_autohide) && mouse_waiting_hide &&
- (GetTimerMS() - mouse_timer >= 1000)) {
- vo_hidecursor(mydisplay, vo_window);
- mouse_waiting_hide = 0;
+ if ((x11->vo_mouse_autohide) && x11->mouse_waiting_hide &&
+ (GetTimerMS() - x11->mouse_timer >= 1000)) {
+ vo_hidecursor(display, x11->window);
+ x11->mouse_waiting_hide = 0;
}
- while (XPending(mydisplay))
+ while (XPending(display))
{
- XNextEvent(mydisplay, &Event);
+ XNextEvent(display, &Event);
#ifdef CONFIG_GUI
if (use_gui)
{
guiGetEvent(0, (char *) &Event);
- if (vo_window != Event.xany.window)
+ if (x11->window != Event.xany.window)
continue;
}
#endif
@@ -840,14 +807,14 @@ int vo_x11_check_events(Display * mydisplay)
ret |= VO_EVENT_EXPOSE;
break;
case ConfigureNotify:
-// if (!vo_fs && (Event.xconfigure.width == vo_screenwidth || Event.xconfigure.height == vo_screenheight)) break;
-// if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break;
- if (vo_window == None)
+// if (!vo_fs && (Event.xconfigure.width == opts->vo_screenwidth || Event.xconfigure.height == opts->vo_screenheight)) break;
+// if (vo_fs && Event.xconfigure.width != opts->vo_screenwidth && Event.xconfigure.height != opts->vo_screenheight) break;
+ if (x11->window == None)
break;
{
- int old_w = vo_dwidth, old_h = vo_dheight;
- vo_x11_update_geometry();
- if (vo_dwidth != old_w || vo_dheight != old_h)
+ int old_w = vo->dwidth, old_h = vo->dheight;
+ vo_x11_update_geometry(vo);
+ if (vo->dwidth != old_w || vo->dheight != old_h)
ret |= VO_EVENT_RESIZE;
}
break;
@@ -860,14 +827,14 @@ int vo_x11_check_events(Display * mydisplay)
#endif
XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
- &stat);
+ &x11->compose_status);
#ifdef XF86XK_AudioPause
- vo_x11_putkey_ext(keySym);
+ vo_x11_putkey_ext(vo, keySym);
#endif
key =
((keySym & 0xff00) !=
0 ? ((keySym & 0x00ff) + 256) : (keySym));
- vo_x11_putkey(key);
+ vo_x11_putkey(vo, key);
ret |= VO_EVENT_KEYPRESS;
}
break;
@@ -876,22 +843,23 @@ int vo_x11_check_events(Display * mydisplay)
{
char cmd_str[40];
sprintf(cmd_str,"set_mouse_pos %i %i",Event.xmotion.x, Event.xmotion.y);
- mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
+ mp_input_queue_cmd(vo->input_ctx,
+ mp_input_parse_cmd(cmd_str));
}
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
break;
case ButtonPress:
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
#ifdef CONFIG_GUI
// Ignore mouse button 1-3 under GUI.
@@ -899,15 +867,16 @@ int vo_x11_check_events(Display * mydisplay)
&& (Event.xbutton.button <= 3))
break;
#endif
- mplayer_put_key((MOUSE_BTN0 + Event.xbutton.button -
- 1) | MP_KEY_DOWN);
+ mplayer_put_key(vo->key_fifo,
+ (MOUSE_BTN0 + Event.xbutton.button - 1)
+ | MP_KEY_DOWN);
break;
case ButtonRelease:
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
#ifdef CONFIG_GUI
// Ignore mouse button 1-3 under GUI.
@@ -915,12 +884,13 @@ int vo_x11_check_events(Display * mydisplay)
&& (Event.xbutton.button <= 3))
break;
#endif
- mplayer_put_key(MOUSE_BTN0 + Event.xbutton.button - 1);
+ mplayer_put_key(vo->key_fifo,
+ MOUSE_BTN0 + Event.xbutton.button - 1);
break;
case PropertyNotify:
{
char *name =
- XGetAtomName(mydisplay, Event.xproperty.atom);
+ XGetAtomName(display, Event.xproperty.atom);
if (!name)
break;
@@ -931,14 +901,14 @@ int vo_x11_check_events(Display * mydisplay)
}
break;
case MapNotify:
- vo_hint.win_gravity = old_gravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
- vo_fs_flip = 0;
+ x11->vo_hint.win_gravity = x11->old_gravity;
+ XSetWMNormalHints(display, x11->window, &x11->vo_hint);
+ x11->fs_flip = 0;
break;
case ClientMessage:
- if (Event.xclient.message_type == XAWM_PROTOCOLS &&
- Event.xclient.data.l[0] == XAWM_DELETE_WINDOW)
- mplayer_put_key(KEY_CLOSE_WIN);
+ if (Event.xclient.message_type == x11->XAWM_PROTOCOLS &&
+ Event.xclient.data.l[0] == x11->XAWM_DELETE_WINDOW)
+ mplayer_put_key(vo->key_fifo, KEY_CLOSE_WIN);
break;
}
}
@@ -948,69 +918,72 @@ int vo_x11_check_events(Display * mydisplay)
/**
* \brief sets the size and position of the non-fullscreen window.
*/
-void vo_x11_nofs_sizepos(int x, int y, int width, int height)
+static void vo_x11_nofs_sizepos(struct vo *vo, int x, int y,
+ int width, int height)
{
- vo_x11_sizehint(x, y, width, height, 0);
+ struct vo_x11_state *x11 = vo->x11;
+ vo_x11_sizehint(vo, x, y, width, height, 0);
if (vo_fs) {
- vo_old_x = x;
- vo_old_y = y;
- vo_old_width = width;
- vo_old_height = height;
+ x11->vo_old_x = x;
+ x11->vo_old_y = y;
+ x11->vo_old_width = width;
+ x11->vo_old_height = height;
}
else
{
- vo_dwidth = width;
- vo_dheight = height;
- XMoveResizeWindow(mDisplay, vo_window, x, y, width, height);
+ vo->dwidth = width;
+ vo->dheight = height;
+ XMoveResizeWindow(vo->x11->display, vo->x11->window, x, y, width, height);
}
}
-void vo_x11_sizehint(int x, int y, int width, int height, int max)
+void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, int max)
{
- vo_hint.flags = 0;
+ struct vo_x11_state *x11 = vo->x11;
+ x11->vo_hint.flags = 0;
if (vo_keepaspect)
{
- vo_hint.flags |= PAspect;
- vo_hint.min_aspect.x = width;
- vo_hint.min_aspect.y = height;
- vo_hint.max_aspect.x = width;
- vo_hint.max_aspect.y = height;
+ x11->vo_hint.flags |= PAspect;
+ x11->vo_hint.min_aspect.x = width;
+ x11->vo_hint.min_aspect.y = height;
+ x11->vo_hint.max_aspect.x = width;
+ x11->vo_hint.max_aspect.y = height;
}
- vo_hint.flags |= PPosition | PSize;
- vo_hint.x = x;
- vo_hint.y = y;
- vo_hint.width = width;
- vo_hint.height = height;
+ x11->vo_hint.flags |= PPosition | PSize;
+ x11->vo_hint.x = x;
+ x11->vo_hint.y = y;
+ x11->vo_hint.width = width;
+ x11->vo_hint.height = height;
if (max)
{
- vo_hint.flags |= PMaxSize;
- vo_hint.max_width = width;
- vo_hint.max_height = height;
+ x11->vo_hint.flags |= PMaxSize;
+ x11->vo_hint.max_width = width;
+ x11->vo_hint.max_height = height;
} else
{
- vo_hint.max_width = 0;
- vo_hint.max_height = 0;
+ x11->vo_hint.max_width = 0;
+ x11->vo_hint.max_height = 0;
}
// Set minimum height/width to 4 to avoid off-by-one errors
// and because mga_vid requires a minimal size of 4 pixels.
- vo_hint.flags |= PMinSize;
- vo_hint.min_width = vo_hint.min_height = 4;
+ x11->vo_hint.flags |= PMinSize;
+ x11->vo_hint.min_width = x11->vo_hint.min_height = 4;
// Set the base size. A window manager might display the window
// size to the user relative to this.
// Setting these to width/height might be nice, but e.g. fluxbox can't handle it.
- vo_hint.flags |= PBaseSize;
- vo_hint.base_width = 0 /*width*/;
- vo_hint.base_height = 0 /*height*/;
+ x11->vo_hint.flags |= PBaseSize;
+ x11->vo_hint.base_width = 0 /*width*/;
+ x11->vo_hint.base_height = 0 /*height*/;
- vo_hint.flags |= PWinGravity;
- vo_hint.win_gravity = StaticGravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
+ x11->vo_hint.flags |= PWinGravity;
+ x11->vo_hint.win_gravity = StaticGravity;
+ XSetWMNormalHints(x11->display, x11->window, &x11->vo_hint);
}
-static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
+static int vo_x11_get_gnome_layer(struct vo_x11_state *x11, Window win)
{
Atom type;
int format;
@@ -1018,7 +991,7 @@ static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
unsigned long bytesafter;
unsigned short *args = NULL;
- if (XGetWindowProperty(mDisplay, win, XA_WIN_LAYER, 0, 16384,
+ if (XGetWindowProperty(x11->display, win, x11->XA_WIN_LAYER, 0, 16384,
False, AnyPropertyType, &type, &format, &nitems,
&bytesafter,
(unsigned char **) &args) == Success
@@ -1032,7 +1005,7 @@ static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
}
//
-Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
+static Window vo_x11_create_smooth_window(struct vo_x11_state *x11, Window mRoot,
Visual * vis, int x, int y,
unsigned int width, unsigned int height,
int depth, Colormap col_map)
@@ -1052,12 +1025,12 @@ Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
xswa.bit_gravity = StaticGravity;
ret_win =
- XCreateWindow(mDisplay, mRootWin, x, y, width, height, 0, depth,
+ XCreateWindow(x11->display, x11->rootwin, x, y, width, height, 0, depth,
CopyFromParent, vis, xswamask, &xswa);
- XSetWMProtocols(mDisplay, ret_win, &XAWM_DELETE_WINDOW, 1);
- if (!f_gc)
- f_gc = XCreateGC(mDisplay, ret_win, 0, 0);
- XSetForeground(mDisplay, f_gc, 0);
+ XSetWMProtocols(x11->display, ret_win, &x11->XAWM_DELETE_WINDOW, 1);
+ if (!x11->f_gc)
+ x11->f_gc = XCreateGC(x11->display, ret_win, 0, 0);
+ XSetForeground(x11->display, x11->f_gc, 0);
return ret_win;
}
@@ -1078,171 +1051,180 @@ Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
* This also does the grunt-work like setting Window Manager hints etc.
* If vo_window is already set it just moves and resizes it.
*/
-void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
+void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
unsigned int width, unsigned int height, int flags,
Colormap col_map,
const char *classname, const char *title)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
+ Display *mDisplay = vo->x11->display;
XGCValues xgcv;
if (WinID >= 0) {
- vo_window = WinID ? (Window)WinID : mRootWin;
+ x11->window = WinID ? (Window)WinID : x11->rootwin;
if (col_map != CopyFromParent) {
unsigned long xswamask = CWColormap;
XSetWindowAttributes xswa;
xswa.colormap = col_map;
- XUnmapWindow(mDisplay, vo_window);
- XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
- XMapWindow(mDisplay, vo_window);
+ XUnmapWindow(mDisplay, x11->window);
+ XChangeWindowAttributes(mDisplay, x11->window, xswamask, &xswa);
+ XMapWindow(mDisplay, x11->window);
}
- if (WinID) vo_x11_update_geometry();
- vo_x11_selectinput_witherr(mDisplay, vo_window,
+ if (WinID) vo_x11_update_geometry(vo);
+ vo_x11_selectinput_witherr(mDisplay, x11->window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
goto final;
}
- if (vo_window == None) {
+ if (x11->window == None) {
XSizeHints hint;
XEvent xev;
vo_fs = 0;
- vo_dwidth = width;
- vo_dheight = height;
- vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vis->visual,
+ vo->dwidth = width;
+ vo->dheight = height;
+ x11->window = vo_x11_create_smooth_window(x11, x11->rootwin, vis->visual,
x, y, width, height, vis->depth, col_map);
- vo_x11_classhint(mDisplay, vo_window, classname);
- XStoreName(mDisplay, vo_window, title);
- vo_hidecursor(mDisplay, vo_window);
- XSelectInput(mDisplay, vo_window, StructureNotifyMask);
+ vo_x11_classhint(vo, x11->window, classname);
+ XStoreName(mDisplay, x11->window, title);
+ vo_hidecursor(mDisplay, x11->window);
+ XSelectInput(mDisplay, x11->window, StructureNotifyMask);
hint.x = x; hint.y = y;
hint.width = width; hint.height = height;
hint.flags = PPosition | PSize;
- XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
- vo_x11_sizehint(x, y, width, height, 0);
- if (!vo_border) vo_x11_decoration(mDisplay, vo_window, 0);
+ XSetStandardProperties(mDisplay, x11->window, title, title, None, NULL, 0, &hint);
+ vo_x11_sizehint(vo, x, y, width, height, 0);
+ if (!vo_border) vo_x11_decoration(vo, 0);
// map window
- XMapWindow(mDisplay, vo_window);
- XClearWindow(mDisplay, vo_window);
+ XMapWindow(mDisplay, x11->window);
+ XClearWindow(mDisplay, x11->window);
// wait for map
do {
XNextEvent(mDisplay, &xev);
- } while (xev.type != MapNotify || xev.xmap.event != vo_window);
- XSelectInput(mDisplay, vo_window, NoEventMask);
+ } while (xev.type != MapNotify || xev.xmap.event != x11->window);
+ XSelectInput(mDisplay, x11->window, NoEventMask);
XSync(mDisplay, False);
- vo_x11_selectinput_witherr(mDisplay, vo_window,
+ vo_x11_selectinput_witherr(mDisplay, x11->window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
}
- if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
- vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height);
+ if (opts->vo_ontop) vo_x11_setlayer(vo, x11->window, opts->vo_ontop);
+ vo_x11_nofs_sizepos(vo, vo->dx, vo->dy, width, height);
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
- vo_x11_fullscreen();
+ vo_x11_fullscreen(vo);
else if (vo_fs) {
// if we are already in fullscreen do not switch back and forth, just
// set the size values right.
- vo_dwidth = vo_screenwidth;
- vo_dheight = vo_screenheight;
+ vo->dwidth = vo->opts->vo_screenwidth;
+ vo->dheight = vo->opts->vo_screenheight;
}
final:
- if (vo_gc != None)
- XFreeGC(mDisplay, vo_gc);
- vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &xgcv);
+ if (x11->vo_gc != None)
+ XFreeGC(mDisplay, x11->vo_gc);
+ x11->vo_gc = XCreateGC(mDisplay, x11->window, GCForeground, &xgcv);
XSync(mDisplay, False);
- vo_mouse_autohide = 1;
+ x11->vo_mouse_autohide = 1;
}
-void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,
+void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
int img_width, int img_height, int use_fs)
{
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ Display *mDisplay = vo->x11->display;
int u_dheight, u_dwidth, left_ov, left_ov2;
- if (!f_gc)
+ if (!x11->f_gc)
return;
- u_dheight = use_fs ? vo_screenheight : vo_dheight;
- u_dwidth = use_fs ? vo_screenwidth : vo_dwidth;
+ u_dheight = use_fs ? opts->vo_screenheight : vo->dheight;
+ u_dwidth = use_fs ? opts->vo_screenwidth : vo->dwidth;
if ((u_dheight <= img_height) && (u_dwidth <= img_width))
return;
left_ov = (u_dheight - img_height) / 2;
left_ov2 = (u_dwidth - img_width) / 2;
- XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, u_dwidth, left_ov);
- XFillRectangle(mDisplay, vo_window, f_gc, 0, u_dheight - left_ov - 1,
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, 0, u_dwidth, left_ov);
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, u_dheight - left_ov - 1,
u_dwidth, left_ov + 1);
if (u_dwidth > img_width)
{
- XFillRectangle(mDisplay, vo_window, f_gc, 0, left_ov, left_ov2,
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, left_ov, left_ov2,
img_height);
- XFillRectangle(mDisplay, vo_window, f_gc, u_dwidth - left_ov2 - 1,
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, u_dwidth - left_ov2 - 1,
left_ov, left_ov2 + 1, img_height);
}
XFlush(mDisplay);
}
-void vo_x11_clearwindow(Display * mDisplay, Window vo_window)
+void vo_x11_clearwindow(struct vo *vo, Window vo_window)
{
- if (!f_gc)
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ if (!x11->f_gc)
return;
- XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, vo_screenwidth,
- vo_screenheight);
+ XFillRectangle(x11->display, vo_window, x11->f_gc, 0, 0,
+ opts->vo_screenwidth, opts->vo_screenheight);
//
- XFlush(mDisplay);
+ XFlush(x11->display);
}
-void vo_x11_setlayer(Display * mDisplay, Window vo_window, int layer)
+void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer)
{
+ struct vo_x11_state *x11 = vo->x11;
if (WinID >= 0)
return;
- if (vo_fs_type & vo_wm_LAYER)
+ if (x11->fs_type & vo_wm_LAYER)
{
XClientMessageEvent xev;
- if (!orig_layer)
- orig_layer = vo_x11_get_gnome_layer(mDisplay, vo_window);
+ if (!x11->orig_layer)
+ x11->orig_layer = vo_x11_get_gnome_layer(x11, vo_window);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
- xev.display = mDisplay;
+ xev.display = x11->display;
xev.window = vo_window;
- xev.message_type = XA_WIN_LAYER;
+ xev.message_type = x11->XA_WIN_LAYER;
xev.format = 32;
- xev.data.l[0] = layer ? fs_layer : orig_layer; // if not fullscreen, stay on default layer
+ xev.data.l[0] = layer ? fs_layer : x11->orig_layer; // if not fullscreen, stay on default layer
xev.data.l[1] = CurrentTime;
mp_msg(MSGT_VO, MSGL_V,
"[x11] Layered style stay on top (layer %ld).\n",
xev.data.l[0]);
- XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask,
+ XSendEvent(x11->display, x11->rootwin, False, SubstructureNotifyMask,
(XEvent *) & xev);
- } else if (vo_fs_type & vo_wm_NETWM)
+ } else if (x11->fs_type & vo_wm_NETWM)
{
XClientMessageEvent xev;
char *state;
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
- xev.message_type = XA_NET_WM_STATE;
- xev.display = mDisplay;
+ xev.message_type = x11->XA_NET_WM_STATE;
+ xev.display = x11->display;
xev.window = vo_window;
xev.format = 32;
xev.data.l[0] = layer;
- if (vo_fs_type & vo_wm_STAYS_ON_TOP)
- xev.data.l[1] = XA_NET_WM_STATE_STAYS_ON_TOP;
- else if (vo_fs_type & vo_wm_ABOVE)
- xev.data.l[1] = XA_NET_WM_STATE_ABOVE;
- else if (vo_fs_type & vo_wm_FULLSCREEN)
- xev.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
- else if (vo_fs_type & vo_wm_BELOW)
+ if (x11->fs_type & vo_wm_STAYS_ON_TOP)
+ xev.data.l[1] = x11->XA_NET_WM_STATE_STAYS_ON_TOP;
+ else if (x11->fs_type & vo_wm_ABOVE)
+ xev.data.l[1] = x11->XA_NET_WM_STATE_ABOVE;
+ else if (x11->fs_type & vo_wm_FULLSCREEN)
+ xev.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN;
+ else if (x11->fs_type & vo_wm_BELOW)
// This is not fallback. We can safely assume that the situation
// where only NETWM_STATE_BELOW is supported doesn't exist.
- xev.data.l[1] = XA_NET_WM_STATE_BELOW;
+ xev.data.l[1] = x11->XA_NET_WM_STATE_BELOW;
- XSendEvent(mDisplay, mRootWin, False, SubstructureRedirectMask,
+ XSendEvent(x11->display, x11->rootwin, False, SubstructureRedirectMask,
(XEvent *) & xev);
- state = XGetAtomName(mDisplay, xev.data.l[1]);
+ state = XGetAtomName(x11->display, xev.data.l[1]);
mp_msg(MSGT_VO, MSGL_V,
"[x11] NET style stay on top (layer %d). Using state %s.\n",
layer, state);
@@ -1323,107 +1305,115 @@ static int vo_x11_get_fs_type(int supported)
}
/**
- * \brief update vo_dx, vo_dy, vo_dwidth and vo_dheight with current values of vo_window
- * \return returns current color depth of vo_window
+ * \brief update vo->dx, vo->dy, vo->dwidth and vo->dheight with current values of vo->x11->window
+ * \return returns current color depth of vo->x11->window
*/
-int vo_x11_update_geometry(void) {
+int vo_x11_update_geometry(struct vo *vo)
+{
+ struct vo_x11_state *x11 = vo->x11;
unsigned depth, w, h;
int dummy_int;
Window dummy_win;
- XGetGeometry(mDisplay, vo_window, &dummy_win, &dummy_int, &dummy_int,
+ XGetGeometry(x11->display, x11->window, &dummy_win, &dummy_int, &dummy_int,
&w, &h, &dummy_int, &depth);
- if (w <= INT_MAX && h <= INT_MAX) { vo_dwidth = w; vo_dheight = h; }
- XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy,
- &dummy_win);
+ if (w <= INT_MAX && h <= INT_MAX) {
+ vo->dwidth = w;
+ vo->dheight = h;
+ }
+ XTranslateCoordinates(x11->display, x11->window, x11->rootwin, 0, 0,
+ &vo->dx, &vo->dy, &dummy_win);
return depth <= INT_MAX ? depth : 0;
}
-void vo_x11_fullscreen(void)
+void vo_x11_fullscreen(struct vo *vo)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
int x, y, w, h;
- if (WinID >= 0 || vo_fs_flip)
+ if (WinID >= 0 || x11->fs_flip)
return;
if (vo_fs)
{
// fs->win
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- x = vo_old_x;
- y = vo_old_y;
- w = vo_old_width;
- h = vo_old_height;
+ x = x11->vo_old_x;
+ y = x11->vo_old_y;
+ w = x11->vo_old_width;
+ h = x11->vo_old_height;
}
- vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
+ vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
vo_fs = VO_FALSE;
} else
{
// win->fs
- vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
+ vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
vo_fs = VO_TRUE;
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- vo_old_x = vo_dx;
- vo_old_y = vo_dy;
- vo_old_width = vo_dwidth;
- vo_old_height = vo_dheight;
+ x11->vo_old_x = vo->dx;
+ x11->vo_old_y = vo->dy;
+ x11->vo_old_width = vo->dwidth;
+ x11->vo_old_height = vo->dheight;
}
- update_xinerama_info();
+ update_xinerama_info(vo);
x = xinerama_x;
y = xinerama_y;
- w = vo_screenwidth;
- h = vo_screenheight;
+ w = opts->vo_screenwidth;
+ h = opts->vo_screenheight;
}
{
long dummy;
- XGetWMNormalHints(mDisplay, vo_window, &vo_hint, &dummy);
- if (!(vo_hint.flags & PWinGravity))
- old_gravity = NorthWestGravity;
+ XGetWMNormalHints(x11->display, x11->window, &x11->vo_hint, &dummy);
+ if (!(x11->vo_hint.flags & PWinGravity))
+ x11->old_gravity = NorthWestGravity;
else
- old_gravity = vo_hint.win_gravity;
+ x11->old_gravity = x11->vo_hint.win_gravity;
}
- if (vo_wm_type == 0 && !(vo_fsmode & 16))
+ if (x11->wm_type == 0 && !(vo_fsmode & 16))
{
- XUnmapWindow(mDisplay, vo_window); // required for MWM
- XWithdrawWindow(mDisplay, vo_window, mScreen);
- vo_fs_flip = 1;
+ XUnmapWindow(x11->display, x11->window); // required for MWM
+ XWithdrawWindow(x11->display, x11->window, x11->screen);
+ x11->fs_flip = 1;
}
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- vo_x11_decoration(mDisplay, vo_window, vo_border && !vo_fs);
- vo_x11_sizehint(x, y, w, h, 0);
- vo_x11_setlayer(mDisplay, vo_window, vo_fs);
+ vo_x11_decoration(vo, vo_border && !vo_fs);
+ vo_x11_sizehint(vo, x, y, w, h, 0);
+ vo_x11_setlayer(vo, x11->window, vo_fs);
- XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
+ XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
}
/* some WMs lose ontop after fullscreen */
- if ((!(vo_fs)) & vo_ontop)
- vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
-
- XMapRaised(mDisplay, vo_window);
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map
- XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
- XRaiseWindow(mDisplay, vo_window);
- XFlush(mDisplay);
+ if ((!(vo_fs)) & opts->vo_ontop)
+ vo_x11_setlayer(vo, x11->window, opts->vo_ontop);
+
+ XMapRaised(x11->display, x11->window);
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map
+ XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
+ XRaiseWindow(x11->display, x11->window);
+ XFlush(x11->display);
}
-void vo_x11_ontop(void)
+void vo_x11_ontop(struct vo *vo)
{
- vo_ontop = (!(vo_ontop));
+ struct MPOpts *opts = vo->opts;
+ opts->vo_ontop = !opts->vo_ontop;
- vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
+ vo_x11_setlayer(vo, vo->x11->window, opts->vo_ontop);
}
-void vo_x11_border(void)
+void vo_x11_border(struct vo *vo)
{
vo_border = !vo_border;
- vo_x11_decoration(mDisplay, vo_window, vo_border && !vo_fs);
+ vo_x11_decoration(vo, vo_border && !vo_fs);
}
/*
@@ -1433,19 +1423,19 @@ void vo_x11_border(void)
static int screensaver_off;
static unsigned int time_last;
-void xscreensaver_heartbeat(void)
+void xscreensaver_heartbeat(struct vo_x11_state *x11)
{
unsigned int time = GetTimerMS();
- if (mDisplay && screensaver_off && (time - time_last) > 30000)
+ if (x11->display && screensaver_off && (time - time_last) > 30000)
{
time_last = time;
- XResetScreenSaver(mDisplay);
+ XResetScreenSaver(x11->display);
}
}
-static int xss_suspend(Bool suspend)
+static int xss_suspend(Display *mDisplay, Bool suspend)
{
#ifndef CONFIG_XSS
return 0;
@@ -1465,13 +1455,13 @@ static int xss_suspend(Bool suspend)
* End of XScreensaver stuff
*/
-void saver_on(Display * mDisplay)
+static void saver_on(Display * mDisplay)
{
if (!screensaver_off)
return;
screensaver_off = 0;
- if (xss_suspend(False))
+ if (xss_suspend(mDisplay, False))
return;
#ifdef CONFIG_XDPMS
if (dpms_disabled)
@@ -1505,14 +1495,14 @@ void saver_on(Display * mDisplay)
#endif
}
-void saver_off(Display * mDisplay)
+static void saver_off(Display * mDisplay)
{
int nothing;
if (screensaver_off)
return;
screensaver_off = 1;
- if (xss_suspend(True))
+ if (xss_suspend(mDisplay, True))
return;
#ifdef CONFIG_XDPMS
if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
@@ -1587,12 +1577,15 @@ void vo_x11_selectinput_witherr(Display * display, Window w,
}
#ifdef CONFIG_XF86VM
-void vo_vm_switch(void)
+void vo_vm_switch(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ Display *mDisplay = x11->display;
int vm_event, vm_error;
int vm_ver, vm_rev;
int i, j, have_vm = 0;
- int X = vo_dwidth, Y = vo_dheight;
+ int X = vo->dwidth, Y = vo->dheight;
int modeline_width, modeline_height;
int modecount;
@@ -1611,7 +1604,7 @@ void vo_vm_switch(void)
if (have_vm)
{
if (vidmodes == NULL)
- XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount,
+ XF86VidModeGetAllModeLines(mDisplay, x11->screen, &modecount,
&vidmodes);
j = 0;
modeline_width = vidmodes[0]->hdisplay;
@@ -1630,26 +1623,28 @@ void vo_vm_switch(void)
mp_msg(MSGT_VO, MSGL_INFO, MSGTR_SelectedVideoMode,
modeline_width, modeline_height, X, Y);
- XF86VidModeLockModeSwitch(mDisplay, mScreen, 0);
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
+ XF86VidModeLockModeSwitch(mDisplay, x11->screen, 0);
+ XF86VidModeSwitchToMode(mDisplay, x11->screen, vidmodes[j]);
+ XF86VidModeSwitchToMode(mDisplay, x11->screen, vidmodes[j]);
// FIXME: all this is more of a hack than proper solution
- X = (vo_screenwidth - modeline_width) / 2;
- Y = (vo_screenheight - modeline_height) / 2;
- XF86VidModeSetViewPort(mDisplay, mScreen, X, Y);
- vo_dx = X;
- vo_dy = Y;
- vo_dwidth = modeline_width;
- vo_dheight = modeline_height;
- aspect_save_screenres(modeline_width, modeline_height);
+ X = (opts->vo_screenwidth - modeline_width) / 2;
+ Y = (opts->vo_screenheight - modeline_height) / 2;
+ XF86VidModeSetViewPort(mDisplay, x11->screen, X, Y);
+ vo->dx = X;
+ vo->dy = Y;
+ vo->dwidth = modeline_width;
+ vo->dheight = modeline_height;
+ aspect_save_screenres(vo, modeline_width, modeline_height);
}
}
-void vo_vm_close(void)
+void vo_vm_close(struct vo *vo)
{
+ Display *dpy = vo->x11->display;
+ struct MPOpts *opts = vo->opts;
#ifdef CONFIG_GUI
- if (vidmodes != NULL && vo_window != None)
+ if (vidmodes != NULL && vo->x11->vo_window != None)
#else
if (vidmodes != NULL)
#endif
@@ -1658,20 +1653,20 @@ void vo_vm_close(void)
free(vidmodes);
vidmodes = NULL;
- XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount,
+ XF86VidModeGetAllModeLines(dpy, vo->x11->screen, &modecount,
&vidmodes);
for (i = 0; i < modecount; i++)
- if ((vidmodes[i]->hdisplay == vo_screenwidth)
- && (vidmodes[i]->vdisplay == vo_screenheight))
+ if ((vidmodes[i]->hdisplay == opts->vo_screenwidth)
+ && (vidmodes[i]->vdisplay == opts->vo_screenheight))
{
mp_msg(MSGT_VO, MSGL_INFO,
"Returning to original mode %dx%d\n",
- vo_screenwidth, vo_screenheight);
+ opts->vo_screenwidth, opts->vo_screenheight);
break;
}
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]);
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]);
+ XF86VidModeSwitchToMode(dpy, vo->x11->screen, vidmodes[i]);
+ XF86VidModeSwitchToMode(dpy, vo->x11->screen, vidmodes[i]);
free(vidmodes);
vidmodes = NULL;
}
@@ -1739,12 +1734,13 @@ static XColor cols[256];
static int cm_size, red_mask, green_mask, blue_mask;
-Colormap vo_x11_create_colormap(XVisualInfo * vinfo)
+Colormap vo_x11_create_colormap(struct vo *vo, XVisualInfo *vinfo)
{
+ struct vo_x11_state *x11 = vo->x11;
unsigned k, r, g, b, ru, gu, bu, m, rv, gv, bv, rvu, gvu, bvu;
if (vinfo->class != DirectColor)
- return XCreateColormap(mDisplay, mRootWin, vinfo->visual,
+ return XCreateColormap(x11->display, x11->rootwin, vinfo->visual,
AllocNone);
/* can this function get called twice or more? */
@@ -1788,8 +1784,8 @@ Colormap vo_x11_create_colormap(XVisualInfo * vinfo)
gv += gvu;
bv += bvu;
}
- cmap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocAll);
- XStoreColors(mDisplay, cmap, cols, cm_size);
+ cmap = XCreateColormap(x11->display, x11->rootwin, vinfo->visual, AllocAll);
+ XStoreColors(x11->display, cmap, cols, cm_size);
return cmap;
}
@@ -1816,7 +1812,7 @@ static int transform_color(float val,
return (unsigned short) (s * 65535);
}
-uint32_t vo_x11_set_equalizer(char *name, int value)
+uint32_t vo_x11_set_equalizer(struct vo *vo, char *name, int value)
{
float gamma, brightness, contrast;
float rf, gf, bf;
@@ -1862,8 +1858,8 @@ uint32_t vo_x11_set_equalizer(char *name, int value)
cols[k].blue = transform_color(bf * k, brightness, contrast, gamma);
}
- XStoreColors(mDisplay, cmap, cols, cm_size);
- XFlush(mDisplay);
+ XStoreColors(vo->x11->display, cmap, cols, cm_size);
+ XFlush(vo->x11->display);
return VO_TRUE;
}
@@ -1883,7 +1879,7 @@ uint32_t vo_x11_get_equalizer(char *name, int *value)
}
#ifdef CONFIG_XV
-int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
+int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char *name, int value)
{
XvAttribute *attributes;
int i, howmany, xv_atom;
@@ -1891,11 +1887,11 @@ int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
mp_dbg(MSGT_VO, MSGL_V, "xv_set_eq called! (%s, %d)\n", name, value);
/* get available attributes */
- attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
+ attributes = XvQueryPortAttributes(vo->x11->display, xv_port, &howmany);
for (i = 0; i < howmany && attributes; i++)
if (attributes[i].flags & XvSettable)
{
- xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
+ xv_atom = XInternAtom(vo->x11->display, attributes[i].name, True);
/* since we have SET_DEFAULTS first in our list, we can check if it's available
then trigger it if it's ok so that the other values are at default upon query */
if (xv_atom != None)
@@ -1946,32 +1942,32 @@ int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
port_value =
(port_value + 100) * (port_max - port_min) / 200 +
port_min;
- XvSetPortAttribute(mDisplay, xv_port, xv_atom, port_value);
+ XvSetPortAttribute(vo->x11->display, xv_port, xv_atom, port_value);
return VO_TRUE;
}
}
return VO_FALSE;
}
-int vo_xv_get_eq(uint32_t xv_port, char *name, int *value)
+int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char *name, int *value)
{
XvAttribute *attributes;
int i, howmany, xv_atom;
/* get available attributes */
- attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
+ attributes = XvQueryPortAttributes(vo->x11->display, xv_port, &howmany);
for (i = 0; i < howmany && attributes; i++)
if (attributes[i].flags & XvGettable)
{
- xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
+ xv_atom = XInternAtom(vo->x11->display, attributes[i].name, True);
/* since we have SET_DEFAULTS first in our list, we can check if it's available
then trigger it if it's ok so that the other values are at default upon query */
if (xv_atom != None)
{
int val, port_value = 0, port_min, port_max;
- XvGetPortAttribute(mDisplay, xv_port, xv_atom,
+ XvGetPortAttribute(vo->x11->display, xv_port, xv_atom,
&port_value);
port_min = attributes[i].min_value;
@@ -2019,11 +2015,6 @@ int vo_xv_get_eq(uint32_t xv_port, char *name, int *value)
return VO_FALSE;
}
-/** \brief contains flags changing the execution of the colorkeying code */
-xv_ck_info_t xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR };
-unsigned long xv_colorkey; ///< The color used for manual colorkeying.
-unsigned int xv_port; ///< The selected Xv port.
-
/**
* \brief Interns the requested atom if it is available.
*
@@ -2032,20 +2023,21 @@ unsigned int xv_port; ///< The selected Xv port.
* \return Returns the atom if available, else None is returned.
*
*/
-static Atom xv_intern_atom_if_exists( char const * atom_name )
+static Atom xv_intern_atom_if_exists(struct vo_x11_state *x11,
+ char const *atom_name)
{
XvAttribute * attributes;
int attrib_count,i;
Atom xv_atom = None;
- attributes = XvQueryPortAttributes( mDisplay, xv_port, &attrib_count );
+ attributes = XvQueryPortAttributes(x11->display, x11->xv_port, &attrib_count );
if( attributes!=NULL )
{
for ( i = 0; i < attrib_count; ++i )
{
if ( strcmp(attributes[i].name, atom_name ) == 0 )
{
- xv_atom = XInternAtom( mDisplay, atom_name, False );
+ xv_atom = XInternAtom(x11->display, atom_name, False );
break; // found what we want, break out
}
}
@@ -2059,12 +2051,13 @@ static Atom xv_intern_atom_if_exists( char const * atom_name )
* \brief Try to enable vsync for xv.
* \return Returns -1 if not available, 0 on failure and 1 on success.
*/
-int vo_xv_enable_vsync(void)
+int vo_xv_enable_vsync(struct vo *vo)
{
- Atom xv_atom = xv_intern_atom_if_exists("XV_SYNC_TO_VBLANK");
+ struct vo_x11_state *x11 = vo->x11;
+ Atom xv_atom = xv_intern_atom_if_exists(x11, "XV_SYNC_TO_VBLANK");
if (xv_atom == None)
return -1;
- return XvSetPortAttribute(mDisplay, xv_port, xv_atom, 1) == Success;
+ return XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 1) == Success;
}
/**
@@ -2078,13 +2071,14 @@ int vo_xv_enable_vsync(void)
* \param height [out] The maximum height gets stored here.
*
*/
-void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height )
+void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height)
{
+ struct vo_x11_state *x11 = vo->x11;
XvEncodingInfo * encodings;
//unsigned long num_encodings, idx; to int or too long?!
unsigned int num_encodings, idx;
- XvQueryEncodings( mDisplay, xv_port, &num_encodings, &encodings);
+ XvQueryEncodings(x11->display, x11->xv_port, &num_encodings, &encodings);
if ( encodings )
{
@@ -2115,11 +2109,11 @@ void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height )
* Outputs the content of |ck_handling| as a readable message.
*
*/
-void vo_xv_print_ck_info(void)
+static void vo_xv_print_ck_info(struct vo_x11_state *x11)
{
mp_msg( MSGT_VO, MSGL_V, "[xv common] " );
- switch ( xv_ck_info.method )
+ switch ( x11->xv_ck_info.method )
{
case CK_METHOD_NONE:
mp_msg( MSGT_VO, MSGL_V, "Drawing no colorkey.\n" ); return;
@@ -2133,32 +2127,32 @@ void vo_xv_print_ck_info(void)
mp_msg( MSGT_VO, MSGL_V, "\n[xv common] " );
- switch ( xv_ck_info.source )
+ switch ( x11->xv_ck_info.source )
{
case CK_SRC_CUR:
mp_msg( MSGT_VO, MSGL_V, "Using colorkey from Xv (0x%06lx).\n",
- xv_colorkey );
+ x11->xv_colorkey );
break;
case CK_SRC_USE:
- if ( xv_ck_info.method == CK_METHOD_AUTOPAINT )
+ if ( x11->xv_ck_info.method == CK_METHOD_AUTOPAINT )
{
mp_msg( MSGT_VO, MSGL_V,
"Ignoring colorkey from MPlayer (0x%06lx).\n",
- xv_colorkey );
+ x11->xv_colorkey );
}
else
{
mp_msg( MSGT_VO, MSGL_V,
"Using colorkey from MPlayer (0x%06lx)."
" Use -colorkey to change.\n",
- xv_colorkey );
+ x11->xv_colorkey );
}
break;
case CK_SRC_SET:
mp_msg( MSGT_VO, MSGL_V,
"Setting and using colorkey from MPlayer (0x%06lx)."
" Use -colorkey to change.\n",
- xv_colorkey );
+ x11->xv_colorkey );
break;
}
}
@@ -2183,28 +2177,29 @@ void vo_xv_print_ck_info(void)
* NOTE: If vo_colorkey has bits set after the first 3 low order bytes
* we don't draw anything as this means it was forced to off.
*/
-int vo_xv_init_colorkey(void)
+int vo_xv_init_colorkey(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
Atom xv_atom;
int rez;
/* check if colorkeying is needed */
- xv_atom = xv_intern_atom_if_exists( "XV_COLORKEY" );
+ xv_atom = xv_intern_atom_if_exists(vo->x11, "XV_COLORKEY");
/* if we have to deal with colorkeying ... */
if( xv_atom != None && !(vo_colorkey & 0xFF000000) )
{
/* check if we should use the colorkey specified in vo_colorkey */
- if ( xv_ck_info.source != CK_SRC_CUR )
+ if ( x11->xv_ck_info.source != CK_SRC_CUR )
{
- xv_colorkey = vo_colorkey;
+ x11->xv_colorkey = vo_colorkey;
/* check if we have to set the colorkey too */
- if ( xv_ck_info.source == CK_SRC_SET )
+ if ( x11->xv_ck_info.source == CK_SRC_SET )
{
- xv_atom = XInternAtom(mDisplay, "XV_COLORKEY",False);
+ xv_atom = XInternAtom(x11->display, "XV_COLORKEY",False);
- rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, vo_colorkey );
+ rez = XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, vo_colorkey);
if ( rez != Success )
{
mp_msg( MSGT_VO, MSGL_FATAL,
@@ -2217,10 +2212,10 @@ int vo_xv_init_colorkey(void)
{
int colorkey_ret;
- rez=XvGetPortAttribute(mDisplay,xv_port, xv_atom, &colorkey_ret);
+ rez=XvGetPortAttribute(x11->display,x11->xv_port, xv_atom, &colorkey_ret);
if ( rez == Success )
{
- xv_colorkey = colorkey_ret;
+ x11->xv_colorkey = colorkey_ret;
}
else
{
@@ -2231,39 +2226,39 @@ int vo_xv_init_colorkey(void)
}
}
- xv_atom = xv_intern_atom_if_exists( "XV_AUTOPAINT_COLORKEY" );
+ xv_atom = xv_intern_atom_if_exists(vo->x11, "XV_AUTOPAINT_COLORKEY");
/* should we draw the colorkey ourselves or activate autopainting? */
- if ( xv_ck_info.method == CK_METHOD_AUTOPAINT )
+ if ( x11->xv_ck_info.method == CK_METHOD_AUTOPAINT )
{
rez = !Success; // reset rez to something different than Success
if ( xv_atom != None ) // autopaint is supported
{
- rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, 1 );
+ rez = XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 1);
}
if ( rez != Success )
{
// fallback to manual colorkey drawing
- xv_ck_info.method = CK_METHOD_MANUALFILL;
+ x11->xv_ck_info.method = CK_METHOD_MANUALFILL;
}
}
else // disable colorkey autopainting if supported
{
if ( xv_atom != None ) // we have autopaint attribute
{
- XvSetPortAttribute( mDisplay, xv_port, xv_atom, 0 );
+ XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 0);
}
}
}
else // do no colorkey drawing at all
{
- xv_ck_info.method = CK_METHOD_NONE;
+ x11->xv_ck_info.method = CK_METHOD_NONE;
} /* end: should we draw colorkey */
/* output information about the current colorkey settings */
- vo_xv_print_ck_info();
+ vo_xv_print_ck_info(x11);
return 1; // success
}
@@ -2278,14 +2273,16 @@ int vo_xv_init_colorkey(void)
* It doesn't call XFlush.
*
*/
-void vo_xv_draw_colorkey( int32_t x, int32_t y,
- int32_t w, int32_t h )
+void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y,
+ int32_t w, int32_t h)
{
- if( xv_ck_info.method == CK_METHOD_MANUALFILL ||
- xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
+ if( x11->xv_ck_info.method == CK_METHOD_MANUALFILL ||
+ x11->xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
{
- XSetForeground( mDisplay, vo_gc, xv_colorkey );
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ XSetForeground(x11->display, x11->vo_gc, x11->xv_colorkey );
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
x, y,
w, h );
}
@@ -2294,24 +2291,24 @@ void vo_xv_draw_colorkey( int32_t x, int32_t y,
/* TODO! move this to vo_x11_clearwindow_part() */
if ( vo_fs )
{
- XSetForeground( mDisplay, vo_gc, 0 );
+ XSetForeground(x11->display, x11->vo_gc, 0 );
/* making non-overlap fills, requires 8 checks instead of 4 */
if ( y > 0 )
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
0, 0,
- vo_screenwidth, y);
+ opts->vo_screenwidth, y);
if (x > 0)
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
0, 0,
- x, vo_screenheight);
- if (x + w < vo_screenwidth)
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ x, opts->vo_screenheight);
+ if (x + w < opts->vo_screenwidth)
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
x + w, 0,
- vo_screenwidth, vo_screenheight);
- if (y + h < vo_screenheight)
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ opts->vo_screenwidth, opts->vo_screenheight);
+ if (y + h < opts->vo_screenheight)
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
0, y + h,
- vo_screenwidth, vo_screenheight);
+ opts->vo_screenwidth, opts->vo_screenheight);
}
}
@@ -2356,19 +2353,20 @@ int xv_test_ckm( void * arg )
* \param str Pointer to the string or NULL
*
*/
-void xv_setup_colorkeyhandling( char const * ck_method_str,
- char const * ck_str )
+void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str,
+ const char *ck_str)
{
+ struct vo_x11_state *x11 = vo->x11;
/* check if a valid pointer to the string was passed */
if ( ck_str )
{
if ( strncmp( ck_str, "use", 3 ) == 0 )
{
- xv_ck_info.source = CK_SRC_USE;
+ x11->xv_ck_info.source = CK_SRC_USE;
}
else if ( strncmp( ck_str, "set", 3 ) == 0 )
{
- xv_ck_info.source = CK_SRC_SET;
+ x11->xv_ck_info.source = CK_SRC_SET;
}
}
/* check if a valid pointer to the string was passed */
@@ -2376,17 +2374,30 @@ void xv_setup_colorkeyhandling( char const * ck_method_str,
{
if ( strncmp( ck_method_str, "bg", 2 ) == 0 )
{
- xv_ck_info.method = CK_METHOD_BACKGROUND;
+ x11->xv_ck_info.method = CK_METHOD_BACKGROUND;
}
else if ( strncmp( ck_method_str, "man", 3 ) == 0 )
{
- xv_ck_info.method = CK_METHOD_MANUALFILL;
+ x11->xv_ck_info.method = CK_METHOD_MANUALFILL;
}
else if ( strncmp( ck_method_str, "auto", 4 ) == 0 )
{
- xv_ck_info.method = CK_METHOD_AUTOPAINT;
+ x11->xv_ck_info.method = CK_METHOD_AUTOPAINT;
}
}
}
#endif
+
+struct vo_x11_state *vo_x11_init_state(void)
+{
+ struct vo_x11_state *s = talloc_ptrtype(NULL, s);
+ *s = (struct vo_x11_state){
+ .xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR },
+ .olddecor = MWM_DECOR_ALL,
+ .oldfuncs = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
+ MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE,
+ .old_gravity = NorthWestGravity,
+ };
+ return s;
+}
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index c7221d2577..08248b57a5 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -24,6 +24,60 @@
#include "config.h"
+struct vo;
+
+struct vo_x11_state {
+ Display *display;
+ Window window;
+ Window rootwin;
+ int screen;
+ int display_is_local;
+ int depthonscreen;
+
+ GC vo_gc;
+
+ struct xv_ck_info_s {
+ int method; ///< CK_METHOD_* constants
+ int source; ///< CK_SRC_* constants
+ } xv_ck_info;
+ unsigned long xv_colorkey;
+ unsigned int xv_port;
+
+ int vo_mouse_autohide;
+ int wm_type;
+ int fs_type;
+ int fs_flip;
+
+ GC f_gc;
+ XSizeHints vo_hint;
+ unsigned int mouse_timer;
+ int mouse_waiting_hide;
+ int orig_layer;
+ int old_gravity;
+ int vo_old_x;
+ int vo_old_y;
+ int vo_old_width;
+ int vo_old_height;
+
+
+ unsigned int olddecor;
+ unsigned int oldfuncs;
+ XComposeStatus compose_status;
+
+ Atom XA_NET_SUPPORTED;
+ Atom XA_NET_WM_STATE;
+ Atom XA_NET_WM_STATE_FULLSCREEN;
+ Atom XA_NET_WM_STATE_ABOVE;
+ Atom XA_NET_WM_STATE_STAYS_ON_TOP;
+ Atom XA_NET_WM_STATE_BELOW;
+ Atom XA_NET_WM_PID;
+ Atom XA_WIN_PROTOCOLS;
+ Atom XA_WIN_LAYER;
+ Atom XA_WIN_HINTS;
+ Atom XAWM_PROTOCOLS;
+ Atom XAWM_DELETE_WINDOW;
+};
+
#if defined(CONFIG_GL) || defined(CONFIG_X11) || defined(CONFIG_XV)
#define X11_FULLSCREEN 1
#endif
@@ -51,67 +105,46 @@ extern int vo_fs_type;
extern char** vo_fstype_list;
extern char *mDisplayName;
-extern Display *mDisplay;
extern Window mRootWin;
extern int mScreen;
extern int mLocalDisplay;
-extern int vo_mouse_autohide;
-
-int vo_init( void );
-void vo_uninit( void );
-void vo_hidecursor ( Display* , Window );
-void vo_showcursor( Display *disp, Window win );
-void vo_x11_decoration( Display * vo_Display,Window w,int d );
-void vo_x11_classhint( Display * display,Window window,char *name );
-void vo_x11_nofs_sizepos(int x, int y, int width, int height);
-void vo_x11_sizehint( int x, int y, int width, int height, int max );
-int vo_x11_check_events(Display *mydisplay);
+struct vo_x11_state *vo_x11_init_state(void);
+int vo_init(struct vo *vo);
+void vo_uninit(struct vo_x11_state *x11);
+void vo_x11_decoration(struct vo *vo, int d );
+void vo_x11_classhint(struct vo *vo, Window window, char *name);
+void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, int max);
+int vo_x11_check_events(struct vo *vo);
void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask);
-int vo_x11_update_geometry(void);
-void vo_x11_fullscreen( void );
-void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer );
-void vo_x11_uninit(void);
-Colormap vo_x11_create_colormap(XVisualInfo *vinfo);
-uint32_t vo_x11_set_equalizer(char *name, int value);
+void vo_x11_fullscreen(struct vo *vo);
+int vo_x11_update_geometry(struct vo *vo);
+void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer);
+void vo_x11_uninit(struct vo *vo);
+Colormap vo_x11_create_colormap(struct vo *vo, XVisualInfo *vinfo);
+uint32_t vo_x11_set_equalizer(struct vo *vo, char *name, int value);
uint32_t vo_x11_get_equalizer(char *name, int *value);
void fstype_help(void);
-Window vo_x11_create_smooth_window( Display *mDisplay, Window mRoot,
- Visual *vis, int x, int y, unsigned int width, unsigned int height,
- int depth, Colormap col_map);
-void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
- unsigned int width, unsigned int height, int flags,
+void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
+ int x, int y, unsigned int width, unsigned int height, int flags,
Colormap col_map, const char *classname, const char *title);
-void vo_x11_clearwindow_part(Display *mDisplay, Window vo_window,
+void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
int img_width, int img_height, int use_fs);
-void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
-void vo_x11_ontop(void);
-void vo_x11_border(void);
-void vo_x11_ewmh_fullscreen( int action );
+void vo_x11_clearwindow(struct vo *vo, Window vo_window);
+void vo_x11_ontop(struct vo *vo);
+void vo_x11_border(struct vo *vo);
+void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action);
#endif
-extern Window vo_window;
-extern GC vo_gc;
-extern XSizeHints vo_hint;
-
-#ifdef CONFIG_XV
-//XvPortID xv_port;
-extern unsigned int xv_port;
+int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char * name, int value);
+int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char * name, int *value);
-int vo_xv_set_eq(uint32_t xv_port, char * name, int value);
-int vo_xv_get_eq(uint32_t xv_port, char * name, int *value);
+int vo_xv_enable_vsync(struct vo *vo);
-int vo_xv_enable_vsync(void);
-
-void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height );
+void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height);
/*** colorkey handling ***/
-typedef struct xv_ck_info_s
-{
- int method; ///< CK_METHOD_* constants
- int source; ///< CK_SRC_* constants
-} xv_ck_info_t;
#define CK_METHOD_NONE 0 ///< no colorkey drawing
#define CK_METHOD_BACKGROUND 1 ///< set colorkey as window background
@@ -121,31 +154,66 @@ typedef struct xv_ck_info_s
#define CK_SRC_SET 1 ///< use and set specified / default colorkey
#define CK_SRC_CUR 2 ///< use current colorkey ( get it from xv )
-extern xv_ck_info_t xv_ck_info;
-extern unsigned long xv_colorkey;
-
-int vo_xv_init_colorkey(void);
-void vo_xv_draw_colorkey(int32_t x, int32_t y, int32_t w, int32_t h);
-void xv_setup_colorkeyhandling(char const * ck_method_str, char const * ck_str);
+int vo_xv_init_colorkey(struct vo *vo);
+void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y, int32_t w, int32_t h);
+void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str, const char *ck_str);
/*** test functions for common suboptions ***/
int xv_test_ck( void * arg );
int xv_test_ckm( void * arg );
-#endif
-
-void vo_setwindow( Window w,GC g );
-void vo_x11_putkey(int key);
-void saver_off( Display * );
-void saver_on( Display * );
+void vo_x11_putkey(struct vo *vo, int key);
#ifdef CONFIG_XF86VM
-void vo_vm_switch(void);
-void vo_vm_close(void);
+void vo_vm_switch(struct vo *vo);
+void vo_vm_close(struct vo *vo);
#endif
-void update_xinerama_info(void);
+void update_xinerama_info(struct vo *vo);
int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return);
+void xscreensaver_heartbeat(struct vo_x11_state *x11);
+
+// Old VOs use incompatible function calls, translate them to new
+// prototypes
+#ifdef IS_OLD_VO
+#define vo_x11_create_vo_window(...) vo_x11_create_vo_window(global_vo, __VA_ARGS__)
+#define vo_x11_fullscreen() vo_x11_fullscreen(global_vo)
+#define vo_x11_update_geometry() vo_x11_update_geometry(global_vo)
+#define vo_x11_ontop() vo_x11_ontop(global_vo)
+#define vo_init() vo_init(global_vo)
+#define vo_x11_ewmh_fullscreen(action) vo_x11_ewmh_fullscreen(global_vo->x11->display, action)
+#define update_xinerama_info() update_xinerama_info(global_vo)
+#define vo_x11_uninit() vo_x11_uninit(global_vo)
+#define vo_x11_check_events(display) vo_x11_check_events(global_vo)
+#define vo_x11_sizehint(...) vo_x11_sizehint(global_vo, __VA_ARGS__)
+#define vo_vm_switch() vo_vm_switch(global_vo)
+#define vo_x11_create_colormap(vinfo) vo_x11_create_colormap(global_vo, vinfo)
+#define vo_x11_set_equalizer(...) vo_x11_set_equalizer(global_vo, __VA_ARGS__)
+#define vo_xv_set_eq(...) vo_xv_set_eq(global_vo, __VA_ARGS__)
+#define vo_xv_get_eq(...) vo_xv_get_eq(global_vo, __VA_ARGS__)
+#define vo_xv_enable_vsync() vo_xv_enable_vsync(global_vo)
+#define vo_xv_get_max_img_dim(...) vo_xv_get_max_img_dim(global_vo, __VA_ARGS__)
+#define vo_xv_init_colorkey() vo_xv_init_colorkey(global_vo)
+#define vo_xv_draw_colorkey(...) vo_xv_draw_colorkey(global_vo, __VA_ARGS__)
+#define vo_x11_clearwindow_part(display, ...) vo_x11_clearwindow_part(global_vo, __VA_ARGS__)
+#define vo_vm_close() vo_vm_close(global_vo)
+#define vo_x11_clearwindow(display, window) vo_x11_clearwindow(global_vo, window)
+#define vo_x11_classhint(display, window, name) vo_x11_classhint(global_vo, window, name)
+#define vo_x11_setlayer(display, window, layer) vo_x11_setlayer(global_vo, window, layer)
+#define xv_setup_colorkeyhandling(a, b) xv_setup_colorkeyhandling(global_vo, a, b)
+#define vo_x11_border() vo_x11_border(global_vo)
+
+#define mDisplay global_vo->x11->display
+#define vo_depthonscreen global_vo->x11->depthonscreen
+#define vo_window global_vo->x11->window
+#define xv_ck_info global_vo->x11->xv_ck_info
+#define xv_colorkey global_vo->x11->xv_colorkey
+#define xv_port global_vo->x11->xv_port
+#define vo_gc global_vo->x11->vo_gc
+#define mRootWin global_vo->x11->rootwin
+#define mScreen global_vo->x11->screen
+#define mLocalDisplay global_vo->x11->display_is_local
+#endif
#endif /* MPLAYER_X11_COMMON_H */