Xext: xv: ProcXvQueryExtension() simplify reply header assembly

As a prepration for upcoming changes, move assembly of the the reply
header further downwards where all values are already known, so we'll
have to touch it only once. Also eliminate the separate write path for
the case where Xv is disabled.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-07-17 21:13:26 +02:00
committed by Enrico Weigelt
parent aef132f847
commit 0d99fd2d1c

View File

@@ -83,7 +83,7 @@ ProcXvQueryExtension(ClientPtr client)
static int
ProcXvQueryAdaptors(ClientPtr client)
{
int totalSize, na, nf, rc;
int na, nf, rc;
int nameSize;
XvAdaptorPtr pa;
XvFormatPtr pf;
@@ -98,37 +98,36 @@ ProcXvQueryAdaptors(ClientPtr client)
if (rc != Success)
return rc;
xvQueryAdaptorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
};
pScreen = pWin->drawable.pScreen;
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
XvGetScreenKey());
if (!pxvs) {
if (client->swapped) swaps(&rep.sequenceNumber);
WriteToClient(client, sizeof(rep), &rep);
return Success;
size_t totalSize = 0;
size_t numAdaptors = 0;
if (pxvs) {
numAdaptors = pxvs->nAdaptors;
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
/* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--) {
totalSize += pad_to_int32(strlen(pa->name));
totalSize += pa->nFormats * sz_xvFormat;
pa++;
}
}
rep.num_adaptors = pxvs->nAdaptors;
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
/* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--) {
totalSize += pad_to_int32(strlen(pa->name));
totalSize += pa->nFormats * sz_xvFormat;
pa++;
}
rep.length = bytes_to_int32(totalSize);
xvQueryAdaptorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_adaptors = numAdaptors,
.length = bytes_to_int32(totalSize)
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
@@ -137,6 +136,9 @@ ProcXvQueryAdaptors(ClientPtr client)
}
WriteToClient(client, sizeof(rep), &rep);
if (!pxvs) /* no payload to send, we're done here */
return Success;
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--) {