(submit/cleanup-xv-dispatch) Xext: xv: ProcXvQueryAdaptors() use local stack buffer
Simplify sending by collecting in a local scoped buffer, so only one WriteToClient() call is needed. This also makes further simplifications by upcoming patches easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
10510cd528
commit
014954c3f7
|
@ -179,9 +179,7 @@ ProcXvQueryAdaptors(ClientPtr client)
|
|||
static int
|
||||
ProcXvQueryEncodings(ClientPtr client)
|
||||
{
|
||||
xvEncodingInfo einfo;
|
||||
int totalSize;
|
||||
int nameSize;
|
||||
XvPortPtr pPort;
|
||||
int ne;
|
||||
XvEncodingPtr pe;
|
||||
|
@ -201,6 +199,11 @@ ProcXvQueryEncodings(ClientPtr client)
|
|||
pe++;
|
||||
}
|
||||
|
||||
char buf[totalSize];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
char *walk = buf;
|
||||
|
||||
xvQueryEncodingsReply rep = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
|
@ -219,26 +222,33 @@ ProcXvQueryEncodings(ClientPtr client)
|
|||
ne = pPort->pAdaptor->nEncodings;
|
||||
pe = pPort->pAdaptor->pEncodings;
|
||||
while (ne--) {
|
||||
einfo.encoding = pe->id;
|
||||
einfo.name_size = nameSize = strlen(pe->name);
|
||||
einfo.width = pe->width;
|
||||
einfo.height = pe->height;
|
||||
einfo.rate.numerator = pe->rate.numerator;
|
||||
einfo.rate.denominator = pe->rate.denominator;
|
||||
int nameSize;
|
||||
xvEncodingInfo *einfo = (xvEncodingInfo*)walk;
|
||||
|
||||
einfo->encoding = pe->id;
|
||||
einfo->name_size = nameSize = strlen(pe->name);
|
||||
einfo->width = pe->width;
|
||||
einfo->height = pe->height;
|
||||
einfo->rate.numerator = pe->rate.numerator;
|
||||
einfo->rate.denominator = pe->rate.denominator;
|
||||
|
||||
if (client->swapped) {
|
||||
swapl(&einfo.encoding);
|
||||
swaps(&einfo.name_size);
|
||||
swaps(&einfo.width);
|
||||
swaps(&einfo.height);
|
||||
swapl(&einfo.rate.numerator);
|
||||
swapl(&einfo.rate.denominator);
|
||||
swapl(&einfo->encoding);
|
||||
swaps(&einfo->name_size);
|
||||
swaps(&einfo->width);
|
||||
swaps(&einfo->height);
|
||||
swapl(&einfo->rate.numerator);
|
||||
swapl(&einfo->rate.denominator);
|
||||
}
|
||||
WriteToClient(client, sizeof(einfo), &einfo);
|
||||
WriteToClient(client, nameSize, pe->name);
|
||||
|
||||
walk += sizeof(xvEncodingInfo);
|
||||
memcpy(walk, pe->name, nameSize);
|
||||
walk += pad_to_int32(nameSize);
|
||||
|
||||
pe++;
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(buf), buf);
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue