Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11yuv.c @ 1168:045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
This allows you to run an SDL program on a system without Xlib, since it'll
just report the x11 target unavailable at runtime.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 05 Nov 2005 19:53:37 +0000 |
parents | b7a5c1b64829 |
children | b81f54c3963f |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
659
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
182
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* This is the XFree86 Xv extension implementation of YUV video overlays */ | |
29 | |
30 #ifdef XFREE86_XV | |
31 | |
32 #include <stdlib.h> | |
33 #include <string.h> | |
34 #include <X11/Xlib.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
35 #ifndef NO_SHARED_MEMORY |
0 | 36 #include <sys/ipc.h> |
37 #include <sys/shm.h> | |
38 #include <X11/extensions/XShm.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
39 #endif |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
40 #include <XFree86/extensions/Xvlib.h> |
0 | 41 |
42 #include "SDL_error.h" | |
43 #include "SDL_video.h" | |
44 #include "SDL_x11yuv_c.h" | |
45 #include "SDL_yuvfuncs.h" | |
46 | |
47 #define XFREE86_REFRESH_HACK | |
48 #ifdef XFREE86_REFRESH_HACK | |
49 #include "SDL_x11image_c.h" | |
50 #endif | |
51 | |
52 /* Workaround when pitch != width */ | |
53 #define PITCH_WORKAROUND | |
54 | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
55 /* Fix for the NVidia GeForce 2 - use the last available adaptor */ |
341
6ca967a46bf1
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
56 /*#define USE_LAST_ADAPTOR*/ /* Apparently the NVidia drivers are fixed */ |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
57 |
0 | 58 /* The functions used to manipulate software video overlays */ |
59 static struct private_yuvhwfuncs x11_yuvfuncs = { | |
60 X11_LockYUVOverlay, | |
61 X11_UnlockYUVOverlay, | |
62 X11_DisplayYUVOverlay, | |
63 X11_FreeYUVOverlay | |
64 }; | |
65 | |
66 struct private_yuvhwdata { | |
67 int port; | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
68 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
69 int yuv_use_mitshm; |
0 | 70 XShmSegmentInfo yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
71 #endif |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
72 SDL_NAME(XvImage) *image; |
0 | 73 }; |
74 | |
75 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
76 static int (*X_handler)(Display *, XErrorEvent *) = NULL; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
77 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
78 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
79 /* Shared memory error handler routine */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
80 static int shm_error; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
81 static int shm_errhandler(Display *d, XErrorEvent *e) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
82 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
83 if ( e->error_code == BadAccess ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
84 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
85 return(0); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
86 } else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
87 return(X_handler(d,e)); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
88 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
89 #endif /* !NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
90 |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
91 static int xv_error; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
92 static int xv_errhandler(Display *d, XErrorEvent *e) |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
93 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
94 if ( e->error_code == BadMatch ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
95 xv_error = True; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
96 return(0); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
97 } else |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
98 return(X_handler(d,e)); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
99 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
100 |
0 | 101 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) |
102 { | |
103 SDL_Overlay *overlay; | |
104 struct private_yuvhwdata *hwdata; | |
105 int xv_port; | |
106 int i, j, k; | |
107 int adaptors; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
108 SDL_NAME(XvAdaptorInfo) *ainfo; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
109 int bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
110 #ifndef NO_SHARED_MEMORY |
0 | 111 XShmSegmentInfo *yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
112 #endif |
0 | 113 |
114 /* Look for the XVideo extension with a valid port for this format */ | |
115 xv_port = -1; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
116 if ( (Success == SDL_NAME(XvQueryExtension)(GFX_Display, &j, &j, &j, &j, &j)) && |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
117 (Success == SDL_NAME(XvQueryAdaptors)(GFX_Display, |
0 | 118 RootWindow(GFX_Display, SDL_Screen), |
119 &adaptors, &ainfo)) ) { | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
120 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
121 for ( i=0; i < adaptors; ++i ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
122 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
123 for ( i=0; (i < adaptors) && (xv_port == -1); ++i ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
124 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
125 { |
0 | 126 /* Check to see if the visual can be used */ |
127 if ( BUGGY_XFREE86(<=, 4001) ) { | |
128 int visual_ok = 0; | |
129 for ( j=0; j<ainfo[i].num_formats; ++j ) { | |
130 if ( ainfo[i].formats[j].visual_id == | |
131 SDL_Visual->visualid ) { | |
132 visual_ok = 1; | |
133 break; | |
134 } | |
135 } | |
136 if ( ! visual_ok ) { | |
137 continue; | |
138 } | |
139 } | |
140 if ( (ainfo[i].type & XvInputMask) && | |
141 (ainfo[i].type & XvImageMask) ) { | |
142 int num_formats; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
143 SDL_NAME(XvImageFormatValues) *formats; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
144 formats = SDL_NAME(XvListImageFormats)(GFX_Display, |
0 | 145 ainfo[i].base_id, &num_formats); |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
146 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
147 for ( j=0; j < num_formats; ++j ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
148 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
149 for ( j=0; (j < num_formats) && (xv_port == -1); ++j ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
150 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
151 { |
0 | 152 if ( (Uint32)formats[j].id == format ) { |
153 for ( k=0; k < ainfo[i].num_ports; ++k ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
154 if ( Success == SDL_NAME(XvGrabPort)(GFX_Display, ainfo[i].base_id+k, CurrentTime) ) { |
0 | 155 xv_port = ainfo[i].base_id+k; |
156 break; | |
157 } | |
158 } | |
159 } | |
160 } | |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
161 if ( formats ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
162 pXFree(formats); |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
163 } |
0 | 164 } |
165 } | |
409
1c3cf7231cd4
Fixed memory leaks in YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
341
diff
changeset
|
166 SDL_NAME(XvFreeAdaptorInfo)(ainfo); |
0 | 167 } |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
168 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
169 /* Precalculate the bpp for the pitch workaround below */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
170 switch (format) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
171 /* Add any other cases we need to support... */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
172 case SDL_YUY2_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
173 case SDL_UYVY_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
174 case SDL_YVYU_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
175 bpp = 2; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
176 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
177 default: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
178 bpp = 1; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
179 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
180 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
181 |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
182 #if 0 |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
183 /* |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
184 * !!! FIXME: |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
185 * "Here are some diffs for X11 and yuv. Note that the last part 2nd |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
186 * diff should probably be a new call to XvQueryAdaptorFree with ainfo |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
187 * and the number of adaptors, instead of the loop through like I did." |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
188 * |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
189 * ACHTUNG: This is broken! It looks like XvFreeAdaptorInfo does this |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
190 * for you, so we end up with a double-free. I need to look at this |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
191 * more closely... --ryan. |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
192 */ |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
193 for ( i=0; i < adaptors; ++i ) { |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
194 if (ainfo[i].name != NULL) Xfree(ainfo[i].name); |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
195 if (ainfo[i].formats != NULL) Xfree(ainfo[i].formats); |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
196 } |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
197 Xfree(ainfo); |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
198 #endif |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
199 |
0 | 200 if ( xv_port == -1 ) { |
201 SDL_SetError("No available video ports for requested format"); | |
202 return(NULL); | |
203 } | |
204 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
205 /* Enable auto-painting of the overlay colorkey */ |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
206 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
207 static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
208 unsigned int i; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
209 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
210 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
211 X_handler = pXSetErrorHandler(xv_errhandler); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
212 for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
213 Atom a; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
214 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
215 xv_error = False; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
216 a = pXInternAtom(GFX_Display, attr[i], True); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
217 if ( a != None ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
218 SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
219 pXSync(GFX_Display, True); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
220 if ( ! xv_error ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
221 break; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
222 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
223 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
224 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
225 pXSetErrorHandler(X_handler); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
226 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
227 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
228 |
0 | 229 /* Create the overlay structure */ |
230 overlay = (SDL_Overlay *)malloc(sizeof *overlay); | |
231 if ( overlay == NULL ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
232 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 233 SDL_OutOfMemory(); |
234 return(NULL); | |
235 } | |
236 memset(overlay, 0, (sizeof *overlay)); | |
237 | |
238 /* Fill in the basic members */ | |
239 overlay->format = format; | |
240 overlay->w = width; | |
241 overlay->h = height; | |
242 | |
243 /* Set up the YUV surface function structure */ | |
244 overlay->hwfuncs = &x11_yuvfuncs; | |
245 overlay->hw_overlay = 1; | |
246 | |
247 /* Create the pixel data and lookup tables */ | |
248 hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata); | |
249 overlay->hwdata = hwdata; | |
250 if ( hwdata == NULL ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
251 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 252 SDL_OutOfMemory(); |
253 SDL_FreeYUVOverlay(overlay); | |
254 return(NULL); | |
255 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
256 hwdata->port = xv_port; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
257 #ifndef NO_SHARED_MEMORY |
0 | 258 yuvshm = &hwdata->yuvshm; |
259 memset(yuvshm, 0, sizeof(*yuvshm)); | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
260 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
261 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
262 #ifdef PITCH_WORKAROUND |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
263 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
264 /* Ajust overlay width according to pitch */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
265 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
266 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
267 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
268 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
269 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
270 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
271 hwdata->yuv_use_mitshm = (hwdata->image != NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
272 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
273 yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
274 IPC_CREAT | 0777); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
275 if ( yuvshm->shmid >= 0 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
276 yuvshm->shmaddr = (char *)shmat(yuvshm->shmid, 0, 0); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
277 yuvshm->readOnly = False; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
278 if ( yuvshm->shmaddr != (char *)-1 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
279 shm_error = False; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
280 X_handler = pXSetErrorHandler(shm_errhandler); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
281 pXShmAttach(GFX_Display, yuvshm); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
282 pXSync(GFX_Display, True); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
283 pXSetErrorHandler(X_handler); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
284 if ( shm_error ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
285 shmdt(yuvshm->shmaddr); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
286 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
287 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
288 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
289 shmctl(yuvshm->shmid, IPC_RMID, NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
290 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
291 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
292 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
293 if ( shm_error ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
294 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
295 hwdata->yuv_use_mitshm = 0; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
296 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
297 hwdata->image->data = yuvshm->shmaddr; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
298 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
299 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
300 if ( !hwdata->yuv_use_mitshm ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
301 #endif /* NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
302 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
303 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
304 0, width, height); |
0 | 305 |
306 #ifdef PITCH_WORKAROUND | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
307 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
308 /* Ajust overlay width according to pitch */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
309 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
310 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
311 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
312 0, width, height); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
313 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
314 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
315 if ( hwdata->image == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
316 SDL_SetError("Couldn't create XVideo image"); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
317 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
318 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
319 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
320 hwdata->image->data = malloc(hwdata->image->data_size); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
321 if ( hwdata->image->data == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
322 SDL_OutOfMemory(); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
323 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
324 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
325 } |
0 | 326 } |
327 | |
328 /* Find the pitch and offset values for the overlay */ | |
329 overlay->planes = hwdata->image->num_planes; | |
330 overlay->pitches = (Uint16 *)malloc(overlay->planes * sizeof(Uint16)); | |
331 overlay->pixels = (Uint8 **)malloc(overlay->planes * sizeof(Uint8 *)); | |
332 if ( !overlay->pitches || !overlay->pixels ) { | |
333 SDL_OutOfMemory(); | |
334 SDL_FreeYUVOverlay(overlay); | |
335 return(NULL); | |
336 } | |
337 for ( i=0; i<overlay->planes; ++i ) { | |
338 overlay->pitches[i] = hwdata->image->pitches[i]; | |
339 overlay->pixels[i] = (Uint8 *)hwdata->image->data + | |
340 hwdata->image->offsets[i]; | |
341 } | |
342 | |
343 #ifdef XFREE86_REFRESH_HACK | |
344 /* Work around an XFree86 X server bug (?) | |
345 We can't perform normal updates in windows that have video | |
346 being output to them. See SDL_x11image.c for more details. | |
347 */ | |
348 X11_DisableAutoRefresh(this); | |
349 #endif | |
350 | |
351 /* We're all done.. */ | |
352 return(overlay); | |
353 } | |
354 | |
355 int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
356 { | |
357 return(0); | |
358 } | |
359 | |
360 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
361 { | |
362 return; | |
363 } | |
364 | |
365 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) | |
366 { | |
367 struct private_yuvhwdata *hwdata; | |
368 | |
369 hwdata = overlay->hwdata; | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
370 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
371 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
372 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
0 | 373 hwdata->image, 0, 0, overlay->w, overlay->h, |
374 dstrect->x, dstrect->y, dstrect->w, dstrect->h, False); | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
375 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
376 else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
377 #endif |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
378 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
379 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
380 hwdata->image, 0, 0, overlay->w, overlay->h, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
381 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
382 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
383 pXSync(GFX_Display, False); |
0 | 384 return(0); |
385 } | |
386 | |
387 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) | |
388 { | |
389 struct private_yuvhwdata *hwdata; | |
390 | |
391 hwdata = overlay->hwdata; | |
392 if ( hwdata ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
393 SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
394 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
395 if ( hwdata->yuv_use_mitshm ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
396 pXShmDetach(GFX_Display, &hwdata->yuvshm); |
0 | 397 shmdt(hwdata->yuvshm.shmaddr); |
398 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
399 #endif |
0 | 400 if ( hwdata->image ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
401 pXFree(hwdata->image); |
0 | 402 } |
403 free(hwdata); | |
404 } | |
405 if ( overlay->pitches ) { | |
406 free(overlay->pitches); | |
407 overlay->pitches = NULL; | |
408 } | |
409 if ( overlay->pixels ) { | |
410 free(overlay->pixels); | |
411 overlay->pixels = NULL; | |
412 } | |
413 #ifdef XFREE86_REFRESH_HACK | |
414 X11_EnableAutoRefresh(this); | |
415 #endif | |
416 } | |
417 | |
418 #endif /* XFREE86_XV */ |