Xext: xv: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
2892b49d26
commit
c729bfd1f9
190
Xext/xvdisp.c
190
Xext/xvdisp.c
|
@ -61,22 +61,14 @@ ProcXvQueryExtension(ClientPtr client)
|
||||||
REQUEST_HEAD_STRUCT(xvQueryExtensionReq);
|
REQUEST_HEAD_STRUCT(xvQueryExtensionReq);
|
||||||
|
|
||||||
xvQueryExtensionReply rep = {
|
xvQueryExtensionReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.length = 0,
|
.length = 0,
|
||||||
.version = XvVersion,
|
.version = XvVersion,
|
||||||
.revision = XvRevision
|
.revision = XvRevision
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
REPLY_FIELD_CARD16(version);
|
||||||
swaps(&rep.sequenceNumber);
|
REPLY_FIELD_CARD16(revision);
|
||||||
swapl(&rep.length);
|
REPLY_SEND_RET_SUCCESS();
|
||||||
swaps(&rep.version);
|
|
||||||
swaps(&rep.revision);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -97,22 +89,14 @@ ProcXvQueryAdaptors(ClientPtr client)
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
xvQueryAdaptorsReply rep = {
|
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
};
|
|
||||||
|
|
||||||
pScreen = pWin->drawable.pScreen;
|
pScreen = pWin->drawable.pScreen;
|
||||||
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
||||||
XvGetScreenKey());
|
XvGetScreenKey());
|
||||||
if (!pxvs) {
|
if (!pxvs) {
|
||||||
if (client->swapped) swaps(&rep.sequenceNumber);
|
xvQueryAdaptorsReply rep = { 0 };
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
REPLY_SEND_RET_SUCCESS();
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rep.num_adaptors = pxvs->nAdaptors;
|
|
||||||
|
|
||||||
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
|
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
|
||||||
|
|
||||||
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
|
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
|
||||||
|
@ -131,14 +115,6 @@ ProcXvQueryAdaptors(ClientPtr client)
|
||||||
memset(payload, 0, totalSize);
|
memset(payload, 0, totalSize);
|
||||||
char *walk = payload;
|
char *walk = payload;
|
||||||
|
|
||||||
rep.length = bytes_to_int32(totalSize);
|
|
||||||
|
|
||||||
if (client->swapped) {
|
|
||||||
swaps(&rep.sequenceNumber);
|
|
||||||
swapl(&rep.length);
|
|
||||||
swaps(&rep.num_adaptors);
|
|
||||||
}
|
|
||||||
|
|
||||||
na = pxvs->nAdaptors;
|
na = pxvs->nAdaptors;
|
||||||
pa = pxvs->pAdaptors;
|
pa = pxvs->pAdaptors;
|
||||||
while (na--) {
|
while (na--) {
|
||||||
|
@ -150,12 +126,8 @@ ProcXvQueryAdaptors(ClientPtr client)
|
||||||
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) {
|
CLIENT_STRUCT_CARD32_1(ainfo, base_id);
|
||||||
swapl(&ainfo->base_id);
|
CLIENT_STRUCT_CARD16_3(ainfo, name_size, num_ports, num_formats);
|
||||||
swaps(&ainfo->name_size);
|
|
||||||
swaps(&ainfo->num_ports);
|
|
||||||
swaps(&ainfo->num_formats);
|
|
||||||
}
|
|
||||||
|
|
||||||
walk += sizeof(ainfo);
|
walk += sizeof(ainfo);
|
||||||
memcpy(walk, pa->name, nameSize);
|
memcpy(walk, pa->name, nameSize);
|
||||||
|
@ -167,16 +139,19 @@ ProcXvQueryAdaptors(ClientPtr client)
|
||||||
xvFormat *format = (xvFormat *)walk;
|
xvFormat *format = (xvFormat *)walk;
|
||||||
format->depth = pf->depth;
|
format->depth = pf->depth;
|
||||||
format->visual = pf->visual;
|
format->visual = pf->visual;
|
||||||
if (client->swapped) swapl(&format->visual);
|
CLIENT_STRUCT_CARD32_1(format, visual);
|
||||||
pf++;
|
pf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa++;
|
pa++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
xvQueryAdaptorsReply rep = {
|
||||||
WriteToClient(client, sizeof(payload), payload);
|
rep.num_adaptors = pxvs->nAdaptors,
|
||||||
|
};
|
||||||
|
|
||||||
|
REPLY_FIELD_CARD16(num_adaptors);
|
||||||
|
REPLY_SEND_EXTRA(payload, sizeof(payload));
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
@ -210,20 +185,10 @@ ProcXvQueryEncodings(ClientPtr client)
|
||||||
char *walk = buf;
|
char *walk = buf;
|
||||||
|
|
||||||
xvQueryEncodingsReply rep = {
|
xvQueryEncodingsReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.num_encodings = pPort->pAdaptor->nEncodings,
|
.num_encodings = pPort->pAdaptor->nEncodings,
|
||||||
.length = bytes_to_int32(totalSize),
|
.length = bytes_to_int32(totalSize),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
|
||||||
swaps(&rep.sequenceNumber);
|
|
||||||
swapl(&rep.length);
|
|
||||||
swaps(&rep.num_encodings);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
|
|
||||||
ne = pPort->pAdaptor->nEncodings;
|
ne = pPort->pAdaptor->nEncodings;
|
||||||
pe = pPort->pAdaptor->pEncodings;
|
pe = pPort->pAdaptor->pEncodings;
|
||||||
while (ne--) {
|
while (ne--) {
|
||||||
|
@ -237,14 +202,8 @@ ProcXvQueryEncodings(ClientPtr client)
|
||||||
einfo->rate.numerator = pe->rate.numerator;
|
einfo->rate.numerator = pe->rate.numerator;
|
||||||
einfo->rate.denominator = pe->rate.denominator;
|
einfo->rate.denominator = pe->rate.denominator;
|
||||||
|
|
||||||
if (client->swapped) {
|
CLIENT_STRUCT_CARD32_3(einfo, encoding, rate.numerator, rate.denominator);
|
||||||
swapl(&einfo->encoding);
|
CLIENT_STRUCT_CARD16_3(einfo, name_size, width, height);
|
||||||
swaps(&einfo->name_size);
|
|
||||||
swaps(&einfo->width);
|
|
||||||
swaps(&einfo->height);
|
|
||||||
swapl(&einfo->rate.numerator);
|
|
||||||
swapl(&einfo->rate.denominator);
|
|
||||||
}
|
|
||||||
|
|
||||||
walk += sizeof(xvEncodingInfo);
|
walk += sizeof(xvEncodingInfo);
|
||||||
memcpy(walk, pe->name, nameSize);
|
memcpy(walk, pe->name, nameSize);
|
||||||
|
@ -253,7 +212,8 @@ ProcXvQueryEncodings(ClientPtr client)
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(buf), buf);
|
REPLY_FIELD_CARD16(num_encodings);
|
||||||
|
REPLY_SEND_EXTRA(buf, sizeof(buf));
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,18 +453,10 @@ ProcXvGrabPort(ClientPtr client)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
xvGrabPortReply rep = {
|
xvGrabPortReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.result = result
|
.result = result
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
REPLY_SEND_RET_SUCCESS();
|
||||||
swaps(&rep.sequenceNumber);
|
|
||||||
swapl(&rep.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -619,19 +571,11 @@ ProcXvGetPortAttribute(ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
xvGetPortAttributeReply rep = {
|
xvGetPortAttributeReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.value = value
|
.value = value
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
REPLY_FIELD_CARD32(value);
|
||||||
swaps(&rep.sequenceNumber);
|
REPLY_SEND_RET_SUCCESS();
|
||||||
swapl(&rep.length);
|
|
||||||
swapl(&rep.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -655,21 +599,13 @@ ProcXvQueryBestSize(ClientPtr client)
|
||||||
&actual_width, &actual_height);
|
&actual_width, &actual_height);
|
||||||
|
|
||||||
xvQueryBestSizeReply rep = {
|
xvQueryBestSizeReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.actual_width = actual_width,
|
.actual_width = actual_width,
|
||||||
.actual_height = actual_height
|
.actual_height = actual_height
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
REPLY_FIELD_CARD16(actual_width);
|
||||||
swaps(&rep.sequenceNumber);
|
REPLY_FIELD_CARD16(actual_height);
|
||||||
swapl(&rep.length);
|
REPLY_SEND_RET_SUCCESS();
|
||||||
swaps(&rep.actual_width);
|
|
||||||
swaps(&rep.actual_height);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -694,22 +630,11 @@ ProcXvQueryPortAttributes(ClientPtr client)
|
||||||
+ text_size;
|
+ text_size;
|
||||||
|
|
||||||
xvQueryPortAttributesReply rep = {
|
xvQueryPortAttributesReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.num_attributes = pPort->pAdaptor->nAttributes,
|
.num_attributes = pPort->pAdaptor->nAttributes,
|
||||||
.length = bytes_to_int32(length),
|
.length = bytes_to_int32(length),
|
||||||
.text_size = text_size,
|
.text_size = text_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
|
||||||
swaps(&rep.sequenceNumber);
|
|
||||||
swapl(&rep.length);
|
|
||||||
swapl(&rep.num_attributes);
|
|
||||||
swapl(&rep.text_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
|
|
||||||
char buf[length];
|
char buf[length];
|
||||||
char * walk = buf;
|
char * walk = buf;
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
@ -724,12 +649,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
|
||||||
Info->max = pAtt->max_value;
|
Info->max = pAtt->max_value;
|
||||||
Info->size = pad_to_int32(size);
|
Info->size = pad_to_int32(size);
|
||||||
|
|
||||||
if (client->swapped) {
|
CLIENT_STRUCT_CARD32_4(Info, flags, size, min, max);
|
||||||
swapl(&Info->flags);
|
|
||||||
swapl(&Info->size);
|
|
||||||
swapl(&Info->min);
|
|
||||||
swapl(&Info->max);
|
|
||||||
}
|
|
||||||
|
|
||||||
walk += sizeof(xvAttributeInfo);
|
walk += sizeof(xvAttributeInfo);
|
||||||
|
|
||||||
|
@ -737,7 +657,9 @@ ProcXvQueryPortAttributes(ClientPtr client)
|
||||||
walk += pad_to_int32(size);
|
walk += pad_to_int32(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(buf), buf);
|
REPLY_FIELD_CARD32(num_attributes);
|
||||||
|
REPLY_FIELD_CARD32(text_size);
|
||||||
|
REPLY_SEND_EXTRA(buf, sizeof(buf));
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,7 +866,6 @@ ProcXvShmPutImage(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcXvQueryImageAttributes(ClientPtr client)
|
ProcXvQueryImageAttributes(ClientPtr client)
|
||||||
{
|
{
|
||||||
xvQueryImageAttributesReply rep;
|
|
||||||
int size, num_planes, i;
|
int size, num_planes, i;
|
||||||
CARD16 width, height;
|
CARD16 width, height;
|
||||||
XvImagePtr pImage = NULL;
|
XvImagePtr pImage = NULL;
|
||||||
|
@ -990,28 +911,19 @@ ProcXvQueryImageAttributes(ClientPtr client)
|
||||||
&width, &height, offsets,
|
&width, &height, offsets,
|
||||||
pitches);
|
pitches);
|
||||||
|
|
||||||
rep = (xvQueryImageAttributesReply) {
|
xvQueryImageAttributesReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.length = num_planes * 2, // in 32bit units
|
|
||||||
.num_planes = num_planes,
|
.num_planes = num_planes,
|
||||||
.width = width,
|
.width = width,
|
||||||
.height = height,
|
.height = height,
|
||||||
.data_size = size
|
.data_size = size
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
REPLY_FIELD_CARD32(num_planes);
|
||||||
swaps(&rep.sequenceNumber);
|
REPLY_FIELD_CARD32(data_size);
|
||||||
swapl(&rep.length);
|
REPLY_FIELD_CARD16(width);
|
||||||
swapl(&rep.num_planes);
|
REPLY_FIELD_CARD16(height);
|
||||||
swapl(&rep.data_size);
|
REPLY_BUF_CARD32(offsets, num_planes * 2);
|
||||||
swaps(&rep.width);
|
REPLY_SEND_EXTRA(offsets, num_planes * sizeof(CARD32) * 2);
|
||||||
swaps(&rep.height);
|
|
||||||
SwapLongs((CARD32 *) offsets, rep.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
WriteToClient(client, rep.length * sizeof(CARD32), offsets);
|
|
||||||
free(offsets);
|
free(offsets);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
@ -1031,19 +943,11 @@ ProcXvListImageFormats(ClientPtr client)
|
||||||
int payload_size = pPort->pAdaptor->nImages * sz_xvImageFormatInfo;
|
int payload_size = pPort->pAdaptor->nImages * sz_xvImageFormatInfo;
|
||||||
|
|
||||||
xvListImageFormatsReply rep = {
|
xvListImageFormatsReply rep = {
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.num_formats = pPort->pAdaptor->nImages,
|
.num_formats = pPort->pAdaptor->nImages,
|
||||||
.length = bytes_to_int32(payload_size)
|
.length = bytes_to_int32(payload_size)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
REPLY_FIELD_CARD32(num_formats);
|
||||||
swaps(&rep.sequenceNumber);
|
|
||||||
swapl(&rep.length);
|
|
||||||
swapl(&rep.num_formats);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
|
|
||||||
pImage = pPort->pAdaptor->pImages;
|
pImage = pPort->pAdaptor->pImages;
|
||||||
|
|
||||||
|
@ -1074,26 +978,12 @@ ProcXvListImageFormats(ClientPtr client)
|
||||||
memcpy(&info[i].comp_order, pImage->component_order, 32);
|
memcpy(&info[i].comp_order, pImage->component_order, 32);
|
||||||
info[i].scanline_order = pImage->scanline_order;
|
info[i].scanline_order = pImage->scanline_order;
|
||||||
|
|
||||||
if (client->swapped) {
|
CLIENT_STRUCT_CARD32_5(&info[i], id, red_mask, green_mask, blue_mask, y_sample_bits);
|
||||||
swapl(&info[i].id);
|
CLIENT_STRUCT_CARD32_4(&info[i], u_sample_bits, v_sample_bits, horz_y_period, horz_u_period);
|
||||||
swapl(&info[i].red_mask);
|
CLIENT_STRUCT_CARD32_4(&info[i], horz_v_period, vert_y_period, vert_u_period, vert_v_period);
|
||||||
swapl(&info[i].green_mask);
|
|
||||||
swapl(&info[i].blue_mask);
|
|
||||||
swapl(&info[i].y_sample_bits);
|
|
||||||
swapl(&info[i].u_sample_bits);
|
|
||||||
swapl(&info[i].v_sample_bits);
|
|
||||||
swapl(&info[i].horz_y_period);
|
|
||||||
swapl(&info[i].horz_u_period);
|
|
||||||
swapl(&info[i].horz_v_period);
|
|
||||||
swapl(&info[i].vert_y_period);
|
|
||||||
swapl(&info[i].vert_u_period);
|
|
||||||
swapl(&info[i].vert_v_period);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof(info))
|
REPLY_SEND_EXTRA(info, sizeof(info));
|
||||||
WriteToClient(client, sizeof(info), info);
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue