(submit/cleanup-xv-dispatch) Xext: xv: ProcXvQueryAdaptors(): write reply payload at once.
Collect up the puzzle piezes of the reply payload into to a temporary struct, so we can send it as one block. This allows for further simplifications by subsequent commits. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
50813e93c6
commit
165e48e286
|
|
@ -82,8 +82,6 @@ ProcXvQueryExtension(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcXvQueryAdaptors(ClientPtr client)
|
ProcXvQueryAdaptors(ClientPtr client)
|
||||||
{
|
{
|
||||||
xvFormat format;
|
|
||||||
xvAdaptorInfo ainfo;
|
|
||||||
int totalSize, na, nf, rc;
|
int totalSize, na, nf, rc;
|
||||||
int nameSize;
|
int nameSize;
|
||||||
XvAdaptorPtr pa;
|
XvAdaptorPtr pa;
|
||||||
|
|
@ -129,43 +127,47 @@ ProcXvQueryAdaptors(ClientPtr client)
|
||||||
pa++;
|
pa++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char payload[totalSize];
|
||||||
|
memset(payload, 0, totalSize);
|
||||||
|
char *walk = payload;
|
||||||
|
|
||||||
rep.length = bytes_to_int32(totalSize);
|
rep.length = bytes_to_int32(totalSize);
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
swaps(&rep.num_adaptors);
|
swaps(&rep.num_adaptors);
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
na = pxvs->nAdaptors;
|
na = pxvs->nAdaptors;
|
||||||
pa = pxvs->pAdaptors;
|
pa = pxvs->pAdaptors;
|
||||||
while (na--) {
|
while (na--) {
|
||||||
|
xvAdaptorInfo *ainfo = (xvAdaptorInfo*)walk;
|
||||||
|
|
||||||
ainfo.base_id = pa->base_id;
|
ainfo->base_id = pa->base_id;
|
||||||
ainfo.num_ports = pa->nPorts;
|
ainfo->num_ports = pa->nPorts;
|
||||||
ainfo.type = pa->type;
|
ainfo->type = pa->type;
|
||||||
ainfo.name_size = nameSize = strlen(pa->name);
|
ainfo->name_size = nameSize = strlen(pa->name);
|
||||||
ainfo.num_formats = pa->nFormats;
|
ainfo->num_formats = pa->nFormats;
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swapl(&ainfo.base_id);
|
swapl(&ainfo->base_id);
|
||||||
swaps(&ainfo.name_size);
|
swaps(&ainfo->name_size);
|
||||||
swaps(&ainfo.num_ports);
|
swaps(&ainfo->num_ports);
|
||||||
swaps(&ainfo.num_formats);
|
swaps(&ainfo->num_formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(ainfo), &ainfo);
|
walk += sizeof(ainfo);
|
||||||
|
memcpy(walk, pa->name, nameSize);
|
||||||
WriteToClient(client, nameSize, pa->name);
|
walk += pad_to_int32(nameSize);
|
||||||
|
|
||||||
nf = pa->nFormats;
|
nf = pa->nFormats;
|
||||||
pf = pa->pFormats;
|
pf = pa->pFormats;
|
||||||
while (nf--) {
|
while (nf--) {
|
||||||
format.depth = pf->depth;
|
xvFormat *format = (xvFormat *)walk;
|
||||||
format.visual = pf->visual;
|
format->depth = pf->depth;
|
||||||
if (client->swapped) swapl(&format.visual);
|
format->visual = pf->visual;
|
||||||
WriteToClient(client, sizeof(format), &format);
|
if (client->swapped) swapl(&format->visual);
|
||||||
pf++;
|
pf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,6 +175,9 @@ ProcXvQueryAdaptors(ClientPtr client)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteToClient(client, sizeof(rep), &rep);
|
||||||
|
WriteToClient(client, sizeof(payload), payload);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue