From fc3b95012e426e9d32f1e00c4e00543023139c2a Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 8 Jul 2024 20:39:16 +0200 Subject: [PATCH] (submit/cleanup-xv-dispatch) Xext: xv: simplify dispatcher These dispatcher functions are much more complex than they're usually are (just switch/case statement). Bring them in line with the standard scheme used in the Xserver, so further steps become easier. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/xvdisp.c | 172 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 67 deletions(-) diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index 009eb081e..796403f26 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -1134,26 +1134,6 @@ 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) { @@ -1161,11 +1141,50 @@ ProcXvDispatch(ClientPtr client) UpdateCurrentTime(); - if (stuff->data >= xvNumRequests) { - return BadRequest; + switch (stuff->data) { + case xv_QueryExtension: + return ProcXvQueryExtension(client); + case xv_QueryAdaptors: + return ProcXvQueryAdaptors(client); + case xv_QueryEncodings: + return ProcXvQueryEncodings(client); + case xv_GrabPort: + return ProcXvGrabPort(client); + case xv_UngrabPort: + return ProcXvUngrabPort(client); + case xv_PutVideo: + return ProcXvPutVideo(client); + case xv_PutStill: + return ProcXvPutStill(client); + case xv_GetVideo: + return ProcXvGetVideo(client); + case xv_GetStill: + return ProcXvGetStill(client); + case xv_StopVideo: + return ProcXvStopVideo(client); + case xv_SelectVideoNotify: + return ProcXvSelectVideoNotify(client); + case xv_SelectPortNotify: + return ProcXvSelectPortNotify(client); + case xv_QueryBestSize: + return ProcXvQueryBestSize(client); + case xv_SetPortAttribute: + return ProcXvSetPortAttribute(client); + case xv_GetPortAttribute: + return ProcXvGetPortAttribute(client); + case xv_QueryPortAttributes: + return ProcXvQueryPortAttributes(client); + case xv_ListImageFormats: + return ProcXvListImageFormats(client); + case xv_QueryImageAttributes: + return ProcXvQueryImageAttributes(client); + case xv_PutImage: + return ProcXvPutImage(client); + case xv_ShmPutImage: + return ProcXvShmPutImage(client); + default: + return BadRequest; } - - return XvProcVector[stuff->data] (client); } /* Swapped Procs */ @@ -1176,7 +1195,7 @@ SProcXvQueryAdaptors(ClientPtr client) REQUEST(xvQueryAdaptorsReq); REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); swapl(&stuff->window); - return XvProcVector[xv_QueryAdaptors] (client); + return ProcXvQueryAdaptors(client); } static int _X_COLD @@ -1185,7 +1204,7 @@ SProcXvQueryEncodings(ClientPtr client) REQUEST(xvQueryEncodingsReq); REQUEST_SIZE_MATCH(xvQueryEncodingsReq); swapl(&stuff->port); - return XvProcVector[xv_QueryEncodings] (client); + return ProcXvQueryEncodings(client); } static int _X_COLD @@ -1195,7 +1214,7 @@ SProcXvGrabPort(ClientPtr client) REQUEST_SIZE_MATCH(xvGrabPortReq); swapl(&stuff->port); swapl(&stuff->time); - return XvProcVector[xv_GrabPort] (client); + return ProcXvGrabPort(client); } static int _X_COLD @@ -1205,7 +1224,7 @@ SProcXvUngrabPort(ClientPtr client) REQUEST_SIZE_MATCH(xvUngrabPortReq); swapl(&stuff->port); swapl(&stuff->time); - return XvProcVector[xv_UngrabPort] (client); + return ProcXvUngrabPort(client); } static int _X_COLD @@ -1224,7 +1243,7 @@ SProcXvPutVideo(ClientPtr client) swaps(&stuff->drw_y); swaps(&stuff->drw_w); swaps(&stuff->drw_h); - return XvProcVector[xv_PutVideo] (client); + return ProcXvPutVideo(client); } static int _X_COLD @@ -1243,7 +1262,7 @@ SProcXvPutStill(ClientPtr client) swaps(&stuff->drw_y); swaps(&stuff->drw_w); swaps(&stuff->drw_h); - return XvProcVector[xv_PutStill] (client); + return ProcXvPutStill(client); } static int _X_COLD @@ -1262,7 +1281,7 @@ SProcXvGetVideo(ClientPtr client) swaps(&stuff->drw_y); swaps(&stuff->drw_w); swaps(&stuff->drw_h); - return XvProcVector[xv_GetVideo] (client); + return ProcXvGetVideo(client); } static int _X_COLD @@ -1281,7 +1300,7 @@ SProcXvGetStill(ClientPtr client) swaps(&stuff->drw_y); swaps(&stuff->drw_w); swaps(&stuff->drw_h); - return XvProcVector[xv_GetStill] (client); + return ProcXvGetStill(client); } static int _X_COLD @@ -1303,7 +1322,7 @@ SProcXvPutImage(ClientPtr client) swaps(&stuff->drw_h); swaps(&stuff->width); swaps(&stuff->height); - return XvProcVector[xv_PutImage] (client); + return ProcXvPutImage(client); } #ifdef MITSHM @@ -1328,7 +1347,7 @@ SProcXvShmPutImage(ClientPtr client) swaps(&stuff->drw_h); swaps(&stuff->width); swaps(&stuff->height); - return XvProcVector[xv_ShmPutImage] (client); + return ProcXvShmPutImage(client); } #else /* MITSHM */ #define SProcXvShmPutImage ProcXvShmPutImage @@ -1340,7 +1359,7 @@ SProcXvSelectVideoNotify(ClientPtr client) REQUEST(xvSelectVideoNotifyReq); REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); swapl(&stuff->drawable); - return XvProcVector[xv_SelectVideoNotify] (client); + return ProcXvSelectVideoNotify(client); } static int _X_COLD @@ -1349,7 +1368,7 @@ SProcXvSelectPortNotify(ClientPtr client) REQUEST(xvSelectPortNotifyReq); REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); swapl(&stuff->port); - return XvProcVector[xv_SelectPortNotify] (client); + return ProcXvSelectPortNotify(client); } static int _X_COLD @@ -1359,7 +1378,7 @@ SProcXvStopVideo(ClientPtr client) REQUEST_SIZE_MATCH(xvStopVideoReq); swapl(&stuff->port); swapl(&stuff->drawable); - return XvProcVector[xv_StopVideo] (client); + return ProcXvStopVideo(client); } static int _X_COLD @@ -1370,7 +1389,7 @@ SProcXvSetPortAttribute(ClientPtr client) swapl(&stuff->port); swapl(&stuff->attribute); swapl(&stuff->value); - return XvProcVector[xv_SetPortAttribute] (client); + return ProcXvSetPortAttribute(client); } static int _X_COLD @@ -1380,7 +1399,7 @@ SProcXvGetPortAttribute(ClientPtr client) REQUEST_SIZE_MATCH(xvGetPortAttributeReq); swapl(&stuff->port); swapl(&stuff->attribute); - return XvProcVector[xv_GetPortAttribute] (client); + return ProcXvGetPortAttribute(client); } static int _X_COLD @@ -1393,7 +1412,7 @@ SProcXvQueryBestSize(ClientPtr client) swaps(&stuff->vid_h); swaps(&stuff->drw_w); swaps(&stuff->drw_h); - return XvProcVector[xv_QueryBestSize] (client); + return ProcXvQueryBestSize(client); } static int _X_COLD @@ -1402,7 +1421,7 @@ SProcXvQueryPortAttributes(ClientPtr client) REQUEST(xvQueryPortAttributesReq); REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); swapl(&stuff->port); - return XvProcVector[xv_QueryPortAttributes] (client); + return ProcXvQueryPortAttributes(client); } static int _X_COLD @@ -1414,7 +1433,7 @@ SProcXvQueryImageAttributes(ClientPtr client) swapl(&stuff->id); swaps(&stuff->width); swaps(&stuff->height); - return XvProcVector[xv_QueryImageAttributes] (client); + return ProcXvQueryImageAttributes(client); } static int _X_COLD @@ -1423,29 +1442,9 @@ SProcXvListImageFormats(ClientPtr client) REQUEST(xvListImageFormatsReq); REQUEST_SIZE_MATCH(xvListImageFormatsReq); swapl(&stuff->port); - return XvProcVector[xv_ListImageFormats] (client); + return ProcXvListImageFormats(client); } -static int (*SXvProcVector[xvNumRequests]) (ClientPtr) = { - ProcXvQueryExtension, - SProcXvQueryAdaptors, - SProcXvQueryEncodings, - SProcXvGrabPort, - SProcXvUngrabPort, - SProcXvPutVideo, - SProcXvPutStill, - SProcXvGetVideo, - SProcXvGetStill, - SProcXvStopVideo, - SProcXvSelectVideoNotify, - SProcXvSelectPortNotify, - SProcXvQueryBestSize, - SProcXvSetPortAttribute, - SProcXvGetPortAttribute, - SProcXvQueryPortAttributes, - SProcXvListImageFormats, - SProcXvQueryImageAttributes, SProcXvPutImage, SProcXvShmPutImage,}; - int _X_COLD SProcXvDispatch(ClientPtr client) { @@ -1453,11 +1452,50 @@ SProcXvDispatch(ClientPtr client) UpdateCurrentTime(); - if (stuff->data >= xvNumRequests) { - return BadRequest; + switch (stuff->data) { + case xv_QueryExtension: + return ProcXvQueryExtension(client); + case xv_QueryAdaptors: + return SProcXvQueryAdaptors(client); + case xv_QueryEncodings: + return SProcXvQueryEncodings(client); + case xv_GrabPort: + return SProcXvGrabPort(client); + case xv_UngrabPort: + return SProcXvUngrabPort(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_StopVideo: + return SProcXvStopVideo(client); + case xv_SelectVideoNotify: + return SProcXvSelectVideoNotify(client); + case xv_SelectPortNotify: + return SProcXvSelectPortNotify(client); + case xv_QueryBestSize: + return SProcXvQueryBestSize(client); + case xv_SetPortAttribute: + return SProcXvSetPortAttribute(client); + case xv_GetPortAttribute: + return SProcXvGetPortAttribute(client); + case xv_QueryPortAttributes: + return SProcXvQueryPortAttributes(client); + case xv_ListImageFormats: + return SProcXvListImageFormats(client); + case xv_QueryImageAttributes: + return SProcXvQueryImageAttributes(client); + case xv_PutImage: + return SProcXvPutImage(client); + case xv_ShmPutImage: + return SProcXvShmPutImage(client); + default: + return BadRequest; } - - return SXvProcVector[stuff->data] (client); } #ifdef PANORAMIX