diff options
Diffstat (limited to 'libvo')
69 files changed, 1922 insertions, 1831 deletions
diff --git a/libvo/aspect.c b/libvo/aspect.c index dfed30d976..5a2091baba 100644 --- a/libvo/aspect.c +++ b/libvo/aspect.c @@ -1,9 +1,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 @@ -12,80 +14,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{ @@ -96,47 +84,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 be5e4a12f8..b803b99490 100644 --- a/libvo/aspect.h +++ b/libvo/aspect.h @@ -2,23 +2,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; +extern void panscan_init(struct vo *vo); +extern void panscan_calc(struct vo *vo); -extern void panscan_init( void ); -extern 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 df3000efb5..38c1e321ec 100644 --- a/libvo/font_load.h +++ b/libvo/font_load.h @@ -62,7 +62,6 @@ typedef struct font_desc { } font_desc_t; extern font_desc_t* vo_font; -extern font_desc_t* sub_font; #ifdef CONFIG_FREETYPE diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c index f5926ca277..9d887573da 100644 --- a/libvo/font_load_ft.c +++ b/libvo/font_load_ft.c @@ -70,13 +70,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 fe4701f219..9c84e71cf2 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -13,6 +13,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 6df60ce257..8b1e4b144c 100644 --- a/libvo/gl_common.h +++ b/libvo/gl_common.h @@ -293,18 +293,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 e7705025b5..34eee958e3 100644 --- a/libvo/mga_common.c +++ b/libvo/mga_common.c @@ -6,6 +6,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 */ @@ -229,7 +230,7 @@ static void mga_fullscreen() } #endif -static int control(uint32_t request, void *data, ...) +static int control(uint32_t request, void *data) { switch (request) { case VOCTRL_QUERY_FORMAT: @@ -240,11 +241,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()"); @@ -254,15 +256,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); @@ -278,12 +278,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()"); @@ -291,16 +291,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..fd266c1896 --- /dev/null +++ b/libvo/old_vo_defines.h @@ -0,0 +1,22 @@ +#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 +#endif diff --git a/libvo/old_vo_wrapper.c b/libvo/old_vo_wrapper.c new file mode 100644 index 0000000000..57d1145f53 --- /dev/null +++ b/libvo/old_vo_wrapper.c @@ -0,0 +1,105 @@ +/* + * 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); +} + +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..e7e98fdad6 --- /dev/null +++ b/libvo/old_vo_wrapper.h @@ -0,0 +1,26 @@ +#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)); +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 dffc5f79ab..c7d3fb516e 100644 --- a/libvo/sub.c +++ b/libvo/sub.c @@ -19,6 +19,7 @@ #include "osdep/timer.h" #endif +#include "talloc.h" #include "mplayer.h" #include "mp_msg.h" #include "help_mp.h" @@ -51,7 +52,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, @@ -66,13 +67,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; @@ -154,9 +153,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, @@ -179,8 +180,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; @@ -201,7 +204,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); @@ -639,7 +642,7 @@ subtitle* vo_sub=NULL; // vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) -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; @@ -648,10 +651,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; } @@ -1022,9 +1026,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; @@ -1048,7 +1052,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; @@ -1058,11 +1063,13 @@ void free_osd_list(void){ obj=next; } vo_osd_list=NULL; + talloc_free(osd); } #define FONT_LOAD_DEFER 6 -int vo_update_osd(int dxs,int dys){ +int osd_update(struct osd_state *osd, int dxs, int dys) +{ mp_osd_obj_t* obj=vo_osd_list; int chg=0; #ifdef CONFIG_FREETYPE @@ -1092,20 +1099,20 @@ int vo_update_osd(int dxs,int dys){ 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 @@ -1121,7 +1128,7 @@ int vo_update_osd(int dxs,int dys){ 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: @@ -1140,8 +1147,8 @@ int vo_update_osd(int dxs,int dys){ 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; @@ -1181,12 +1188,15 @@ int vo_update_osd(int dxs,int dys){ return chg; } -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); @@ -1201,13 +1211,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)){ @@ -1223,15 +1236,20 @@ void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){ } } -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 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) +{ mp_osd_obj_t* obj=vo_osd_list; - vo_update_osd(dxs,dys); + osd_update(osd, dxs, dys); 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: @@ -1242,7 +1260,7 @@ void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, 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; diff --git a/libvo/sub.h b/libvo/sub.h index d0cd9e1360..a1e7acd3c4 100644 --- a/libvo/sub.h +++ b/libvo/sub.h @@ -49,22 +49,16 @@ typedef struct mp_osd_obj_s { unsigned char *bitmap_buffer; } mp_osd_obj_t; - -#if 0 - -// disable subtitles: -static inline void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ -} - -#else +struct osd_state { + unsigned char osd_text[64]; + 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; @@ -96,8 +90,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; @@ -116,14 +110,19 @@ extern float spu_gaussvar; //extern void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); //extern void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); //extern void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); -extern 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)); -extern 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_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; @@ -134,6 +133,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 -#endif /* 0 */ + +#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 ea5ecc93a1..fc1573325b 100644 --- a/libvo/vesa_lvo.c +++ b/libvo/vesa_lvo.c @@ -43,13 +43,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) { @@ -155,7 +155,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; @@ -195,7 +195,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");} @@ -213,7 +213,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); @@ -303,7 +303,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 67a9ee0dd1..2581ace34e 100644 --- a/libvo/vesa_lvo.h +++ b/libvo/vesa_lvo.h @@ -21,8 +21,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 836f7adc1a..90634fecab 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -1,5 +1,5 @@ -/* this file contains libvo's common functions, variables used by +/* this file contains libvo's common functions, variables used by many/all drivers. */ #include <stdio.h> @@ -10,6 +10,8 @@ //#include <sys/mman.h> #include "config.h" +#include "options.h" +#include "talloc.h" #include "video_out.h" #include "aspect.h" #include "geometry.h" @@ -18,27 +20,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; @@ -46,7 +35,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; @@ -66,55 +54,55 @@ 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_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_directx; -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_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_directx; +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, @@ -157,7 +145,7 @@ const vo_functions_t* const video_out_drivers[] = &video_out_xover, #endif #ifdef CONFIG_GL - &video_out_gl, + &video_out_gl, &video_out_gl2, #endif #ifdef CONFIG_DGA @@ -230,7 +218,7 @@ const vo_functions_t* const video_out_drivers[] = #endif #ifdef CONFIG_PNG &video_out_png, -#endif +#endif #ifdef CONFIG_JPEG &video_out_jpeg, #endif @@ -249,83 +237,156 @@ 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,"\t%s\t%s\n", info->short_name, info->name); + } + 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; - } - - return vo->config(width, height, d_width, d_height, flags, title, format); + 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; + } + + int ret = vo->driver->config(vo, width, height, d_width, d_height, flags, + title, format); + vo->config_ok = (ret == 0); + vo->config_count += vo->config_ok; + return ret; } -#if defined(CONFIG_FBDEV) || defined(CONFIG_VESA) -/* Borrowed from vo_fbdev.c +#if defined(CONFIG_FBDEV)||defined(CONFIG_VESA) +/* Borrowed from vo_fbdev.c Monitor ranges related functions*/ char *monitor_hfreq_str = NULL; diff --git a/libvo/video_out.h b/libvo/video_out.h index d5a12acdcf..e392b55f2b 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -47,7 +47,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 @@ -108,15 +116,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: @@ -127,21 +144,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: @@ -151,60 +168,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); - -} vo_functions_t; - -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, + void (*uninit)(struct vo *vo); +}; + +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; +}; + +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; @@ -216,18 +273,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; 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 f79dfd913a..3b3d5f8f50 100644 --- a/libvo/vo_aa.c +++ b/libvo/vo_aa.c @@ -86,7 +86,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 @@ -182,15 +184,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; @@ -534,18 +531,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; } @@ -718,37 +715,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 23c1af0886..fa3f36d2e3 100644 --- a/libvo/vo_bl.c +++ b/libvo/vo_bl.c @@ -460,7 +460,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 3fd1fcd1cd..46dab1d7c6 100644 --- a/libvo/vo_caca.c +++ b/libvo/vo_caca.c @@ -322,7 +322,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 0f7de905dc..c2565ef7ec 100644 --- a/libvo/vo_cvidix.c +++ b/libvo/vo_cvidix.c @@ -152,11 +152,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)); @@ -165,24 +165,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 af1e89105e..fac15a46dd 100644 --- a/libvo/vo_dfbmga.c +++ b/libvo/vo_dfbmga.c @@ -1381,7 +1381,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: @@ -1399,25 +1399,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_directfb2.c b/libvo/vo_directfb2.c index 86dbc9b0d2..b8acb74080 100644 --- a/libvo/vo_directfb2.c +++ b/libvo/vo_directfb2.c @@ -1411,7 +1411,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: @@ -1422,25 +1422,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 b87c811b76..67ed453d04 100644 --- a/libvo/vo_directx.c +++ b/libvo/vo_directx.c @@ -89,9 +89,6 @@ static float window_aspect; static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL; static RECT last_rect = {0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE}; -extern 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)); -extern int vidmode; - /***************************************************************************** * DirectDraw GUIDs. * Defining them here allows us to get rid of the dxguid library during @@ -1474,7 +1471,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 +1563,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 93ad86f610..f5dc56bb13 100644 --- a/libvo/vo_dxr2.c +++ b/libvo/vo_dxr2.c @@ -28,8 +28,7 @@ #include <dxr2ioctl.h> -extern float monitor_aspect; -extern float movie_aspect; +#include "aspect.h" int dxr2_fd = -1; @@ -37,7 +36,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; @@ -432,7 +432,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); @@ -646,7 +646,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; @@ -820,10 +820,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; @@ -906,7 +907,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 82b3d3c779..69038ae0eb 100644 --- a/libvo/vo_dxr3.c +++ b/libvo/vo_dxr3.c @@ -162,7 +162,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: @@ -240,22 +240,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) @@ -264,23 +259,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; @@ -310,7 +300,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 14889b81b7..e8f5e86ba7 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -1134,7 +1134,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 { @@ -1165,7 +1166,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: @@ -1178,27 +1179,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 30bbc35792..0b6fda1ea7 100644 --- a/libvo/vo_fbdev2.c +++ b/libvo/vo_fbdev2.c @@ -398,7 +398,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 4ff1f40299..935e64ea95 100644 --- a/libvo/vo_ggi.c +++ b/libvo/vo_ggi.c @@ -67,6 +67,8 @@ static struct ggi_conf_s { } flushregion; int voflags; + + int depthonscreen; } ggi_conf; @@ -194,7 +196,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; @@ -358,9 +360,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) { @@ -368,7 +370,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); } } @@ -452,7 +454,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 e3e1d6ac95..869276d9c4 100644 --- a/libvo/vo_gif89a.c +++ b/libvo/vo_gif89a.c @@ -336,7 +336,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 b26e3c1855..9d538a8447 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -958,7 +958,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: @@ -993,14 +993,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(global_vo); resize(vo_dwidth, vo_dheight); return VO_TRUE; case VOCTRL_GET_PANSCAN: @@ -1012,33 +1012,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; } diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c index 5a81213b6f..d7814948aa 100644 --- a/libvo/vo_gl2.c +++ b/libvo/vo_gl2.c @@ -869,7 +869,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: @@ -881,7 +881,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(); @@ -890,7 +890,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(global_vo); return VO_TRUE; case VOCTRL_GET_PANSCAN: return VO_TRUE; @@ -900,23 +900,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 05f37303d5..38b9ee7f4e 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 e1a397eaf1..3d8fcc77f0 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_macosx.m b/libvo/vo_macosx.m index f21623c885..9cd0a1a008 100644 --- a/libvo/vo_macosx.m +++ b/libvo/vo_macosx.m @@ -24,6 +24,7 @@ #include "input/mouse.h" #include "osdep/keycodes.h" +#include "mp_fifo.h" //Cocoa NSDistantObject *mplayerosxProxy; @@ -60,8 +61,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; @@ -80,9 +79,6 @@ static vo_info_t info = LIBVO_EXTERN(macosx) -extern void mplayer_put_key(int code); -extern 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)); - static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) { switch (image_format) @@ -359,7 +355,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) { @@ -1012,7 +1008,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 cc7a4f3f07..4eae0fb11b 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 7858256f20..3971abdb69 100644 --- a/libvo/vo_mpegpes.c +++ b/libvo/vo_mpegpes.c @@ -172,7 +172,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 @@ -207,15 +207,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]; @@ -253,7 +248,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 791dfd515d..3c5f109aa2 100644 --- a/libvo/vo_png.c +++ b/libvo/vo_png.c @@ -223,7 +223,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 52aa623bb1..fe5909329a 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 f126cc82d7..164d00b79d 100644 --- a/libvo/vo_quartz.c +++ b/libvo/vo_quartz.c @@ -70,8 +70,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; @@ -129,8 +127,6 @@ enum #include "osdep/keycodes.h" -extern 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)); - //PROTOTYPE///////////////////////////////////////////////////////////////// static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); @@ -1232,7 +1228,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 778374e2d1..e36348e8cd 100644 --- a/libvo/vo_s3fb.c +++ b/libvo/vo_s3fb.c @@ -504,7 +504,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 4fca181e24..7bf359dc26 100644 --- a/libvo/vo_sdl.c +++ b/libvo/vo_sdl.c @@ -1660,7 +1660,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 0e2f770eca..522ea8c83a 100644 --- a/libvo/vo_svga.c +++ b/libvo/vo_svga.c @@ -135,7 +135,7 @@ char s[64]; 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)) { @@ -350,7 +350,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: @@ -362,33 +362,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 522f5e928d..501017f0f7 100644 --- a/libvo/vo_tdfx_vid.c +++ b/libvo/vo_tdfx_vid.c @@ -646,7 +646,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 6cdb07563c..fb825c37f3 100644 --- a/libvo/vo_tdfxfb.c +++ b/libvo/vo_tdfxfb.c @@ -478,7 +478,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 63f7be2284..e5cd90181b 100644 --- a/libvo/vo_tga.c +++ b/libvo/vo_tga.c @@ -242,7 +242,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 7cecfd75da..7157c68430 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_vesa.c b/libvo/vo_vesa.c index e9cad61248..b761fdc036 100644 --- a/libvo/vo_vesa.c +++ b/libvo/vo_vesa.c @@ -1076,7 +1076,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) @@ -1090,7 +1091,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: @@ -1098,33 +1099,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 ed6257b33f..bccf6f02ef 100644 --- a/libvo/vo_wii.c +++ b/libvo/vo_wii.c @@ -408,7 +408,7 @@ get_image(mp_image_t *mpi) } static int -control (uint32_t request, void *data, ...) +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 b03b1b2ded..2581310596 100644 --- a/libvo/vo_winvidix.c +++ b/libvo/vo_winvidix.c @@ -43,6 +43,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; @@ -116,7 +117,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(); @@ -190,7 +191,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); @@ -323,13 +324,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);} @@ -337,28 +338,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 2343a16f72..c3692cad58 100644 --- a/libvo/vo_x11.c +++ b/libvo/vo_x11.c @@ -745,7 +745,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) { @@ -761,25 +761,13 @@ static int control(uint32_t request, void *data, ...) return get_image(data); 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 0420b2be0e..38a3a585e6 100644 --- a/libvo/vo_xover.c +++ b/libvo/vo_xover.c @@ -67,8 +67,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) { @@ -211,7 +211,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(); @@ -384,10 +384,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) @@ -399,35 +399,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) { @@ -449,7 +452,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 f84f99fb83..6dfd8a8cf4 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -19,13 +19,17 @@ Buffer allocation: #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdint.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> @@ -40,6 +44,7 @@ Buffer allocation: #include "subopt-helper.h" #include "input/input.h" +#include "mp_fifo.h" #ifdef CONFIG_GUI #include "gui/interface.h" @@ -54,107 +59,115 @@ 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 flip_flag; +struct xvctx { + XvAdaptorInfo *ai; + XvImageFormatValues *fo; + unsigned int formats, adaptors, xv_format; + int current_buf; + int current_ip_buf; + int num_buffers; + int visible_buf; + XvImage *xvimage[NUM_BUFFERS]; + uint32_t image_width; + uint32_t image_height; + uint32_t image_format; + int is_paused; + uint32_t drwX, drwY; + uint32_t max_width, max_height; // zero means: not set + int event_fd_registered; // for uninit called from preinit + int mode_switched; + 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 int int_pause; +// FIXME: dynamically allocate this stuff +static void allocate_xvimage(struct vo *, int); -static Window mRoot; -static uint32_t drwX, drwY, drwBorderWidth, drwDepth; -static uint32_t max_width = 0, max_height = 0; // zero means: not set -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]); } -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]); } -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]); } -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 calc_drwXY(uint32_t *drwX, uint32_t *drwY) { +static void calc_drwXY(struct vo *vo, uint32_t *drwX, uint32_t *drwY) { + struct MPOpts *opts = vo->opts; *drwX = *drwY = 0; if (vo_fs) { - aspect(&vo_dwidth, &vo_dheight, A_ZOOM); - vo_dwidth = FFMIN(vo_dwidth, vo_screenwidth); - vo_dheight = FFMIN(vo_dheight, vo_screenheight); - *drwX = (vo_screenwidth - vo_dwidth) / 2; - *drwY = (vo_screenheight - vo_dheight) / 2; + aspect(vo, &vo->dwidth, &vo->dheight, A_ZOOM); + vo->dwidth = FFMIN(vo->dwidth, opts->vo_screenwidth); + vo->dheight = FFMIN(vo->dheight, opts->vo_screenheight); + *drwX = (opts->vo_screenwidth - vo->dwidth) / 2; + *drwY = (opts->vo_screenheight - vo->dheight) / 2; mp_msg(MSGT_VO, MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n", - *drwX, *drwY, vo_dwidth, vo_dheight); + *drwX, *drwY, vo->dwidth, vo->dheight); } else if (WinID == 0) { - *drwX = vo_dx; - *drwY = vo_dy; + *drwX = vo->dx; + *drwY = vo->dy; } } @@ -162,10 +175,12 @@ static void calc_drwXY(uint32_t *drwX, uint32_t *drwY) { * 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; XSizeHints hint; XVisualInfo vinfo; XGCValues xgcv; @@ -173,56 +188,38 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, XWindowAttributes attribs; unsigned long xswamask; int depth; + struct xvctx *ctx = vo->priv; + int i; -#ifdef CONFIG_XF86VM - int vm = 0; - unsigned int modeline_width, modeline_height; - static uint32_t vm_width; - static uint32_t vm_height; -#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)) + 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, - image_width, image_height, max_width, max_height); + ctx->image_width, ctx->image_height, ctx->max_width, ctx->max_height); return -1; } - vo_mouse_autohide = 1; + x11->vo_mouse_autohide = 1; - int_pause = 0; - visible_buf = -1; - -#ifdef CONFIG_XF86VM - if (flags & VOFLAG_MODESWITCHING) - vm = 1; -#endif - flip_flag = flags & VOFLAG_FLIPPING; - num_buffers = - vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1; + ctx->is_paused = 0; + ctx->visible_buf = -1; /* 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) @@ -230,58 +227,64 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, else #endif { - hint.x = vo_dx; - hint.y = vo_dy; + hint.x = vo->dx; + hint.y = vo->dy; hint.width = d_width; hint.height = d_height; #ifdef CONFIG_XF86VM + unsigned int modeline_width, modeline_height; + uint32_t vm_width; + uint32_t vm_height; + int vm = flags & VOFLAG_MODESWITCHING; if (vm) { if ((d_width == 0) && (d_height == 0)) { - vm_width = image_width; - vm_height = image_height; + vm_width = ctx->image_width; + vm_height = ctx->image_height; } else { vm_width = d_width; vm_height = d_height; } - vo_vm_switch(vm_width, vm_height, &modeline_width, + vo_vm_switch(vo, vm_width, vm_height, &modeline_width, &modeline_height); - hint.x = (vo_screenwidth - modeline_width) / 2; - hint.y = (vo_screenheight - modeline_height) / 2; + ctx->mode_switched = 1; + hint.x = (opts->vo_screenwidth - modeline_width) / 2; + hint.y = (opts->vo_screenheight - modeline_height) / 2; hint.width = modeline_width; hint.height = modeline_height; - aspect_save_screenres(modeline_width, modeline_height); + aspect_save_screenres(vo, modeline_width, modeline_height); } else +#warning This "else" makes no sense #endif hint.flags = PPosition | PSize /* | PBaseSize */ ; hint.base_width = hint.width; hint.base_height = hint.height; - 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) + if (x11->xv_ck_info.method == CK_METHOD_BACKGROUND) { - xswa.background_pixel = xv_colorkey; + xswa.background_pixel = x11->xv_colorkey; } xswa.border_pixel = 0; xswamask = CWBackPixel | CWBorderPixel; if (WinID >= 0) { - vo_window = WinID ? ((Window) WinID) : mRootWin; + x11->window = WinID ? ((Window) WinID) : x11->rootwin; if (WinID) { - XUnmapWindow(mDisplay, vo_window); - XChangeWindowAttributes(mDisplay, vo_window, xswamask, + XUnmapWindow(x11->display, x11->window); + XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa); - vo_x11_selectinput_witherr(mDisplay, vo_window, + vo_x11_selectinput_witherr(x11->display, x11->window, StructureNotifyMask | KeyPressMask | PropertyChangeMask | @@ -289,267 +292,261 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, ButtonPressMask | ButtonReleaseMask | ExposureMask); - XMapWindow(mDisplay, vo_window); - XGetGeometry(mDisplay, vo_window, &mRoot, - &drwX, &drwY, &vo_dwidth, &vo_dheight, + XMapWindow(x11->display, x11->window); + Window mRoot; + uint32_t drwBorderWidth, drwDepth; + XGetGeometry(x11->display, x11->window, &mRoot, + &ctx->drwX, &ctx->drwY, &vo->dwidth, &vo->dheight, &drwBorderWidth, &drwDepth); - if (vo_dwidth <= 0) vo_dwidth = d_width; - if (vo_dheight <= 0) vo_dheight = d_height; - aspect_save_prescale(vo_dwidth, vo_dheight); + if (vo->dwidth <= 0) vo->dwidth = d_width; + if (vo->dheight <= 0) vo->dheight = d_height; + aspect_save_prescale(vo, vo->dwidth, vo->dheight); } } else { - vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, + vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, d_width, d_height, flags, CopyFromParent, "xv", title); - XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); + XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa); } - if (vo_gc != None) - XFreeGC(mDisplay, vo_gc); - vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv); - XSync(mDisplay, False); + if (x11->vo_gc != None) + XFreeGC(x11->display, x11->vo_gc); + x11->vo_gc = XCreateGC(x11->display, x11->window, 0L, &xgcv); + XSync(x11->display, False); #ifdef CONFIG_XF86VM if (vm) { /* Grab the mouse pointer in our window */ if (vo_grabpointer) - XGrabPointer(mDisplay, vo_window, True, 0, + XGrabPointer(x11->display, x11->window, True, 0, GrabModeAsync, GrabModeAsync, - vo_window, None, CurrentTime); - XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); + 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); + x11->xv_port); - switch (xv_format) + switch (ctx->xv_format) { case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: - draw_alpha_fnc = draw_alpha_yv12; + ctx->draw_alpha_fnc = draw_alpha_yv12; break; case IMGFMT_YUY2: case IMGFMT_YVYU: - draw_alpha_fnc = draw_alpha_yuy2; + ctx->draw_alpha_fnc = draw_alpha_yuy2; break; case IMGFMT_UYVY: - draw_alpha_fnc = draw_alpha_uyvy; + ctx->draw_alpha_fnc = draw_alpha_uyvy; break; default: - draw_alpha_fnc = draw_alpha_null; + 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->num_buffers; i++) + deallocate_xvimage(vo, i); + + ctx->num_buffers = + vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1; - for (current_buf = 0; current_buf < num_buffers; ++current_buf) - allocate_xvimage(current_buf); + for (i = 0; i < ctx->num_buffers; i++) + allocate_xvimage(vo, i); - current_buf = 0; - current_ip_buf = 0; + ctx->current_buf = 0; + ctx->current_ip_buf = 0; #if 0 set_gamma_correction(); #endif - aspect(&vo_dwidth, &vo_dheight, A_NOZOOM); + aspect(vo, &vo->dwidth, &vo->dheight, A_NOZOOM); if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) vo_fs = 1; - calc_drwXY(&drwX, &drwY); + calc_drwXY(vo, &ctx->drwX, &ctx->drwY); - panscan_calc(); + panscan_calc(vo); - vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), - drwY - (vo_panscan_y >> 1), - vo_dwidth + vo_panscan_x - 1, - vo_dheight + vo_panscan_y - 1); + vo_xv_draw_colorkey(vo, ctx->drwX - (vo->panscan_x >> 1), + ctx->drwY - (vo->panscan_y >> 1), + vo->dwidth + vo->panscan_x - 1, + vo->dheight + vo->panscan_y - 1); + mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", ctx->drwX, + ctx->drwY, vo->dwidth, vo->dheight); -#if 0 -#ifdef HAVE_SHM - if (Shmem_Flag) - { - XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, - xvimage[current_buf], 0, 0, image_width, - image_height, drwX, drwY, 1, 1, False); - XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, - xvimage[current_buf], 0, 0, image_width, - image_height, drwX, drwY, vo_dwidth, - (vo_fs ? vo_dheight - 1 : vo_dheight), False); - } else -#endif - { - XvPutImage(mDisplay, xv_port, vo_window, vo_gc, - xvimage[current_buf], 0, 0, image_width, image_height, - drwX, drwY, 1, 1); - XvPutImage(mDisplay, xv_port, vo_window, vo_gc, - xvimage[current_buf], 0, 0, image_width, image_height, - drwX, drwY, vo_dwidth, - (vo_fs ? vo_dheight - 1 : vo_dheight)); - } -#endif - - mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, - drwY, vo_dwidth, vo_dheight); - - if (vo_ontop) - vo_x11_setlayer(mDisplay, vo_window, vo_ontop); + if (opts->vo_ontop) + vo_x11_setlayer(vo, x11->window, opts->vo_ontop); 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; + if (x11->display_is_local && XShmQueryExtension(x11->display)) + ctx->Shmem_Flag = 1; else { - Shmem_Flag = 0; + ctx->Shmem_Flag = 0; mp_msg(MSGT_VO, MSGL_INFO, MSGTR_LIBVO_XV_SharedMemoryNotSupported); } - if (Shmem_Flag) + if (ctx->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); + 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) + if (ctx->Shmem_Flag) { - XShmDetach(mDisplay, &Shminfo[foo]); - shmdt(Shminfo[foo].shmaddr); + 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; #ifdef HAVE_SHM - if (Shmem_Flag) + if (ctx->Shmem_Flag) { - XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, - xvi, 0, 0, image_width, - image_height, drwX - (vo_panscan_x >> 1), - drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x, - vo_dheight + vo_panscan_y, + XvShmPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, + xvi, 0, 0, ctx->image_width, + ctx->image_height, ctx->drwX - (vo->panscan_x >> 1), + ctx->drwY - (vo->panscan_y >> 1), vo->dwidth + vo->panscan_x, + vo->dheight + vo->panscan_y, False); } else #endif { - XvPutImage(mDisplay, xv_port, vo_window, vo_gc, - xvi, 0, 0, image_width, image_height, - drwX - (vo_panscan_x >> 1), drwY - (vo_panscan_y >> 1), - vo_dwidth + vo_panscan_x, - vo_dheight + vo_panscan_y); + XvPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, + xvi, 0, 0, ctx->image_width, ctx->image_height, + ctx->drwX - (vo->panscan_x >> 1), ctx->drwY - (vo->panscan_y >> 1), + vo->dwidth + vo->panscan_x, + vo->dheight + vo->panscan_y); } } -static void check_events(void) +static void check_events(struct vo *vo) { - int e = vo_x11_check_events(mDisplay); + struct xvctx *ctx = vo->priv; + struct vo_x11_state *x11 = vo->x11; + int e = vo_x11_check_events(vo); if (e & VO_EVENT_RESIZE) { - XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &vo_dwidth, - &vo_dheight, &drwBorderWidth, &drwDepth); - mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, - drwY, vo_dwidth, vo_dheight); - - calc_drwXY(&drwX, &drwY); + Window mRoot; + uint32_t drwBorderWidth, drwDepth; + XGetGeometry(x11->display, x11->window, &mRoot, &ctx->drwX, &ctx->drwY, + &vo->dwidth, &vo->dheight, &drwBorderWidth, &drwDepth); + mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", ctx->drwX, + ctx->drwY, vo->dwidth, vo->dheight); + + calc_drwXY(vo, &ctx->drwX, &ctx->drwY); } if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) { - vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), - drwY - (vo_panscan_y >> 1), - vo_dwidth + vo_panscan_x - 1, - vo_dheight + vo_panscan_y - 1); + vo_xv_draw_colorkey(vo, ctx->drwX - (vo->panscan_x >> 1), + ctx->drwY - (vo->panscan_y >> 1), + vo->dwidth + vo->panscan_x - 1, + vo->dheight + vo->panscan_y - 1); } - 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 ) + if ( ctx->visible_buf != -1 ) { /* redraw the last visible buffer */ - put_xvimage( xvimage[visible_buf] ); + 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; + + 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); } -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) + if (ctx->num_buffers > 1) { - current_buf = - vo_directrendering ? 0 : ((current_buf + 1) % num_buffers); - XFlush(mDisplay); + 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], + 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; @@ -557,95 +554,96 @@ static int draw_slice(uint8_t * image[], int stride[], int w, int h, 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], + 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], + memcpy_pic(dst, image[2], w, h, current_image->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], + 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], + 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[]) { mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_XV_DrawFrameCalled); return -1; } -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; if (mpi->flags & MP_IMGFLAG_DIRECT) { // direct rendering: - current_buf = (int) (mpi->priv); // hack! + ctx->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); + draw_slice(vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); return VO_TRUE; } 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]); + ctx->xvimage[ctx->current_buf]->pitches[0], mpi->stride[0]); return VO_TRUE; } return VO_FALSE; // not (yet) supported } -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! + int buf = ctx->current_buf; // we shouldn't change current_buf unless we do DR! - 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)) { // 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])) + || (mpi->width * (mpi->bpp / 8) == ctx->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]; + 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) { @@ -653,90 +651,103 @@ static uint32_t get_image(mp_image_t * mpi) { // I420 mpi->planes[1] = - xvimage[current_buf]->data + - xvimage[current_buf]->offsets[1]; + current_image->data + + current_image->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]; + 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]; + current_image->data + + current_image->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]; + 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; + mpi->priv = (void *) ctx->current_buf; // printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n"); 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++) + for (i = 0; i < ctx->formats; i++) { - if (fo[i].id == format) + 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->num_buffers; i++) + deallocate_xvimage(vo, i); #ifdef CONFIG_XF86VM - vo_vm_close(mDisplay); + 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 preinit(const char *arg) +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(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; opt_t subopts[] = { /* name arg type arg var test */ - { "port", OPT_ARG_INT, &xv_port, (opt_test_f)int_pos }, + { "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 ) @@ -745,41 +756,42 @@ static int preinit(const char *arg) } /* 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)) + 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); - return -1; + 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++) + for (port_found = 0, i = 0; !port_found && i < ctx->adaptors; i++) { - if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) + if ((ctx->ai[i].type & XvInputMask) && (ctx->ai[i].type & XvImageMask)) { - for (xv_p = ai[i].base_id; - xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) + 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 == xv_port) + if (xv_p == x11->xv_port) { port_found = 1; break; @@ -789,32 +801,32 @@ static int preinit(const char *arg) } if (port_found) { - if (XvGrabPort(mDisplay, xv_port, CurrentTime)) - xv_port = 0; + if (XvGrabPort(x11->display, x11->xv_port, CurrentTime)) + x11->xv_port = 0; } else { mp_msg(MSGT_VO, MSGL_WARN, MSGTR_LIBVO_XV_InvalidPortParameter); - xv_port = 0; + 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)) + + if ((ctx->ai[i].type & XvInputMask) && (ctx->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)) + 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)) { - xv_port = xv_p; + 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 { @@ -824,7 +836,7 @@ static int preinit(const char *arg) } } } - if (!xv_port) + if (!x11->xv_port) { if (busy_ports) mp_msg(MSGT_VO, MSGL_ERR, @@ -832,97 +844,104 @@ static int preinit(const char *arg) else mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_NoXvideoSupport); - return -1; + 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) { + struct xvctx *ctx = vo->priv; + struct vo_x11_state *x11 = vo->x11; switch (request) { case VOCTRL_PAUSE: - return int_pause = 1; + return (ctx->is_paused = 1); case VOCTRL_RESUME: - return int_pause = 0; + return (ctx->is_paused = 0); case VOCTRL_QUERY_FORMAT: - return query_format(*((uint32_t *) data)); + return query_format(ctx, *((uint32_t *) data)); case VOCTRL_GET_IMAGE: - return get_image(data); + return get_image(ctx, data); case VOCTRL_DRAW_IMAGE: - return draw_image(data); + return draw_image(vo, data); case VOCTRL_GUISUPPORT: return VO_TRUE; case VOCTRL_GET_PANSCAN: - if (!vo_config_count || !vo_fs) + if (!vo->config_ok || !vo_fs) return VO_FALSE; return VO_TRUE; case VOCTRL_FULLSCREEN: - vo_x11_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)) + if ((vo_fs && (vo_panscan != vo->panscan_amount)) + || (!vo_fs && vo->panscan_amount)) { - int old_y = vo_panscan_y; + int old_y = vo->panscan_y; - panscan_calc(); + panscan_calc(vo); - if (old_y != vo_panscan_y) + if (old_y != vo->panscan_y) { - vo_x11_clearwindow_part(mDisplay, vo_window, - vo_dwidth + vo_panscan_x - 1, - vo_dheight + vo_panscan_y - 1, + vo_x11_clearwindow_part(vo, x11->window, + vo->dwidth + vo->panscan_x - 1, + vo->dheight + vo->panscan_y - 1, 1); - vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), - drwY - (vo_panscan_y >> 1), - vo_dwidth + vo_panscan_x - 1, - vo_dheight + vo_panscan_y - 1); - flip_page(); + vo_xv_draw_colorkey(vo, ctx->drwX - (vo->panscan_x >> 1), + ctx->drwY - (vo->panscan_y >> 1), + vo->dwidth + vo->panscan_x - 1, + vo->dheight + vo->panscan_y - 1); + flip_page(vo); } } 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(vo, x11->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(vo, x11->xv_port, args->name, args->valueptr); } case VOCTRL_ONTOP: - vo_x11_ontop(); + vo_x11_ontop(vo); return VO_TRUE; case VOCTRL_UPDATE_SCREENINFO: - update_xinerama_info(); + update_xinerama_info(vo); return VO_TRUE; } 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 206f0228a9..7470034f24 100644 --- a/libvo/vo_xvidix.c +++ b/libvo/vo_xvidix.c @@ -464,13 +464,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) { @@ -494,30 +494,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 8e0fbbb15d..dbf5483434 100644 --- a/libvo/vo_xvmc.c +++ b/libvo/vo_xvmc.c @@ -1359,7 +1359,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: @@ -1401,26 +1401,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 29495170dc..433c30290a 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 285846278b..759f0537ec 100644 --- a/libvo/vo_yuv4mpeg.c +++ b/libvo/vo_yuv4mpeg.c @@ -538,7 +538,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 26d868ffd4..3f67d94648 100644 --- a/libvo/vo_zr.c +++ b/libvo/vo_zr.c @@ -814,7 +814,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 362ae49860..c50e95c1bc 100644 --- a/libvo/vo_zr2.c +++ b/libvo/vo_zr2.c @@ -433,7 +433,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 bb53dfb89a..f95cbb60ad 100644 --- a/libvo/vosub_vidix.c +++ b/libvo/vosub_vidix.c @@ -33,6 +33,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" @@ -48,7 +49,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, ...);*/ @@ -85,7 +86,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; @@ -149,7 +150,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; @@ -195,7 +196,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; @@ -212,7 +213,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; @@ -240,7 +241,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; @@ -258,7 +259,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; @@ -565,7 +566,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: @@ -585,36 +586,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; } @@ -624,38 +620,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; @@ -666,7 +658,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 3befcd42e9..708db684f6 100644 --- a/libvo/vosub_vidix.h +++ b/libvo/vosub_vidix.h @@ -16,7 +16,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, @@ -24,7 +24,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 bae8ff3dfe..1346f50a7f 100644 --- a/libvo/w32_common.c +++ b/libvo/w32_common.c @@ -11,6 +11,8 @@ #include "aspect.h" #include "w32_common.h" #include "mp_fifo.h" +// To get "#define vo_ontop global_vo->opts->vo_ontop" etc +#include "old_vo_defines.h" extern int enable_mouse_movements; @@ -21,6 +23,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; @@ -74,7 +77,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l xborder = (r2.right - r2.left) - (r.right - r.left); yborder = (r2.bottom - r2.top) - (r.bottom - r.top); 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; @@ -134,7 +137,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: @@ -231,7 +234,7 @@ static void updateScreenProperties(void) { vo_screenwidth = dm.dmPelsWidth; vo_screenheight = dm.dmPelsHeight; - vo_depthonscreen = dm.dmBitsPerPel; + depthonscreen = dm.dmBitsPerPel; w32_update_xinerama_info(); } @@ -241,7 +244,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; @@ -251,7 +254,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; @@ -341,7 +344,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; @@ -440,7 +443,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 65b88cb307..bb47a4b187 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -5,9 +5,11 @@ #include <inttypes.h> #include "config.h" +#include "options.h" #include "mp_msg.h" #include "mp_fifo.h" #include "x11_common.h" +#include "talloc.h" #ifdef X11_FULLSCREEN @@ -68,57 +70,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 XA_BLACKBOX_PID; -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. @@ -127,12 +98,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; @@ -140,12 +111,12 @@ void vo_x11_ewmh_fullscreen(int action) xev.xclient.type = ClientMessage; xev.xclient.serial = 0; xev.xclient.send_event = True; - xev.xclient.message_type = XInternAtom(mDisplay, + xev.xclient.message_type = XInternAtom(x11->display, "_NET_WM_STATE", False); - xev.xclient.window = vo_window; + xev.xclient.window = x11->window; xev.xclient.format = 32; xev.xclient.data.l[0] = action; - xev.xclient.data.l[1] = XInternAtom(mDisplay, + xev.xclient.data.l[1] = XInternAtom(x11->display, "_NET_WM_STATE_FULLSCREEN", False); xev.xclient.data.l[2] = 0; @@ -153,7 +124,7 @@ void vo_x11_ewmh_fullscreen(int action) 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)) { @@ -162,13 +133,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 @@ -187,7 +158,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; @@ -263,9 +234,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); @@ -274,20 +245,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; @@ -297,12 +270,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; @@ -322,18 +295,18 @@ 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); #if 0 // ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support // (in their implementation it only changes internal window state, nothing more!!!) if (wm & vo_wm_FULLSCREEN) { - if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems)) + if (x11_get_property(x11, x11->XA_BLACKBOX_PID, &args, &nitems)) { mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm is a broken OpenBox.\n"); @@ -349,7 +322,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 +340,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 +367,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 +397,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 +415,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 +470,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 +486,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 +500,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,36 +529,38 @@ 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" #include "wskeys.h" #ifdef XF86XK_AudioPause -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; switch (keysym) { case XF86XK_AudioPause: - mplayer_put_key(KEY_PAUSE); + mplayer_put_key(f, KEY_PAUSE); break; case XF86XK_AudioStop: - mplayer_put_key(KEY_STOP); + mplayer_put_key(f, KEY_STOP); break; case XF86XK_AudioPrev: - mplayer_put_key(KEY_PREV); + mplayer_put_key(f, KEY_PREV); break; case XF86XK_AudioNext: - mplayer_put_key(KEY_NEXT); + mplayer_put_key(f, KEY_NEXT); break; case XF86XK_AudioLowerVolume: - mplayer_put_key(KEY_VOLUME_DOWN); + mplayer_put_key(f, KEY_VOLUME_DOWN); break; case XF86XK_AudioRaiseVolume: - mplayer_put_key(KEY_VOLUME_UP); + mplayer_put_key(f, KEY_VOLUME_UP); break; default: break; @@ -589,248 +568,249 @@ static void vo_x11_putkey_ext(int keysym) } #endif -void vo_x11_putkey(int key) +void vo_x11_putkey(struct vo *vo, int key) { + struct mp_fifo *f = vo->key_fifo; switch (key) { case wsLeft: - mplayer_put_key(KEY_LEFT); + mplayer_put_key(f, KEY_LEFT); break; case wsRight: - mplayer_put_key(KEY_RIGHT); + mplayer_put_key(f, KEY_RIGHT); break; case wsUp: - mplayer_put_key(KEY_UP); + mplayer_put_key(f, KEY_UP); break; case wsDown: - mplayer_put_key(KEY_DOWN); + mplayer_put_key(f, KEY_DOWN); break; case wsSpace: - mplayer_put_key(' '); + mplayer_put_key(f, ' '); break; case wsEscape: - mplayer_put_key(KEY_ESC); + mplayer_put_key(f, KEY_ESC); break; case wsTab: - mplayer_put_key(KEY_TAB); + mplayer_put_key(f, KEY_TAB); break; case wsEnter: - mplayer_put_key(KEY_ENTER); + mplayer_put_key(f, KEY_ENTER); break; case wsBackSpace: - mplayer_put_key(KEY_BS); + mplayer_put_key(f, KEY_BS); break; case wsDelete: - mplayer_put_key(KEY_DELETE); + mplayer_put_key(f, KEY_DELETE); break; case wsInsert: - mplayer_put_key(KEY_INSERT); + mplayer_put_key(f, KEY_INSERT); break; case wsHome: - mplayer_put_key(KEY_HOME); + mplayer_put_key(f, KEY_HOME); break; case wsEnd: - mplayer_put_key(KEY_END); + mplayer_put_key(f, KEY_END); break; case wsPageUp: - mplayer_put_key(KEY_PAGE_UP); + mplayer_put_key(f, KEY_PAGE_UP); break; case wsPageDown: - mplayer_put_key(KEY_PAGE_DOWN); + mplayer_put_key(f, KEY_PAGE_DOWN); break; case wsF1: - mplayer_put_key(KEY_F + 1); + mplayer_put_key(f, KEY_F + 1); break; case wsF2: - mplayer_put_key(KEY_F + 2); + mplayer_put_key(f, KEY_F + 2); break; case wsF3: - mplayer_put_key(KEY_F + 3); + mplayer_put_key(f, KEY_F + 3); break; case wsF4: - mplayer_put_key(KEY_F + 4); + mplayer_put_key(f, KEY_F + 4); break; case wsF5: - mplayer_put_key(KEY_F + 5); + mplayer_put_key(f, KEY_F + 5); break; case wsF6: - mplayer_put_key(KEY_F + 6); + mplayer_put_key(f, KEY_F + 6); break; case wsF7: - mplayer_put_key(KEY_F + 7); + mplayer_put_key(f, KEY_F + 7); break; case wsF8: - mplayer_put_key(KEY_F + 8); + mplayer_put_key(f, KEY_F + 8); break; case wsF9: - mplayer_put_key(KEY_F + 9); + mplayer_put_key(f, KEY_F + 9); break; case wsF10: - mplayer_put_key(KEY_F + 10); + mplayer_put_key(f, KEY_F + 10); break; case wsF11: - mplayer_put_key(KEY_F + 11); + mplayer_put_key(f, KEY_F + 11); break; case wsF12: - mplayer_put_key(KEY_F + 12); + mplayer_put_key(f, KEY_F + 12); break; case wsMinus: case wsGrayMinus: - mplayer_put_key('-'); + mplayer_put_key(f, '-'); break; case wsPlus: case wsGrayPlus: - mplayer_put_key('+'); + mplayer_put_key(f, '+'); break; case wsGrayMul: case wsMul: - mplayer_put_key('*'); + mplayer_put_key(f, '*'); break; case wsGrayDiv: case wsDiv: - mplayer_put_key('/'); + mplayer_put_key(f, '/'); break; case wsLess: - mplayer_put_key('<'); + mplayer_put_key(f, '<'); break; case wsMore: - mplayer_put_key('>'); + mplayer_put_key(f, '>'); break; case wsGray0: - mplayer_put_key(KEY_KP0); + mplayer_put_key(f, KEY_KP0); break; case wsGrayEnd: case wsGray1: - mplayer_put_key(KEY_KP1); + mplayer_put_key(f, KEY_KP1); break; case wsGrayDown: case wsGray2: - mplayer_put_key(KEY_KP2); + mplayer_put_key(f, KEY_KP2); break; case wsGrayPgDn: case wsGray3: - mplayer_put_key(KEY_KP3); + mplayer_put_key(f, KEY_KP3); break; case wsGrayLeft: case wsGray4: - mplayer_put_key(KEY_KP4); + mplayer_put_key(f, KEY_KP4); break; case wsGray5Dup: case wsGray5: - mplayer_put_key(KEY_KP5); + mplayer_put_key(f, KEY_KP5); break; case wsGrayRight: case wsGray6: - mplayer_put_key(KEY_KP6); + mplayer_put_key(f, KEY_KP6); break; case wsGrayHome: case wsGray7: - mplayer_put_key(KEY_KP7); + mplayer_put_key(f, KEY_KP7); break; case wsGrayUp: case wsGray8: - mplayer_put_key(KEY_KP8); + mplayer_put_key(f, KEY_KP8); break; case wsGrayPgUp: case wsGray9: - mplayer_put_key(KEY_KP9); + mplayer_put_key(f, KEY_KP9); break; case wsGrayDecimal: - mplayer_put_key(KEY_KPDEC); + mplayer_put_key(f, KEY_KPDEC); break; case wsGrayInsert: - mplayer_put_key(KEY_KPINS); + mplayer_put_key(f, KEY_KPINS); break; case wsGrayDelete: - mplayer_put_key(KEY_KPDEL); + mplayer_put_key(f, KEY_KPDEL); break; case wsGrayEnter: - mplayer_put_key(KEY_KPENTER); + mplayer_put_key(f, KEY_KPENTER); break; case wsGrave: - mplayer_put_key('`'); + mplayer_put_key(f, '`'); break; case wsTilde: - mplayer_put_key('~'); + mplayer_put_key(f, '~'); break; case wsExclSign: - mplayer_put_key('!'); + mplayer_put_key(f, '!'); break; case wsAt: - mplayer_put_key('@'); + mplayer_put_key(f, '@'); break; case wsHash: - mplayer_put_key('#'); + mplayer_put_key(f, '#'); break; case wsDollar: - mplayer_put_key('$'); + mplayer_put_key(f, '$'); break; case wsPercent: - mplayer_put_key('%'); + mplayer_put_key(f, '%'); break; case wsCircumflex: - mplayer_put_key('^'); + mplayer_put_key(f, '^'); break; case wsAmpersand: - mplayer_put_key('&'); + mplayer_put_key(f, '&'); break; case wsobracket: - mplayer_put_key('('); + mplayer_put_key(f, '('); break; case wscbracket: - mplayer_put_key(')'); + mplayer_put_key(f, ')'); break; case wsUnder: - mplayer_put_key('_'); + mplayer_put_key(f, '_'); break; case wsocbracket: - mplayer_put_key('{'); + mplayer_put_key(f, '{'); break; case wsccbracket: - mplayer_put_key('}'); + mplayer_put_key(f, '}'); break; case wsColon: - mplayer_put_key(':'); + mplayer_put_key(f, ':'); break; case wsSemicolon: - mplayer_put_key(';'); + mplayer_put_key(f, ';'); break; case wsDblQuote: - mplayer_put_key('\"'); + mplayer_put_key(f, '\"'); break; case wsAcute: - mplayer_put_key('\''); + mplayer_put_key(f, '\''); break; case wsComma: - mplayer_put_key(','); + mplayer_put_key(f, ','); break; case wsPoint: - mplayer_put_key('.'); + mplayer_put_key(f, '.'); break; case wsQuestSign: - mplayer_put_key('?'); + mplayer_put_key(f, '?'); break; case wsBSlash: - mplayer_put_key('\\'); + mplayer_put_key(f, '\\'); break; case wsPipe: - mplayer_put_key('|'); + mplayer_put_key(f, '|'); break; case wsEqual: - mplayer_put_key('='); + mplayer_put_key(f, '='); break; case wsosbrackets: - mplayer_put_key('['); + mplayer_put_key(f, '['); break; case wscsbrackets: - mplayer_put_key(']'); + mplayer_put_key(f, ']'); break; default: if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') || (key >= '0' && key <= '9')) - mplayer_put_key(key); + mplayer_put_key(f, key); } } @@ -878,12 +858,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; @@ -893,26 +870,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); } } @@ -922,8 +900,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 = @@ -932,110 +910,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); + XSetClassHint(x11->display, window, &wmClass); + XChangeProperty(x11->display, window, x11->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; -} -#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 @@ -1046,27 +1013,27 @@ 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; - vo_dwidth = Event.xconfigure.width; - vo_dheight = Event.xconfigure.height; + vo->dwidth = Event.xconfigure.width; + vo->dheight = Event.xconfigure.height; #if 0 /* when resizing, x and y are zero :( */ - vo_dx = Event.xconfigure.x; - vo_dy = Event.xconfigure.y; + vo->dx = Event.xconfigure.x; + vo->dy = Event.xconfigure.y; #else { Window root; int foo; Window win; - XGetGeometry(mydisplay, vo_window, &root, &foo, &foo, + XGetGeometry(display, x11->window, &root, &foo, &foo, &foo /*width */ , &foo /*height */ , &foo, &foo); - XTranslateCoordinates(mydisplay, vo_window, root, 0, 0, - &vo_dx, &vo_dy, &win); + XTranslateCoordinates(display, x11->window, root, 0, 0, + &vo->dx, &vo->dy, &win); } #endif ret |= VO_EVENT_RESIZE; @@ -1080,14 +1047,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; @@ -1096,22 +1063,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. @@ -1119,15 +1087,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. @@ -1135,12 +1104,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; @@ -1151,14 +1121,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; } } @@ -1168,62 +1138,65 @@ 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; - 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; @@ -1231,7 +1204,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 @@ -1245,7 +1218,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) @@ -1265,12 +1238,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; } @@ -1291,142 +1264,151 @@ 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) { - if (vo_window == None) { + struct MPOpts *opts = vo->opts; + struct vo_x11_state *x11 = vo->x11; + Display *mDisplay = vo->x11->display; + 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); } -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); @@ -1506,92 +1488,95 @@ static int vo_x11_get_fs_type(int supported) return type; } -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); } /* @@ -1601,19 +1586,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; @@ -1633,13 +1618,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) @@ -1673,14 +1658,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, ¬hing, ¬hing)) @@ -1755,9 +1740,12 @@ void vo_x11_selectinput_witherr(Display * display, Window w, } #ifdef CONFIG_XF86VM -void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width, +void vo_vm_switch(struct vo *vo, uint32_t X, uint32_t Y, int *modeline_width, int *modeline_height) { + 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; @@ -1777,7 +1765,7 @@ void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width, if (have_vm) { if (vidmodes == NULL) - XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, + XF86VidModeGetAllModeLines(mDisplay, x11->screen, &modecount, &vidmodes); j = 0; *modeline_width = vidmodes[0]->hdisplay; @@ -1796,19 +1784,21 @@ void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width, 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]); - X = (vo_screenwidth - *modeline_width) / 2; - Y = (vo_screenheight - *modeline_height) / 2; - XF86VidModeSetViewPort(mDisplay, mScreen, X, Y); + XF86VidModeLockModeSwitch(mDisplay, x11->screen, 0); + XF86VidModeSwitchToMode(mDisplay, x11->screen, vidmodes[j]); + XF86VidModeSwitchToMode(mDisplay, x11->screen, vidmodes[j]); + X = (opts->vo_screenwidth - *modeline_width) / 2; + Y = (opts->vo_screenheight - *modeline_height) / 2; + XF86VidModeSetViewPort(mDisplay, x11->screen, X, Y); } } -void vo_vm_close(Display * dpy) +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 @@ -1820,15 +1810,15 @@ void vo_vm_close(Display * dpy) 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; } @@ -1901,12 +1891,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? */ @@ -1950,8 +1941,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; } @@ -1978,7 +1969,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; @@ -2024,8 +2015,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; } @@ -2045,7 +2036,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; @@ -2053,11 +2044,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) @@ -2108,32 +2099,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; @@ -2181,11 +2172,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. * @@ -2194,20 +2180,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 } } @@ -2221,12 +2208,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; } /** @@ -2240,13 +2228,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 ) { @@ -2277,11 +2266,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; @@ -2295,32 +2284,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; } } @@ -2345,28 +2334,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, @@ -2379,10 +2369,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 { @@ -2393,39 +2383,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 } @@ -2440,14 +2430,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 ); } @@ -2456,24 +2448,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); } } @@ -2518,19 +2510,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 */ @@ -2538,17 +2531,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 7272378f9a..cdced1ebdd 100644 --- a/libvo/x11_common.h +++ b/libvo/x11_common.h @@ -4,6 +4,61 @@ #include <X11/Xlib.h> #include <X11/Xutil.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 XA_BLACKBOX_PID; + Atom XAWM_PROTOCOLS; + Atom XAWM_DELETE_WINDOW; +}; + #ifdef X11_FULLSCREEN #define vo_wm_LAYER 1 @@ -27,66 +82,45 @@ 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; - -extern int vo_init( void ); -extern void vo_uninit( void ); -extern void vo_hidecursor ( Display* , Window ); -extern void vo_showcursor( Display *disp, Window win ); -extern void vo_x11_decoration( Display * vo_Display,Window w,int d ); -extern void vo_x11_classhint( Display * display,Window window,char *name ); -extern void vo_x11_nofs_sizepos(int x, int y, int width, int height); -extern void vo_x11_sizehint( int x, int y, int width, int height, int max ); -extern 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); +extern 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); extern void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask); -extern void vo_x11_fullscreen( void ); -extern void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer ); -extern void vo_x11_uninit(void); -extern Colormap vo_x11_create_colormap(XVisualInfo *vinfo); -extern uint32_t vo_x11_set_equalizer(char *name, int value); +void vo_x11_fullscreen(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); extern uint32_t vo_x11_get_equalizer(char *name, int *value); extern void fstype_help(void); -extern 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); -extern 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); -extern 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); -extern void vo_x11_clearwindow( Display *mDisplay, Window vo_window ); -extern void vo_x11_ontop(void); -extern void vo_x11_border(void); -extern void vo_x11_ewmh_fullscreen( int action ); +void vo_x11_clearwindow(struct vo *vo, Window vo_window); +void vo_x11_ontop(struct vo *vo); +extern 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); -extern int vo_xv_set_eq(uint32_t xv_port, char * name, int value); -extern int vo_xv_get_eq(uint32_t xv_port, char * name, int *value); +int vo_xv_enable_vsync(struct vo *vo); -extern int vo_xv_enable_vsync(void); - -extern 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 @@ -96,31 +130,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; - -extern int vo_xv_init_colorkey(void); -extern void vo_xv_draw_colorkey(int32_t x, int32_t y, int32_t w, int32_t h); -extern 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 - - extern void vo_setwindow( Window w,GC g ); - extern 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(uint32_t, uint32_t, int*, int*); -void vo_vm_close(Display*); +void vo_vm_switch(struct vo *vo, uint32_t, uint32_t, int*, int*); +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_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, __VA_ARGS__) +#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(display) 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 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 vo_mouse_autohide global_vo->x11->vo_mouse_autohide +#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 */ |