File: | XvMC.c |
Location: | line 510, column 5 |
Description: | Value stored to 'magic' is never read |
1 | #ifdef HAVE_CONFIG_H1 |
2 | #include <config.h> |
3 | #endif |
4 | #include <stdio.h> |
5 | #include "XvMClibint.h" |
6 | #ifdef HAVE_SHMAT1 |
7 | #ifndef Lynx |
8 | #include <sys/ipc.h> |
9 | #include <sys/shm.h> |
10 | #else |
11 | #include <ipc.h> |
12 | #include <shm.h> |
13 | #endif /* Lynx */ |
14 | #endif /* HAVE_SHMAT */ |
15 | #include <unistd.h> |
16 | #include <sys/time.h> |
17 | #include <X11/extensions/Xext.h> |
18 | #include <X11/extensions/extutil.h> |
19 | #include <limits.h> |
20 | |
21 | static XExtensionInfo _xvmc_info_data; |
22 | static XExtensionInfo *xvmc_info = &_xvmc_info_data; |
23 | static const char *xvmc_extension_name = XvMCName"XVideo-MotionCompensation"; |
24 | |
25 | static const char *xvmc_error_list[] = |
26 | { |
27 | "BadContext", |
28 | "BadSurface", |
29 | "BadSubpicture" |
30 | }; |
31 | |
32 | static XEXT_GENERATE_CLOSE_DISPLAY (xvmc_close_display, xvmc_info)int xvmc_close_display (Display *dpy, XExtCodes *codes) { return XextRemoveDisplay (xvmc_info, dpy); } |
33 | |
34 | |
35 | static XEXT_GENERATE_ERROR_STRING (xvmc_error_string, xvmc_extension_name,char *xvmc_error_string (Display *dpy, int code, XExtCodes *codes , char *buf, int n) { code -= codes->first_error; if (code >= 0 && code < 3) { char tmp[256]; __builtin___snprintf_chk (tmp, sizeof(tmp), 0, __builtin_object_size (tmp, 2 > 1 ? 1 : 0), "%s.%d", xvmc_extension_name, code); XGetErrorDatabaseText (dpy, "XProtoError", tmp, xvmc_error_list[code], buf, n); return buf; } return (char *)0; } |
36 | XvMCNumErrors, xvmc_error_list)char *xvmc_error_string (Display *dpy, int code, XExtCodes *codes , char *buf, int n) { code -= codes->first_error; if (code >= 0 && code < 3) { char tmp[256]; __builtin___snprintf_chk (tmp, sizeof(tmp), 0, __builtin_object_size (tmp, 2 > 1 ? 1 : 0), "%s.%d", xvmc_extension_name, code); XGetErrorDatabaseText (dpy, "XProtoError", tmp, xvmc_error_list[code], buf, n); return buf; } return (char *)0; } |
37 | |
38 | |
39 | static XExtensionHooks xvmc_extension_hooks = { |
40 | NULL((void*)0), /* create_gc */ |
41 | NULL((void*)0), /* copy_gc */ |
42 | NULL((void*)0), /* flush_gc */ |
43 | NULL((void*)0), /* free_gc */ |
44 | NULL((void*)0), /* create_font */ |
45 | NULL((void*)0), /* free_font */ |
46 | xvmc_close_display, /* close_display */ |
47 | NULL((void*)0), /* wire_to_event */ |
48 | NULL((void*)0), /* event_to_wire */ |
49 | NULL((void*)0), /* error */ |
50 | xvmc_error_string /* error_string */ |
51 | }; |
52 | |
53 | static XEXT_GENERATE_FIND_DISPLAY (xvmc_find_display, xvmc_info,XExtDisplayInfo *xvmc_find_display (Display *dpy) { XExtDisplayInfo *dpyinfo; if (!xvmc_info) { if (!(xvmc_info = XextCreateExtension ())) return ((void*)0); } if (!(dpyinfo = XextFindDisplay (xvmc_info , dpy))) dpyinfo = XextAddDisplay (xvmc_info,dpy,xvmc_extension_name ,&xvmc_extension_hooks,0,((void*)0)); return dpyinfo; } |
54 | xvmc_extension_name,XExtDisplayInfo *xvmc_find_display (Display *dpy) { XExtDisplayInfo *dpyinfo; if (!xvmc_info) { if (!(xvmc_info = XextCreateExtension ())) return ((void*)0); } if (!(dpyinfo = XextFindDisplay (xvmc_info , dpy))) dpyinfo = XextAddDisplay (xvmc_info,dpy,xvmc_extension_name ,&xvmc_extension_hooks,0,((void*)0)); return dpyinfo; } |
55 | &xvmc_extension_hooks,XExtDisplayInfo *xvmc_find_display (Display *dpy) { XExtDisplayInfo *dpyinfo; if (!xvmc_info) { if (!(xvmc_info = XextCreateExtension ())) return ((void*)0); } if (!(dpyinfo = XextFindDisplay (xvmc_info , dpy))) dpyinfo = XextAddDisplay (xvmc_info,dpy,xvmc_extension_name ,&xvmc_extension_hooks,0,((void*)0)); return dpyinfo; } |
56 | XvMCNumEvents, NULL)XExtDisplayInfo *xvmc_find_display (Display *dpy) { XExtDisplayInfo *dpyinfo; if (!xvmc_info) { if (!(xvmc_info = XextCreateExtension ())) return ((void*)0); } if (!(dpyinfo = XextFindDisplay (xvmc_info , dpy))) dpyinfo = XextAddDisplay (xvmc_info,dpy,xvmc_extension_name ,&xvmc_extension_hooks,0,((void*)0)); return dpyinfo; } |
57 | |
58 | Boolint XvMCQueryExtension (Display *dpy, int *event_basep, int *error_basep) |
59 | { |
60 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
61 | |
62 | if (XextHasExtension(info)((info) && ((info)->codes))) { |
63 | *event_basep = info->codes->first_event; |
64 | *error_basep = info->codes->first_error; |
65 | return True1; |
66 | } else { |
67 | return False0; |
68 | } |
69 | } |
70 | |
71 | Statusint XvMCQueryVersion (Display *dpy, int *major, int *minor) |
72 | { |
73 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
74 | xvmcQueryVersionReply rep; |
75 | xvmcQueryVersionReq *req; |
76 | |
77 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
78 | |
79 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
80 | XvMCGetReq (QueryVersion, req)if ((dpy->bufptr + sizeof(xvmcQueryVersionReq)) > dpy-> bufmax) _XFlush(dpy); req = (xvmcQueryVersionReq *)(dpy->last_req = dpy->bufptr); req->reqType = info->codes->major_opcode ; req->xvmcReqType = 0; req->length = sizeof(xvmcQueryVersionReq )>>2; dpy->bufptr += sizeof(xvmcQueryVersionReq); dpy ->request++; |
81 | if (!_XReply (dpy, (xReply *) &rep, 0, xTrue1)) { |
82 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
83 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
84 | return BadImplementation17; |
85 | } |
86 | *major = rep.major; |
87 | *minor = rep.minor; |
88 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
89 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
90 | return Success0; |
91 | } |
92 | |
93 | |
94 | XvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num) |
95 | { |
96 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
97 | xvmcListSurfaceTypesReply rep; |
98 | xvmcListSurfaceTypesReq *req; |
99 | XvMCSurfaceInfo *surface_info = NULL((void*)0); |
100 | |
101 | *num = 0; |
102 | |
103 | XvMCCheckExtension (dpy, info, NULL)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return ((void*)0); }; |
104 | |
105 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
106 | XvMCGetReq (ListSurfaceTypes, req)if ((dpy->bufptr + sizeof(xvmcListSurfaceTypesReq)) > dpy ->bufmax) _XFlush(dpy); req = (xvmcListSurfaceTypesReq *)( dpy->last_req = dpy->bufptr); req->reqType = info-> codes->major_opcode; req->xvmcReqType = 1; req->length = sizeof(xvmcListSurfaceTypesReq)>>2; dpy->bufptr += sizeof(xvmcListSurfaceTypesReq); dpy->request++; |
107 | req->port = port; |
108 | if (!_XReply (dpy, (xReply *) &rep, 0, xFalse0)) { |
109 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
110 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
111 | return NULL((void*)0); |
112 | } |
113 | |
114 | if(rep.num > 0) { |
115 | if (rep.num < (INT_MAX2147483647 / sizeof(XvMCSurfaceInfo))) |
116 | surface_info = Xmalloc(rep.num * sizeof(XvMCSurfaceInfo))malloc(((rep.num * sizeof(XvMCSurfaceInfo)) == 0 ? 1 : (rep.num * sizeof(XvMCSurfaceInfo)))); |
117 | |
118 | if(surface_info) { |
119 | xvmcSurfaceInfo sinfo; |
120 | int i; |
121 | |
122 | *num = rep.num; |
123 | |
124 | for(i = 0; i < rep.num; i++) { |
125 | _XRead(dpy, (char*)&sinfo, sizeof(xvmcSurfaceInfo)); |
126 | surface_info[i].surface_type_id = sinfo.surface_type_id; |
127 | surface_info[i].chroma_format = sinfo.chroma_format; |
128 | surface_info[i].max_width = sinfo.max_width; |
129 | surface_info[i].max_height = sinfo.max_height; |
130 | surface_info[i].subpicture_max_width = |
131 | sinfo.subpicture_max_width; |
132 | surface_info[i].subpicture_max_height = |
133 | sinfo.subpicture_max_height; |
134 | surface_info[i].mc_type = sinfo.mc_type; |
135 | surface_info[i].flags = sinfo.flags; |
136 | } |
137 | } else |
138 | _XEatDataWords(dpy, rep.length); |
139 | } |
140 | |
141 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
142 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
143 | return surface_info; |
144 | } |
145 | |
146 | |
147 | XvImageFormatValues * XvMCListSubpictureTypes ( |
148 | Display * dpy, |
149 | XvPortID port, |
150 | int surface_type_id, |
151 | int *count_return |
152 | ) |
153 | { |
154 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
155 | xvmcListSubpictureTypesReply rep; |
156 | xvmcListSubpictureTypesReq *req; |
157 | XvImageFormatValues *ret = NULL((void*)0); |
158 | |
159 | |
160 | *count_return = 0; |
161 | |
162 | XvMCCheckExtension (dpy, info, NULL)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return ((void*)0); }; |
163 | |
164 | |
165 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
166 | XvMCGetReq (ListSubpictureTypes, req)if ((dpy->bufptr + sizeof(xvmcListSubpictureTypesReq)) > dpy->bufmax) _XFlush(dpy); req = (xvmcListSubpictureTypesReq *)(dpy->last_req = dpy->bufptr); req->reqType = info ->codes->major_opcode; req->xvmcReqType = 8; req-> length = sizeof(xvmcListSubpictureTypesReq)>>2; dpy-> bufptr += sizeof(xvmcListSubpictureTypesReq); dpy->request ++; |
167 | req->port = port; |
168 | req->surface_type_id = surface_type_id; |
169 | if (!_XReply (dpy, (xReply *) &rep, 0, xFalse0)) { |
170 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
171 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
172 | return NULL((void*)0); |
173 | } |
174 | |
175 | if(rep.num > 0) { |
176 | if (rep.num < (INT_MAX2147483647 / sizeof(XvImageFormatValues))) |
177 | ret = Xmalloc(rep.num * sizeof(XvImageFormatValues))malloc(((rep.num * sizeof(XvImageFormatValues)) == 0 ? 1 : (rep .num * sizeof(XvImageFormatValues)))); |
178 | |
179 | if(ret) { |
180 | xvImageFormatInfo Info; |
181 | int i; |
182 | |
183 | *count_return = rep.num; |
184 | |
185 | for(i = 0; i < rep.num; i++) { |
186 | _XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo128); |
187 | ret[i].id = Info.id; |
188 | ret[i].type = Info.type; |
189 | ret[i].byte_order = Info.byte_order; |
190 | memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16)__builtin___memcpy_chk (&(ret[i].guid[0]), &(Info.guid [0]), 16, __builtin_object_size (&(ret[i].guid[0]), 0)); |
191 | ret[i].bits_per_pixel = Info.bpp; |
192 | ret[i].format = Info.format; |
193 | ret[i].num_planes = Info.num_planes; |
194 | ret[i].depth = Info.depth; |
195 | ret[i].red_mask = Info.red_mask; |
196 | ret[i].green_mask = Info.green_mask; |
197 | ret[i].blue_mask = Info.blue_mask; |
198 | ret[i].y_sample_bits = Info.y_sample_bits; |
199 | ret[i].u_sample_bits = Info.u_sample_bits; |
200 | ret[i].v_sample_bits = Info.v_sample_bits; |
201 | ret[i].horz_y_period = Info.horz_y_period; |
202 | ret[i].horz_u_period = Info.horz_u_period; |
203 | ret[i].horz_v_period = Info.horz_v_period; |
204 | ret[i].vert_y_period = Info.vert_y_period; |
205 | ret[i].vert_u_period = Info.vert_u_period; |
206 | ret[i].vert_v_period = Info.vert_v_period; |
207 | memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32)__builtin___memcpy_chk (&(ret[i].component_order[0]), & (Info.comp_order[0]), 32, __builtin_object_size (&(ret[i] .component_order[0]), 0)); |
208 | ret[i].scanline_order = Info.scanline_order; |
209 | } |
210 | } else |
211 | _XEatDataWords(dpy, rep.length); |
212 | } |
213 | |
214 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
215 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
216 | return ret; |
217 | } |
218 | |
219 | |
220 | /****************************************************************** |
221 | These are intended as a protocol interface to be used by direct |
222 | rendering libraries. They are not intended to be client viewable |
223 | functions. These will stay in place until we have a mechanism in |
224 | place similar to that of OpenGL with an libXvMCcore library. |
225 | *******************************************************************/ |
226 | |
227 | /* |
228 | _xvmc_create_context - |
229 | |
230 | Pass in the context with the surface_type_id, width, height, |
231 | port and flags filled out. This function will fill out the |
232 | context_id and update the width, height and flags field. |
233 | The server may return implementation-specific information |
234 | back in the priv_data. The size of that information will |
235 | an array of priv_count CARD32s. This data is allocated by |
236 | this function. If returned, the caller is responsible for |
237 | freeing it! Generally, such information is only returned if |
238 | an XVMC_DIRECT context was specified. |
239 | */ |
240 | |
241 | |
242 | Statusint _xvmc_create_context ( |
243 | Display *dpy, |
244 | XvMCContext *context, |
245 | int *priv_count, |
246 | CARD32 **priv_data |
247 | ) |
248 | { |
249 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
250 | xvmcCreateContextReply rep; |
251 | xvmcCreateContextReq *req; |
252 | |
253 | *priv_count = 0; |
254 | *priv_data = NULL((void*)0); |
255 | |
256 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
257 | |
258 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
259 | XvMCGetReq (CreateContext, req)if ((dpy->bufptr + sizeof(xvmcCreateContextReq)) > dpy-> bufmax) _XFlush(dpy); req = (xvmcCreateContextReq *)(dpy-> last_req = dpy->bufptr); req->reqType = info->codes-> major_opcode; req->xvmcReqType = 2; req->length = sizeof (xvmcCreateContextReq)>>2; dpy->bufptr += sizeof(xvmcCreateContextReq ); dpy->request++; |
260 | context->context_id = XAllocID(dpy)((*((_XPrivDisplay)(dpy))->resource_alloc)((dpy))); |
261 | req->context_id = context->context_id; |
262 | req->port = context->port; |
263 | req->surface_type_id = context->surface_type_id; |
264 | req->width = context->width; |
265 | req->height = context->height; |
266 | req->flags = context->flags; |
267 | if (!_XReply (dpy, (xReply *) &rep, 0, xFalse0)) { |
268 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
269 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
270 | return BadImplementation17; |
271 | } |
272 | context->width = rep.width_actual; |
273 | context->height = rep.height_actual; |
274 | context->flags = rep.flags_return; |
275 | |
276 | if(rep.length) { |
277 | if (rep.length < (INT_MAX2147483647 >> 2)) |
278 | *priv_data = Xmalloc(rep.length << 2)malloc(((rep.length << 2) == 0 ? 1 : (rep.length << 2))); |
279 | if(*priv_data) { |
280 | _XRead(dpy, (char*)(*priv_data), rep.length << 2); |
281 | *priv_count = rep.length; |
282 | } else |
283 | _XEatDataWords(dpy, rep.length); |
284 | } |
285 | |
286 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
287 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
288 | return Success0; |
289 | } |
290 | |
291 | Statusint _xvmc_destroy_context ( |
292 | Display *dpy, |
293 | XvMCContext *context |
294 | ) |
295 | { |
296 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
297 | xvmcDestroyContextReq *req; |
298 | |
299 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
300 | |
301 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
302 | XvMCGetReq (DestroyContext, req)if ((dpy->bufptr + sizeof(xvmcDestroyContextReq)) > dpy ->bufmax) _XFlush(dpy); req = (xvmcDestroyContextReq *)(dpy ->last_req = dpy->bufptr); req->reqType = info->codes ->major_opcode; req->xvmcReqType = 3; req->length = sizeof (xvmcDestroyContextReq)>>2; dpy->bufptr += sizeof(xvmcDestroyContextReq ); dpy->request++; |
303 | req->context_id = context->context_id; |
304 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
305 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
306 | return Success0; |
307 | } |
308 | |
309 | |
310 | /* |
311 | _xvmc_create_surface - |
312 | |
313 | Pass the context and this function will fill out all the |
314 | information in the surface. |
315 | The server may return implementation-specific information |
316 | back in the priv_data. The size of that information will |
317 | an array of priv_count CARD32s. This data is allocated by |
318 | this function. If returned, the caller is responsible for |
319 | freeing it! Generally, such information is returned only if |
320 | the context was a direct context. |
321 | |
322 | */ |
323 | |
324 | Statusint _xvmc_create_surface ( |
325 | Display *dpy, |
326 | XvMCContext *context, |
327 | XvMCSurface *surface, |
328 | int *priv_count, |
329 | CARD32 **priv_data |
330 | ) |
331 | { |
332 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
333 | xvmcCreateSurfaceReply rep; |
334 | xvmcCreateSurfaceReq *req; |
335 | |
336 | *priv_count = 0; |
337 | *priv_data = NULL((void*)0); |
338 | |
339 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
340 | |
341 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
342 | XvMCGetReq (CreateSurface, req)if ((dpy->bufptr + sizeof(xvmcCreateSurfaceReq)) > dpy-> bufmax) _XFlush(dpy); req = (xvmcCreateSurfaceReq *)(dpy-> last_req = dpy->bufptr); req->reqType = info->codes-> major_opcode; req->xvmcReqType = 4; req->length = sizeof (xvmcCreateSurfaceReq)>>2; dpy->bufptr += sizeof(xvmcCreateSurfaceReq ); dpy->request++; |
343 | |
344 | surface->surface_id = XAllocID(dpy)((*((_XPrivDisplay)(dpy))->resource_alloc)((dpy))); |
345 | surface->context_id = context->context_id; |
346 | surface->surface_type_id = context->surface_type_id; |
347 | surface->width = context->width; |
348 | surface->height = context->height; |
349 | |
350 | req->surface_id = surface->surface_id; |
351 | req->context_id = surface->context_id; |
352 | if (!_XReply (dpy, (xReply *) &rep, 0, xFalse0)) { |
353 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
354 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
355 | return BadImplementation17; |
356 | } |
357 | |
358 | if(rep.length) { |
359 | if (rep.length < (INT_MAX2147483647 >> 2)) |
360 | *priv_data = Xmalloc(rep.length << 2)malloc(((rep.length << 2) == 0 ? 1 : (rep.length << 2))); |
361 | if(*priv_data) { |
362 | _XRead(dpy, (char*)(*priv_data), rep.length << 2); |
363 | *priv_count = rep.length; |
364 | } else |
365 | _XEatDataWords(dpy, rep.length); |
366 | } |
367 | |
368 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
369 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
370 | return Success0; |
371 | } |
372 | |
373 | Statusint _xvmc_destroy_surface ( |
374 | Display *dpy, |
375 | XvMCSurface *surface |
376 | ) |
377 | { |
378 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
379 | xvmcDestroySurfaceReq *req; |
380 | |
381 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
382 | |
383 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
384 | XvMCGetReq (DestroySurface, req)if ((dpy->bufptr + sizeof(xvmcDestroySurfaceReq)) > dpy ->bufmax) _XFlush(dpy); req = (xvmcDestroySurfaceReq *)(dpy ->last_req = dpy->bufptr); req->reqType = info->codes ->major_opcode; req->xvmcReqType = 5; req->length = sizeof (xvmcDestroySurfaceReq)>>2; dpy->bufptr += sizeof(xvmcDestroySurfaceReq ); dpy->request++; |
385 | req->surface_id = surface->surface_id; |
386 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
387 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
388 | return Success0; |
389 | } |
390 | |
391 | /* |
392 | _xvmc_create_subpicture - |
393 | |
394 | Pass the subpicture with the width, height and xvimage_id filled |
395 | out and this function will fill out everything else in the |
396 | subpicture as well as adjust the width and height if needed. |
397 | The server may return implementation-specific information |
398 | back in the priv_data. The size of that information will |
399 | an array of priv_count CARD32s. This data is allocated by |
400 | this function. If returned, the caller is responsible for |
401 | freeing it! Generally, such information is returned only if |
402 | the context was a direct context. |
403 | |
404 | */ |
405 | |
406 | Statusint _xvmc_create_subpicture ( |
407 | Display *dpy, |
408 | XvMCContext *context, |
409 | XvMCSubpicture *subpicture, |
410 | int *priv_count, |
411 | CARD32 **priv_data |
412 | ) |
413 | { |
414 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
415 | xvmcCreateSubpictureReply rep; |
416 | xvmcCreateSubpictureReq *req; |
417 | |
418 | *priv_count = 0; |
419 | *priv_data = NULL((void*)0); |
420 | |
421 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
422 | |
423 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
424 | XvMCGetReq (CreateSubpicture, req)if ((dpy->bufptr + sizeof(xvmcCreateSubpictureReq)) > dpy ->bufmax) _XFlush(dpy); req = (xvmcCreateSubpictureReq *)( dpy->last_req = dpy->bufptr); req->reqType = info-> codes->major_opcode; req->xvmcReqType = 6; req->length = sizeof(xvmcCreateSubpictureReq)>>2; dpy->bufptr += sizeof(xvmcCreateSubpictureReq); dpy->request++; |
425 | |
426 | subpicture->subpicture_id = XAllocID(dpy)((*((_XPrivDisplay)(dpy))->resource_alloc)((dpy))); |
427 | subpicture->context_id = context->context_id; |
428 | |
429 | req->subpicture_id = subpicture->subpicture_id; |
430 | req->context_id = subpicture->context_id; |
431 | req->xvimage_id = subpicture->xvimage_id; |
432 | req->width = subpicture->width; |
433 | req->height = subpicture->height; |
434 | if (!_XReply (dpy, (xReply *) &rep, 0, xFalse0)) { |
435 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
436 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
437 | return BadImplementation17; |
438 | } |
439 | |
440 | subpicture->width = rep.width_actual; |
441 | subpicture->height = rep.height_actual; |
442 | subpicture->num_palette_entries = rep.num_palette_entries; |
443 | subpicture->entry_bytes = rep.entry_bytes; |
444 | subpicture->component_order[0] = rep.component_order[0]; |
445 | subpicture->component_order[1] = rep.component_order[1]; |
446 | subpicture->component_order[2] = rep.component_order[2]; |
447 | subpicture->component_order[3] = rep.component_order[3]; |
448 | |
449 | if(rep.length) { |
450 | if (rep.length < (INT_MAX2147483647 >> 2)) |
451 | *priv_data = Xmalloc(rep.length << 2)malloc(((rep.length << 2) == 0 ? 1 : (rep.length << 2))); |
452 | if(*priv_data) { |
453 | _XRead(dpy, (char*)(*priv_data), rep.length << 2); |
454 | *priv_count = rep.length; |
455 | } else |
456 | _XEatDataWords(dpy, rep.length); |
457 | } |
458 | |
459 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
460 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
461 | return Success0; |
462 | } |
463 | |
464 | Statusint _xvmc_destroy_subpicture( |
465 | Display *dpy, |
466 | XvMCSubpicture *subpicture |
467 | ) |
468 | { |
469 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
470 | xvmcDestroySubpictureReq *req; |
471 | |
472 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
473 | |
474 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
475 | XvMCGetReq (DestroySubpicture, req)if ((dpy->bufptr + sizeof(xvmcDestroySubpictureReq)) > dpy ->bufmax) _XFlush(dpy); req = (xvmcDestroySubpictureReq *) (dpy->last_req = dpy->bufptr); req->reqType = info-> codes->major_opcode; req->xvmcReqType = 7; req->length = sizeof(xvmcDestroySubpictureReq)>>2; dpy->bufptr += sizeof(xvmcDestroySubpictureReq); dpy->request++; |
476 | req->subpicture_id = subpicture->subpicture_id; |
477 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
478 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
479 | return Success0; |
480 | } |
481 | |
482 | Statusint XvMCGetDRInfo(Display *dpy, XvPortID port, |
483 | char **name, char **busID, |
484 | int *major, int *minor, |
485 | int *patchLevel, |
486 | int *isLocal) |
487 | { |
488 | XExtDisplayInfo *info = xvmc_find_display(dpy); |
489 | xvmcGetDRInfoReply rep; |
490 | xvmcGetDRInfoReq *req; |
491 | CARD32 magic; |
492 | |
493 | #ifdef HAVE_SHMAT1 |
494 | volatile CARD32 *shMem; |
495 | struct timezone here; |
496 | struct timeval now; |
497 | here.tz_minuteswest = 0; |
498 | here.tz_dsttime = 0; |
499 | #endif |
500 | |
501 | *name = NULL((void*)0); |
502 | *busID = NULL((void*)0); |
503 | |
504 | XvMCCheckExtension (dpy, info, BadImplementation)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, xvmc_extension_name); return 17; }; |
505 | |
506 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
507 | XvMCGetReq (GetDRInfo, req)if ((dpy->bufptr + sizeof(xvmcGetDRInfoReq)) > dpy-> bufmax) _XFlush(dpy); req = (xvmcGetDRInfoReq *)(dpy->last_req = dpy->bufptr); req->reqType = info->codes->major_opcode ; req->xvmcReqType = 9; req->length = sizeof(xvmcGetDRInfoReq )>>2; dpy->bufptr += sizeof(xvmcGetDRInfoReq); dpy-> request++; |
508 | |
509 | req->port = port; |
510 | magic = 0; |
Value stored to 'magic' is never read | |
511 | req->magic = 0; |
512 | #ifdef HAVE_SHMAT1 |
513 | req->shmKey = shmget(IPC_PRIVATE((key_t)0), 1024, IPC_CREAT001000 | 0600); |
514 | |
515 | /* |
516 | * We fill a shared memory page with a repetitive pattern. If the |
517 | * X server can read this pattern, we probably have a local connection. |
518 | * Note that we can trigger the remote X server to read any shared |
519 | * page on the remote machine, so we shouldn't be able to guess and verify |
520 | * any complicated data on those pages. Thats the explanation of this |
521 | * otherwise stupid-looking pattern algorithm. |
522 | */ |
523 | |
524 | if (req->shmKey >= 0) { |
525 | shMem = (CARD32 *) shmat(req->shmKey, NULL((void*)0), 0); |
526 | shmctl( req->shmKey, IPC_RMID0, NULL((void*)0)); |
527 | if ( shMem ) { |
528 | |
529 | register volatile CARD32 *shMemC = shMem; |
530 | register int i; |
531 | |
532 | gettimeofday( &now, &here); |
533 | magic = now.tv_usec & 0x000FFFFF; |
534 | req->magic = magic; |
535 | i = 1024 / sizeof(CARD32); |
536 | while(i--) { |
537 | *shMemC++ = magic; |
538 | magic = ~magic; |
539 | } |
540 | } else { |
541 | req->shmKey = -1; |
542 | } |
543 | } |
544 | #else |
545 | req->shmKey = 0; |
546 | #endif |
547 | if (!_XReply (dpy, (xReply *) &rep, 0, xFalse0)) { |
548 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
549 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
550 | #ifdef HAVE_SHMAT1 |
551 | if ( req->shmKey >= 0) { |
552 | shmdt( (const void *) shMem ); |
553 | } |
554 | #endif |
555 | return -1; |
556 | } |
557 | #ifdef HAVE_SHMAT1 |
558 | shmdt( (const void *) shMem ); |
559 | #endif |
560 | |
561 | if (rep.length > 0) { |
562 | unsigned long realSize = 0; |
563 | char *tmpBuf = NULL((void*)0); |
564 | |
565 | if ((rep.length < (INT_MAX2147483647 >> 2)) && |
566 | /* protect against overflow in strncpy below */ |
567 | (rep.nameLen + rep.busIDLen > rep.nameLen)) { |
568 | realSize = rep.length << 2; |
569 | if (realSize >= (rep.nameLen + rep.busIDLen)) { |
570 | tmpBuf = Xmalloc(realSize)malloc(((realSize) == 0 ? 1 : (realSize))); |
571 | *name = Xmalloc(rep.nameLen)malloc(((rep.nameLen) == 0 ? 1 : (rep.nameLen))); |
572 | *busID = Xmalloc(rep.busIDLen)malloc(((rep.busIDLen) == 0 ? 1 : (rep.busIDLen))); |
573 | } |
574 | } |
575 | |
576 | if (*name && *busID && tmpBuf) { |
577 | _XRead(dpy, tmpBuf, realSize); |
578 | strncpy(*name,tmpBuf,rep.nameLen)__builtin___strncpy_chk (*name, tmpBuf, rep.nameLen, __builtin_object_size (*name, 2 > 1 ? 1 : 0)); |
579 | (*name)[rep.nameLen - 1] = '\0'; |
580 | strncpy(*busID,tmpBuf+rep.nameLen,rep.busIDLen)__builtin___strncpy_chk (*busID, tmpBuf+rep.nameLen, rep.busIDLen , __builtin_object_size (*busID, 2 > 1 ? 1 : 0)); |
581 | (*busID)[rep.busIDLen - 1] = '\0'; |
582 | XFree(tmpBuf); |
583 | } else { |
584 | XFree(*name); |
585 | *name = NULL((void*)0); |
586 | XFree(*busID); |
587 | *busID = NULL((void*)0); |
588 | XFree(tmpBuf); |
589 | |
590 | _XEatDataWords(dpy, rep.length); |
591 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
592 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
593 | return -1; |
594 | |
595 | } |
596 | } |
597 | |
598 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
599 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
600 | *major = rep.major; |
601 | *minor = rep.minor; |
602 | *patchLevel = rep.patchLevel; |
603 | *isLocal = (req->shmKey > 0) ? rep.isLocal : 1; |
604 | return (rep.length > 0) ? Success0 : BadImplementation17; |
605 | } |
606 |