(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
|
static int
|
||||||
ProcXvQueryEncodings(ClientPtr client)
|
ProcXvQueryEncodings(ClientPtr client)
|
||||||
{
|
{
|
||||||
xvEncodingInfo einfo;
|
|
||||||
int totalSize;
|
int totalSize;
|
||||||
int nameSize;
|
|
||||||
XvPortPtr pPort;
|
XvPortPtr pPort;
|
||||||
int ne;
|
int ne;
|
||||||
XvEncodingPtr pe;
|
XvEncodingPtr pe;
|
||||||
|
@ -201,6 +199,11 @@ ProcXvQueryEncodings(ClientPtr client)
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char buf[totalSize];
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
|
char *walk = buf;
|
||||||
|
|
||||||
xvQueryEncodingsReply rep = {
|
xvQueryEncodingsReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
|
@ -219,26 +222,33 @@ ProcXvQueryEncodings(ClientPtr client)
|
||||||
ne = pPort->pAdaptor->nEncodings;
|
ne = pPort->pAdaptor->nEncodings;
|
||||||
pe = pPort->pAdaptor->pEncodings;
|
pe = pPort->pAdaptor->pEncodings;
|
||||||
while (ne--) {
|
while (ne--) {
|
||||||
einfo.encoding = pe->id;
|
int nameSize;
|
||||||
einfo.name_size = nameSize = strlen(pe->name);
|
xvEncodingInfo *einfo = (xvEncodingInfo*)walk;
|
||||||
einfo.width = pe->width;
|
|
||||||
einfo.height = pe->height;
|
einfo->encoding = pe->id;
|
||||||
einfo.rate.numerator = pe->rate.numerator;
|
einfo->name_size = nameSize = strlen(pe->name);
|
||||||
einfo.rate.denominator = pe->rate.denominator;
|
einfo->width = pe->width;
|
||||||
|
einfo->height = pe->height;
|
||||||
|
einfo->rate.numerator = pe->rate.numerator;
|
||||||
|
einfo->rate.denominator = pe->rate.denominator;
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swapl(&einfo.encoding);
|
swapl(&einfo->encoding);
|
||||||
swaps(&einfo.name_size);
|
swaps(&einfo->name_size);
|
||||||
swaps(&einfo.width);
|
swaps(&einfo->width);
|
||||||
swaps(&einfo.height);
|
swaps(&einfo->height);
|
||||||
swapl(&einfo.rate.numerator);
|
swapl(&einfo->rate.numerator);
|
||||||
swapl(&einfo.rate.denominator);
|
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++;
|
pe++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteToClient(client, sizeof(buf), buf);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue