From 0fff01f5660fb3bb9284f97c45dc76154435d02b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Sun, 2 Dec 2007 14:15:36 -0500 Subject: [PATCH] Fix swapped Xv dispatch under Xinerama. Same-endian dispatch was properly calling through the Xinerama wrapping, but other-endian dispatch wasn't. --- Xext/xvdisp.c | 910 +++++++++++++++++++++----------------------------- Xext/xvdisp.h | 1 + Xext/xvmain.c | 4 +- 3 files changed, 379 insertions(+), 536 deletions(-) diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index 21d00aa7f..ee2e051d4 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -19,33 +19,8 @@ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ******************************************************************/ -/* -** File: -** -** xvdisp.c --- Xv server extension dispatch module. -** -** Author: -** -** David Carver (Digital Workstation Engineering/Project Athena) -** -** Revisions: -** -** 11.06.91 Carver -** - changed SetPortControl to SetPortAttribute -** - changed GetPortControl to GetPortAttribute -** - changed QueryBestSize -** -** 15.05.91 Carver -** - version 2.0 upgrade -** -** 24.01.91 Carver -** - version 1.4 upgrade -** -*/ - #ifdef HAVE_DIX_CONFIG_H #include #endif @@ -78,81 +53,246 @@ SOFTWARE. #include "panoramiXsrv.h" unsigned long XvXRTPort; - -#ifdef MITSHM -static int XineramaXvShmPutImage(ClientPtr); -#endif -static int XineramaXvPutImage(ClientPtr); -static int XineramaXvPutVideo(ClientPtr); -static int XineramaXvPutStill(ClientPtr); -static int XineramaXvSetPortAttribute(ClientPtr); -static int XineramaXvStopVideo(ClientPtr); #endif -/* INTERNAL */ +static int +SWriteQueryExtensionReply( + ClientPtr client, + xvQueryExtensionReply *rep +){ + char n; -static int ProcXvQueryExtension(ClientPtr); -static int ProcXvQueryAdaptors(ClientPtr); -static int ProcXvQueryEncodings(ClientPtr); -static int ProcXvPutVideo(ClientPtr); -static int ProcXvPutStill(ClientPtr); -static int ProcXvGetVideo(ClientPtr); -static int ProcXvGetStill(ClientPtr); -static int ProcXvGrabPort(ClientPtr); -static int ProcXvUngrabPort(ClientPtr); -static int ProcXvSelectVideoNotify(ClientPtr); -static int ProcXvSelectPortNotify(ClientPtr); -static int ProcXvStopVideo(ClientPtr); -static int ProcXvSetPortAttribute(ClientPtr); -static int ProcXvGetPortAttribute(ClientPtr); -static int ProcXvQueryBestSize(ClientPtr); -static int ProcXvQueryPortAttributes(ClientPtr); -static int ProcXvPutImage(ClientPtr); -#ifdef MITSHM -static int ProcXvShmPutImage(ClientPtr); -#endif -static int ProcXvQueryImageAttributes(ClientPtr); -static int ProcXvListImageFormats(ClientPtr); + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->version, n); + swaps(&rep->revision, n); + + (void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)&rep); -static int SProcXvQueryExtension(ClientPtr); -static int SProcXvQueryAdaptors(ClientPtr); -static int SProcXvQueryEncodings(ClientPtr); -static int SProcXvPutVideo(ClientPtr); -static int SProcXvPutStill(ClientPtr); -static int SProcXvGetVideo(ClientPtr); -static int SProcXvGetStill(ClientPtr); -static int SProcXvGrabPort(ClientPtr); -static int SProcXvUngrabPort(ClientPtr); -static int SProcXvSelectVideoNotify(ClientPtr); -static int SProcXvSelectPortNotify(ClientPtr); -static int SProcXvStopVideo(ClientPtr); -static int SProcXvSetPortAttribute(ClientPtr); -static int SProcXvGetPortAttribute(ClientPtr); -static int SProcXvQueryBestSize(ClientPtr); -static int SProcXvQueryPortAttributes(ClientPtr); -static int SProcXvPutImage(ClientPtr); -#ifdef MITSHM -static int SProcXvShmPutImage(ClientPtr); -#endif -static int SProcXvQueryImageAttributes(ClientPtr); -static int SProcXvListImageFormats(ClientPtr); + return Success; +} -static int SWriteQueryAdaptorsReply(ClientPtr, xvQueryAdaptorsReply *); -static int SWriteQueryExtensionReply(ClientPtr, xvQueryExtensionReply *); -static int SWriteQueryEncodingsReply(ClientPtr, xvQueryEncodingsReply *); -static int SWriteAdaptorInfo(ClientPtr, xvAdaptorInfo *); -static int SWriteEncodingInfo(ClientPtr, xvEncodingInfo *); -static int SWriteFormat(ClientPtr, xvFormat *); -static int SWriteAttributeInfo(ClientPtr, xvAttributeInfo *); -static int SWriteGrabPortReply(ClientPtr, xvGrabPortReply *); -static int SWriteGetPortAttributeReply(ClientPtr, xvGetPortAttributeReply *); -static int SWriteQueryBestSizeReply(ClientPtr, xvQueryBestSizeReply *); -static int SWriteQueryPortAttributesReply( - ClientPtr, xvQueryPortAttributesReply *); -static int SWriteQueryImageAttributesReply( - ClientPtr, xvQueryImageAttributesReply*); -static int SWriteListImageFormatsReply(ClientPtr, xvListImageFormatsReply*); -static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*); +static int +SWriteQueryAdaptorsReply( + ClientPtr client, + xvQueryAdaptorsReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->num_adaptors, n); + + (void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)&rep); + + return Success; +} + +static int +SWriteQueryEncodingsReply( + ClientPtr client, + xvQueryEncodingsReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->num_encodings, n); + + (void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)&rep); + + return Success; +} + +static int +SWriteAdaptorInfo( + ClientPtr client, + xvAdaptorInfo *pAdaptor +){ + char n; + + swapl(&pAdaptor->base_id, n); + swaps(&pAdaptor->name_size, n); + swaps(&pAdaptor->num_ports, n); + swaps(&pAdaptor->num_formats, n); + + (void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor); + + return Success; +} + +static int +SWriteEncodingInfo( + ClientPtr client, + xvEncodingInfo *pEncoding +){ + char n; + + swapl(&pEncoding->encoding, n); + swaps(&pEncoding->name_size, n); + swaps(&pEncoding->width, n); + swaps(&pEncoding->height, n); + swapl(&pEncoding->rate.numerator, n); + swapl(&pEncoding->rate.denominator, n); + (void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding); + + return Success; +} + +static int +SWriteFormat( + ClientPtr client, + xvFormat *pFormat +){ + char n; + + swapl(&pFormat->visual, n); + (void)WriteToClient(client, sz_xvFormat, (char *)pFormat); + + return Success; +} + +static int +SWriteAttributeInfo( + ClientPtr client, + xvAttributeInfo *pAtt +){ + char n; + + swapl(&pAtt->flags, n); + swapl(&pAtt->size, n); + swapl(&pAtt->min, n); + swapl(&pAtt->max, n); + (void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt); + + return Success; +} + +static int +SWriteImageFormatInfo( + ClientPtr client, + xvImageFormatInfo *pImage +){ + char n; + + swapl(&pImage->id, n); + swapl(&pImage->red_mask, n); + swapl(&pImage->green_mask, n); + swapl(&pImage->blue_mask, n); + swapl(&pImage->y_sample_bits, n); + swapl(&pImage->u_sample_bits, n); + swapl(&pImage->v_sample_bits, n); + swapl(&pImage->horz_y_period, n); + swapl(&pImage->horz_u_period, n); + swapl(&pImage->horz_v_period, n); + swapl(&pImage->vert_y_period, n); + swapl(&pImage->vert_u_period, n); + swapl(&pImage->vert_v_period, n); + + (void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage); + + return Success; +} + +static int +SWriteGrabPortReply( + ClientPtr client, + xvGrabPortReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + + (void)WriteToClient(client, sz_xvGrabPortReply, (char *)&rep); + + return Success; +} + +static int +SWriteGetPortAttributeReply( + ClientPtr client, + xvGetPortAttributeReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->value, n); + + (void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)&rep); + + return Success; +} + +static int +SWriteQueryBestSizeReply( + ClientPtr client, + xvQueryBestSizeReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->actual_width, n); + swaps(&rep->actual_height, n); + + (void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)&rep); + + return Success; +} + +static int +SWriteQueryPortAttributesReply( + ClientPtr client, + xvQueryPortAttributesReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->num_attributes, n); + swapl(&rep->text_size, n); + + (void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)&rep); + + return Success; +} + +static int +SWriteQueryImageAttributesReply( + ClientPtr client, + xvQueryImageAttributesReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->num_planes, n); + swapl(&rep->data_size, n); + swaps(&rep->width, n); + swaps(&rep->height, n); + + (void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)&rep); + + return Success; +} + +static int +SWriteListImageFormatsReply( + ClientPtr client, + xvListImageFormatsReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->num_formats, n); + + (void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)&rep); + + return Success; +} #define _WriteQueryAdaptorsReply(_c,_d) \ if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \ @@ -213,141 +353,6 @@ static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*); #define _AllocatePort(_i,_p) \ ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success -/* -** ProcXvDispatch -** -** -** -*/ - -int -ProcXvDispatch(ClientPtr client) -{ - REQUEST(xReq); - - UpdateCurrentTime(); - - switch (stuff->data) - { - case xv_QueryExtension: return(ProcXvQueryExtension(client)); - case xv_QueryAdaptors: return(ProcXvQueryAdaptors(client)); - case xv_QueryEncodings: return(ProcXvQueryEncodings(client)); - case xv_PutVideo: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvPutVideo(client)); - else -#endif - return(ProcXvPutVideo(client)); - case xv_PutStill: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvPutStill(client)); - else -#endif - return(ProcXvPutStill(client)); - case xv_GetVideo: return(ProcXvGetVideo(client)); - case xv_GetStill: return(ProcXvGetStill(client)); - case xv_GrabPort: return(ProcXvGrabPort(client)); - case xv_UngrabPort: return(ProcXvUngrabPort(client)); - case xv_SelectVideoNotify: return(ProcXvSelectVideoNotify(client)); - case xv_SelectPortNotify: return(ProcXvSelectPortNotify(client)); - case xv_StopVideo: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvStopVideo(client)); - else -#endif - return(ProcXvStopVideo(client)); - case xv_SetPortAttribute: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvSetPortAttribute(client)); - else -#endif - return(ProcXvSetPortAttribute(client)); - case xv_GetPortAttribute: return(ProcXvGetPortAttribute(client)); - case xv_QueryBestSize: return(ProcXvQueryBestSize(client)); - case xv_QueryPortAttributes: return(ProcXvQueryPortAttributes(client)); - case xv_PutImage: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvPutImage(client)); - else -#endif - return(ProcXvPutImage(client)); -#ifdef MITSHM - case xv_ShmPutImage: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvShmPutImage(client)); - else -#endif - return(ProcXvShmPutImage(client)); -#endif - case xv_QueryImageAttributes: return(ProcXvQueryImageAttributes(client)); - case xv_ListImageFormats: return(ProcXvListImageFormats(client)); - default: - if (stuff->data < xvNumRequests) - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, - BadImplementation); - return(BadImplementation); - } - else - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return(BadRequest); - } - } -} - -int -SProcXvDispatch(ClientPtr client) -{ - REQUEST(xReq); - - UpdateCurrentTime(); - - switch (stuff->data) - { - case xv_QueryExtension: return(SProcXvQueryExtension(client)); - case xv_QueryAdaptors: return(SProcXvQueryAdaptors(client)); - case xv_QueryEncodings: return(SProcXvQueryEncodings(client)); - case xv_PutVideo: return(SProcXvPutVideo(client)); - case xv_PutStill: return(SProcXvPutStill(client)); - case xv_GetVideo: return(SProcXvGetVideo(client)); - case xv_GetStill: return(SProcXvGetStill(client)); - case xv_GrabPort: return(SProcXvGrabPort(client)); - case xv_UngrabPort: return(SProcXvUngrabPort(client)); - case xv_SelectVideoNotify: return(SProcXvSelectVideoNotify(client)); - case xv_SelectPortNotify: return(SProcXvSelectPortNotify(client)); - case xv_StopVideo: return(SProcXvStopVideo(client)); - case xv_SetPortAttribute: return(SProcXvSetPortAttribute(client)); - case xv_GetPortAttribute: return(SProcXvGetPortAttribute(client)); - case xv_QueryBestSize: return(SProcXvQueryBestSize(client)); - case xv_QueryPortAttributes: return(SProcXvQueryPortAttributes(client)); - case xv_PutImage: return(SProcXvPutImage(client)); -#ifdef MITSHM - case xv_ShmPutImage: return(SProcXvShmPutImage(client)); -#endif - case xv_QueryImageAttributes: return(SProcXvQueryImageAttributes(client)); - case xv_ListImageFormats: return(SProcXvListImageFormats(client)); - default: - if (stuff->data < xvNumRequests) - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, - BadImplementation); - return(BadImplementation); - } - else - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return(BadRequest); - } - } -} - static int ProcXvQueryExtension(ClientPtr client) { @@ -364,7 +369,6 @@ ProcXvQueryExtension(ClientPtr client) _WriteQueryExtensionReply(client, &rep); return Success; - } static int @@ -457,7 +461,6 @@ ProcXvQueryAdaptors(ClientPtr client) } return (client->noClientException); - } static int @@ -521,7 +524,6 @@ ProcXvQueryEncodings(ClientPtr client) } return (client->noClientException); - } static int @@ -567,7 +569,6 @@ ProcXvPutVideo(ClientPtr client) stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, stuff->drw_w, stuff->drw_h); - } static int @@ -613,10 +614,8 @@ ProcXvPutStill(ClientPtr client) stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, stuff->drw_w, stuff->drw_h); - } - static int ProcXvGetVideo(ClientPtr client) { @@ -660,10 +659,8 @@ ProcXvGetVideo(ClientPtr client) stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, stuff->drw_w, stuff->drw_h); - } - static int ProcXvGetStill(ClientPtr client) { @@ -707,7 +704,6 @@ ProcXvGetStill(ClientPtr client) stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, stuff->drw_w, stuff->drw_h); - } static int @@ -723,7 +719,6 @@ ProcXvSelectVideoNotify(ClientPtr client) return rc; return XVCALL(diSelectVideoNotify)(client, pDraw, stuff->onoff); - } static int @@ -747,7 +742,6 @@ ProcXvSelectPortNotify(ClientPtr client) } return XVCALL(diSelectPortNotify)(client, pPort, stuff->onoff); - } static int @@ -786,7 +780,6 @@ ProcXvGrabPort(ClientPtr client) _WriteGrabPortReply(client, &rep); return Success; - } static int @@ -810,10 +803,8 @@ ProcXvUngrabPort(ClientPtr client) } return XVCALL(diUngrabPort)(client, pPort, stuff->time); - } - static int ProcXvStopVideo(ClientPtr client) { @@ -840,7 +831,6 @@ ProcXvStopVideo(ClientPtr client) return rc; return XVCALL(diStopVideo)(client, pPort, pDraw); - } static int @@ -1021,8 +1011,6 @@ ProcXvQueryPortAttributes(ClientPtr client) return Success; } - - static int ProcXvPutImage(ClientPtr client) { @@ -1200,6 +1188,13 @@ ProcXvShmPutImage(ClientPtr client) return status; } +#else /* !MITSHM */ +static int +ProcXvShmPutImage(ClientPtr client) +{ + SendErrorToClient(client, XvReqCode, xv_ShmPutImage, 0, BadImplementation); + return(BadImplementation); +} #endif #ifdef XvMCExtension @@ -1327,65 +1322,101 @@ ProcXvListImageFormats(ClientPtr client) return Success; } +static int (*XvProcVector[xvNumRequests])(ClientPtr) = { + ProcXvQueryExtension, + ProcXvQueryAdaptors, + ProcXvQueryEncodings, + ProcXvGrabPort, + ProcXvUngrabPort, + ProcXvPutVideo, + ProcXvPutStill, + ProcXvGetVideo, + ProcXvGetStill, + ProcXvStopVideo, + ProcXvSelectVideoNotify, + ProcXvSelectPortNotify, + ProcXvQueryBestSize, + ProcXvSetPortAttribute, + ProcXvGetPortAttribute, + ProcXvQueryPortAttributes, + ProcXvListImageFormats, + ProcXvQueryImageAttributes, + ProcXvPutImage, + ProcXvShmPutImage, +}; +int +ProcXvDispatch(ClientPtr client) +{ + REQUEST(xReq); + + UpdateCurrentTime(); + + if (stuff->data > xvNumRequests) { + SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); + return(BadRequest); + } + + return XvProcVector[stuff->data](client); +} /* Swapped Procs */ static int SProcXvQueryExtension(ClientPtr client) { - register char n; + char n; REQUEST(xvQueryExtensionReq); swaps(&stuff->length, n); - return ProcXvQueryExtension(client); + return XvProcVector[xv_QueryExtension](client); } static int SProcXvQueryAdaptors(ClientPtr client) { - register char n; + char n; REQUEST(xvQueryAdaptorsReq); swaps(&stuff->length, n); swapl(&stuff->window, n); - return ProcXvQueryAdaptors(client); + return XvProcVector[xv_QueryAdaptors](client); } static int SProcXvQueryEncodings(ClientPtr client) { - register char n; + char n; REQUEST(xvQueryEncodingsReq); swaps(&stuff->length, n); swapl(&stuff->port, n); - return ProcXvQueryEncodings(client); + return XvProcVector[xv_QueryEncodings](client); } static int SProcXvGrabPort(ClientPtr client) { - register char n; + char n; REQUEST(xvGrabPortReq); swaps(&stuff->length, n); swapl(&stuff->port, n); swapl(&stuff->time, n); - return ProcXvGrabPort(client); + return XvProcVector[xv_GrabPort](client); } static int SProcXvUngrabPort(ClientPtr client) { - register char n; + char n; REQUEST(xvUngrabPortReq); swaps(&stuff->length, n); swapl(&stuff->port, n); swapl(&stuff->time, n); - return ProcXvUngrabPort(client); + return XvProcVector[xv_UngrabPort](client); } static int SProcXvPutVideo(ClientPtr client) { - register char n; + char n; REQUEST(xvPutVideoReq); swaps(&stuff->length, n); swapl(&stuff->port, n); @@ -1399,13 +1430,13 @@ SProcXvPutVideo(ClientPtr client) swaps(&stuff->drw_y, n); swaps(&stuff->drw_w, n); swaps(&stuff->drw_h, n); - return ProcXvPutVideo(client); + return XvProcVector[xv_PutVideo](client); } static int SProcXvPutStill(ClientPtr client) { - register char n; + char n; REQUEST(xvPutStillReq); swaps(&stuff->length, n); swapl(&stuff->port, n); @@ -1419,13 +1450,13 @@ SProcXvPutStill(ClientPtr client) swaps(&stuff->drw_y, n); swaps(&stuff->drw_w, n); swaps(&stuff->drw_h, n); - return ProcXvPutStill(client); + return XvProcVector[xv_PutStill](client); } static int SProcXvGetVideo(ClientPtr client) { - register char n; + char n; REQUEST(xvGetVideoReq); swaps(&stuff->length, n); swapl(&stuff->port, n); @@ -1439,13 +1470,13 @@ SProcXvGetVideo(ClientPtr client) swaps(&stuff->drw_y, n); swaps(&stuff->drw_w, n); swaps(&stuff->drw_h, n); - return ProcXvGetVideo(client); + return XvProcVector[xv_GetVideo](client); } static int SProcXvGetStill(ClientPtr client) { - register char n; + char n; REQUEST(xvGetStillReq); swaps(&stuff->length, n); swapl(&stuff->port, n); @@ -1459,13 +1490,13 @@ SProcXvGetStill(ClientPtr client) swaps(&stuff->drw_y, n); swaps(&stuff->drw_w, n); swaps(&stuff->drw_h, n); - return ProcXvGetStill(client); + return XvProcVector[xv_GetStill](client); } static int SProcXvPutImage(ClientPtr client) { - register char n; + char n; REQUEST(xvPutImageReq); swaps(&stuff->length, n); swapl(&stuff->port, n); @@ -1482,14 +1513,14 @@ SProcXvPutImage(ClientPtr client) swaps(&stuff->drw_h, n); swaps(&stuff->width, n); swaps(&stuff->height, n); - return ProcXvPutImage(client); + return XvProcVector[xv_PutImage](client); } #ifdef MITSHM static int SProcXvShmPutImage(ClientPtr client) { - register char n; + char n; REQUEST(xvShmPutImageReq); swaps(&stuff->length, n); swapl(&stuff->port, n); @@ -1508,68 +1539,69 @@ SProcXvShmPutImage(ClientPtr client) swaps(&stuff->offset, n); swaps(&stuff->width, n); swaps(&stuff->height, n); - return ProcXvShmPutImage(client); + return XvProcVector[xv_ShmPutImage](client); } +#else /* MITSHM */ +#define SProcXvShmPutImage ProcXvShmPutImage #endif - static int SProcXvSelectVideoNotify(ClientPtr client) { - register char n; + char n; REQUEST(xvSelectVideoNotifyReq); swaps(&stuff->length, n); swapl(&stuff->drawable, n); - return ProcXvSelectVideoNotify(client); + return XvProcVector[xv_SelectVideoNotify](client); } static int SProcXvSelectPortNotify(ClientPtr client) { - register char n; + char n; REQUEST(xvSelectPortNotifyReq); swaps(&stuff->length, n); swapl(&stuff->port, n); - return ProcXvSelectPortNotify(client); + return XvProcVector[xv_SelectPortNotify](client); } static int SProcXvStopVideo(ClientPtr client) { - register char n; + char n; REQUEST(xvStopVideoReq); swaps(&stuff->length, n); swapl(&stuff->port, n); swapl(&stuff->drawable, n); - return ProcXvStopVideo(client); + return XvProcVector[xv_StopVideo](client); } static int SProcXvSetPortAttribute(ClientPtr client) { - register char n; + char n; REQUEST(xvSetPortAttributeReq); swaps(&stuff->length, n); swapl(&stuff->port, n); swapl(&stuff->attribute, n); - return ProcXvSetPortAttribute(client); + return XvProcVector[xv_SetPortAttribute](client); } static int SProcXvGetPortAttribute(ClientPtr client) { - register char n; + char n; REQUEST(xvGetPortAttributeReq); swaps(&stuff->length, n); swapl(&stuff->port, n); swapl(&stuff->attribute, n); - return ProcXvGetPortAttribute(client); + return XvProcVector[xv_GetPortAttribute](client); } static int SProcXvQueryBestSize(ClientPtr client) { - register char n; + char n; REQUEST(xvQueryBestSizeReq); swaps(&stuff->length, n); swapl(&stuff->port, n); @@ -1577,290 +1609,80 @@ SProcXvQueryBestSize(ClientPtr client) swaps(&stuff->vid_h, n); swaps(&stuff->drw_w, n); swaps(&stuff->drw_h, n); - return ProcXvQueryBestSize(client); + return XvProcVector[xv_QueryBestSize](client); } static int SProcXvQueryPortAttributes(ClientPtr client) { - register char n; + char n; REQUEST(xvQueryPortAttributesReq); swaps(&stuff->length, n); swapl(&stuff->port, n); - return ProcXvQueryPortAttributes(client); + return XvProcVector[xv_QueryPortAttributes](client); } static int SProcXvQueryImageAttributes(ClientPtr client) { - register char n; + char n; REQUEST(xvQueryImageAttributesReq); swaps(&stuff->length, n); swapl(&stuff->id, n); swaps(&stuff->width, n); swaps(&stuff->width, n); - return ProcXvQueryImageAttributes(client); + return XvProcVector[xv_QueryImageAttributes](client); } static int SProcXvListImageFormats(ClientPtr client) { - register char n; + char n; REQUEST(xvListImageFormatsReq); swaps(&stuff->length, n); swapl(&stuff->port, n); - return ProcXvListImageFormats(client); + return XvProcVector[xv_ListImageFormats](client); } +static int (*SXvProcVector[xvNumRequests])(ClientPtr) = { + SProcXvQueryExtension, + SProcXvQueryAdaptors, + SProcXvQueryEncodings, + SProcXvGrabPort, + SProcXvUngrabPort, + SProcXvPutVideo, + SProcXvPutStill, + SProcXvGetVideo, + SProcXvGetStill, + SProcXvStopVideo, + SProcXvSelectVideoNotify, + SProcXvSelectPortNotify, + SProcXvQueryBestSize, + SProcXvSetPortAttribute, + SProcXvGetPortAttribute, + SProcXvQueryPortAttributes, + SProcXvListImageFormats, + SProcXvQueryImageAttributes, + SProcXvPutImage, + SProcXvShmPutImage, +}; -static int -SWriteQueryExtensionReply( - ClientPtr client, - xvQueryExtensionReply *rep -){ - register char n; +int +SProcXvDispatch(ClientPtr client) +{ + REQUEST(xReq); - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->version, n); - swaps(&rep->revision, n); - - (void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)&rep); + UpdateCurrentTime(); - return Success; + if (stuff->data > xvNumRequests) { + SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); + return(BadRequest); + } + + return SXvProcVector[stuff->data](client); } -static int -SWriteQueryAdaptorsReply( - ClientPtr client, - xvQueryAdaptorsReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->num_adaptors, n); - - (void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryEncodingsReply( - ClientPtr client, - xvQueryEncodingsReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->num_encodings, n); - - (void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)&rep); - - return Success; -} - -static int -SWriteAdaptorInfo( - ClientPtr client, - xvAdaptorInfo *pAdaptor -){ - register char n; - - swapl(&pAdaptor->base_id, n); - swaps(&pAdaptor->name_size, n); - swaps(&pAdaptor->num_ports, n); - swaps(&pAdaptor->num_formats, n); - - (void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor); - - return Success; -} - -static int -SWriteEncodingInfo( - ClientPtr client, - xvEncodingInfo *pEncoding -){ - register char n; - - swapl(&pEncoding->encoding, n); - swaps(&pEncoding->name_size, n); - swaps(&pEncoding->width, n); - swaps(&pEncoding->height, n); - swapl(&pEncoding->rate.numerator, n); - swapl(&pEncoding->rate.denominator, n); - (void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding); - - return Success; -} - -static int -SWriteFormat( - ClientPtr client, - xvFormat *pFormat -){ - register char n; - - swapl(&pFormat->visual, n); - (void)WriteToClient(client, sz_xvFormat, (char *)pFormat); - - return Success; -} - -static int -SWriteAttributeInfo( - ClientPtr client, - xvAttributeInfo *pAtt -){ - register char n; - - swapl(&pAtt->flags, n); - swapl(&pAtt->size, n); - swapl(&pAtt->min, n); - swapl(&pAtt->max, n); - (void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt); - - return Success; -} - -static int -SWriteImageFormatInfo( - ClientPtr client, - xvImageFormatInfo *pImage -){ - register char n; - - swapl(&pImage->id, n); - swapl(&pImage->red_mask, n); - swapl(&pImage->green_mask, n); - swapl(&pImage->blue_mask, n); - swapl(&pImage->y_sample_bits, n); - swapl(&pImage->u_sample_bits, n); - swapl(&pImage->v_sample_bits, n); - swapl(&pImage->horz_y_period, n); - swapl(&pImage->horz_u_period, n); - swapl(&pImage->horz_v_period, n); - swapl(&pImage->vert_y_period, n); - swapl(&pImage->vert_u_period, n); - swapl(&pImage->vert_v_period, n); - - (void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage); - - return Success; -} - - - -static int -SWriteGrabPortReply( - ClientPtr client, - xvGrabPortReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - - (void)WriteToClient(client, sz_xvGrabPortReply, (char *)&rep); - - return Success; -} - -static int -SWriteGetPortAttributeReply( - ClientPtr client, - xvGetPortAttributeReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->value, n); - - (void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryBestSizeReply( - ClientPtr client, - xvQueryBestSizeReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->actual_width, n); - swaps(&rep->actual_height, n); - - (void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryPortAttributesReply( - ClientPtr client, - xvQueryPortAttributesReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_attributes, n); - swapl(&rep->text_size, n); - - (void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryImageAttributesReply( - ClientPtr client, - xvQueryImageAttributesReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_planes, n); - swapl(&rep->data_size, n); - swaps(&rep->width, n); - swaps(&rep->height, n); - - (void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)&rep); - - return Success; -} - - -static int -SWriteListImageFormatsReply( - ClientPtr client, - xvListImageFormatsReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_formats, n); - - (void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)&rep); - - return Success; -} - - #ifdef PANORAMIX - - - - static int XineramaXvStopVideo(ClientPtr client) { @@ -1910,7 +1732,6 @@ XineramaXvSetPortAttribute(ClientPtr client) return result; } - #ifdef MITSHM static int XineramaXvShmPutImage(ClientPtr client) @@ -1958,6 +1779,8 @@ XineramaXvShmPutImage(ClientPtr client) } return result; } +#else +#define XineramaXvShmPutImage ProcXvShmPutImage #endif static int @@ -2095,7 +1918,6 @@ XineramaXvPutStill(ClientPtr client) return result; } - void XineramifyXv(void) { ScreenPtr pScreen, screen0 = screenInfo.screens[0]; @@ -2201,6 +2023,26 @@ void XineramifyXv(void) } } } -} + /* munge the dispatch vector */ + XvProcVector[xv_PutVideo] = XineramaXvPutVideo; + XvProcVector[xv_PutStill] = XineramaXvPutStill; + XvProcVector[xv_StopVideo] = XineramaXvStopVideo; + XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute; + XvProcVector[xv_PutImage] = XineramaXvPutImage; + XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage; +} +#endif /* PANORAMIX */ + +void +XvResetProcVector(void) +{ +#ifdef PANORAMIX + XvProcVector[xv_PutVideo] = ProcXvPutVideo; + XvProcVector[xv_PutStill] = ProcXvPutStill; + XvProcVector[xv_StopVideo] = ProcXvStopVideo; + XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute; + XvProcVector[xv_PutImage] = ProcXvPutImage; + XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage; #endif +} diff --git a/Xext/xvdisp.h b/Xext/xvdisp.h index 75cacddcc..298d39560 100644 --- a/Xext/xvdisp.h +++ b/Xext/xvdisp.h @@ -1 +1,2 @@ extern void XineramifyXv(void); +extern void XvResetProcVector(void); diff --git a/Xext/xvmain.c b/Xext/xvmain.c index ddf3d1d6b..1b80bc8da 100644 --- a/Xext/xvmain.c +++ b/Xext/xvmain.c @@ -102,8 +102,8 @@ SOFTWARE. #ifdef PANORAMIX #include "panoramiX.h" #include "panoramiXsrv.h" -#include "xvdisp.h" #endif +#include "xvdisp.h" int XvScreenIndex = -1; unsigned long XvExtensionGeneration = 0; @@ -326,12 +326,12 @@ XvCloseScreen( pScreen->devPrivates[XvScreenIndex].ptr = (pointer)NULL; return (*pScreen->CloseScreen)(ii, pScreen); - } static void XvResetProc(ExtensionEntry* extEntry) { + XvResetProcVector(); } _X_EXPORT int