comparison src/video/x11/SDL_x11yuv.c @ 950:b7a5c1b64829

Date: Tue, 24 Aug 2004 06:16:32 +0200 From: Christian Biere Subject: [SDL] YUV Overlay vs. XV_AUTOPAINT_COLORKEY I have a problem with SDL's YUV Overlay support using X11 Xv. Some people reported that they get nothing but a black screen. I've compared the output of xvattr they've sent me with the values I get here. It turned out that XV_AUTOPAINT_COLORKEY was disabled. By enabling this feature everything works fine.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 25 Aug 2004 05:39:03 +0000
parents 6a2c6717b386
children 045f186426e1
comparison
equal deleted inserted replaced
949:e0d96eb0af19 950:b7a5c1b64829
71 #endif 71 #endif
72 SDL_NAME(XvImage) *image; 72 SDL_NAME(XvImage) *image;
73 }; 73 };
74 74
75 75
76 static int (*X_handler)(Display *, XErrorEvent *) = NULL;
77
76 #ifndef NO_SHARED_MEMORY 78 #ifndef NO_SHARED_MEMORY
77 /* Shared memory error handler routine */ 79 /* Shared memory error handler routine */
78 static int shm_error; 80 static int shm_error;
79 static int (*X_handler)(Display *, XErrorEvent *) = NULL;
80 static int shm_errhandler(Display *d, XErrorEvent *e) 81 static int shm_errhandler(Display *d, XErrorEvent *e)
81 { 82 {
82 if ( e->error_code == BadAccess ) { 83 if ( e->error_code == BadAccess ) {
83 shm_error = True; 84 shm_error = True;
84 return(0); 85 return(0);
85 } else 86 } else
86 return(X_handler(d,e)); 87 return(X_handler(d,e));
87 } 88 }
88 #endif /* !NO_SHARED_MEMORY */ 89 #endif /* !NO_SHARED_MEMORY */
89 90
91 static int xv_error;
92 static int xv_errhandler(Display *d, XErrorEvent *e)
93 {
94 if ( e->error_code == BadMatch ) {
95 xv_error = True;
96 return(0);
97 } else
98 return(X_handler(d,e));
99 }
90 100
91 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) 101 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
92 { 102 {
93 SDL_Overlay *overlay; 103 SDL_Overlay *overlay;
94 struct private_yuvhwdata *hwdata; 104 struct private_yuvhwdata *hwdata;
190 if ( xv_port == -1 ) { 200 if ( xv_port == -1 ) {
191 SDL_SetError("No available video ports for requested format"); 201 SDL_SetError("No available video ports for requested format");
192 return(NULL); 202 return(NULL);
193 } 203 }
194 204
205 /* Enable auto-painting of the overlay colorkey */
206 {
207 static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" };
208 unsigned int i;
209
210 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True);
211 X_handler = XSetErrorHandler(xv_errhandler);
212 for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) {
213 Atom a;
214
215 xv_error = False;
216 a = XInternAtom(GFX_Display, attr[i], True);
217 if ( a != None ) {
218 SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1);
219 XSync(GFX_Display, True);
220 if ( ! xv_error ) {
221 break;
222 }
223 }
224 }
225 XSetErrorHandler(X_handler);
226 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False);
227 }
228
195 /* Create the overlay structure */ 229 /* Create the overlay structure */
196 overlay = (SDL_Overlay *)malloc(sizeof *overlay); 230 overlay = (SDL_Overlay *)malloc(sizeof *overlay);
197 if ( overlay == NULL ) { 231 if ( overlay == NULL ) {
198 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); 232 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime);
199 SDL_OutOfMemory(); 233 SDL_OutOfMemory();