#include "xmalloc.h"
#include "log.h"
#include "util.h"
+#include "endianmacros.h"
/* Don't accept more connection than this */
#define MAX_CONNECTIONS 10
size_t l;
assert(c && length == (sizeof(int)*2+ESD_NAME_MAX));
- format = maybe_swap_endian_32(c->swap_byte_order, *(const int*)data);
- rate = maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
+ format = MAYBE_INT32_SWAP(c->swap_byte_order, *(const int*)data);
+ rate = MAYBE_INT32_SWAP(c->swap_byte_order, *((const int*)data + 1));
ss.rate = rate;
format_esd2native(format, c->swap_byte_order, &ss);
size_t l;
assert(c && length == (sizeof(int)*2+ESD_NAME_MAX));
- format = maybe_swap_endian_32(c->swap_byte_order, *(const int*)data);
- rate = maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
+ format = MAYBE_INT32_SWAP(c->swap_byte_order, *(const int*)data);
+ rate = MAYBE_INT32_SWAP(c->swap_byte_order, *((const int*)data + 1));
ss.rate = rate;
format_esd2native(format, c->swap_byte_order, &ss);
lag = connection_write(c, sizeof(int));
assert(lag);
- *lag = c->swap_byte_order ? swap_endian_32(latency) : latency;
+ *lag = MAYBE_INT32_SWAP(c->swap_byte_order, latency);
return 0;
}
response = connection_write(c, sizeof(int)*3);
assert(response);
*(response++) = 0;
- *(response++) = maybe_swap_endian_32(c->swap_byte_order, rate);
- *(response++) = maybe_swap_endian_32(c->swap_byte_order, format);
+ *(response++) = MAYBE_INT32_SWAP(c->swap_byte_order, rate);
+ *(response++) = MAYBE_INT32_SWAP(c->swap_byte_order, format);
return 0;
}
}
/* id */
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (int) (conn->index+1));
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, (int) (conn->index+1));
response += sizeof(int);
/* name */
response += ESD_NAME_MAX;
/* rate */
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, rate);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, rate);
response += sizeof(int);
/* left */
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, lvolume);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, lvolume);
response += sizeof(int);
/*right*/
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, rvolume);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, rvolume);
response += sizeof(int);
/*format*/
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, format);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, format);
response += sizeof(int);
t-= k;
assert(t >= s*2);
/* id */
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (int) (ce->index+1));
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, (int) (ce->index+1));
response += sizeof(int);
/* name */
response += ESD_NAME_MAX;
/* rate */
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, ce->sample_spec.rate);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, ce->sample_spec.rate);
response += sizeof(int);
/* left */
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, (ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
response += sizeof(int);
/*right*/
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, (ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
response += sizeof(int);
/*format*/
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, format_native2esd(&ce->sample_spec));
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, format_native2esd(&ce->sample_spec));
response += sizeof(int);
/*length*/
- *((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (int) ce->memchunk.length);
+ *((int*) response) = MAYBE_INT32_SWAP(c->swap_byte_order, (int) ce->memchunk.length);
response += sizeof(int);
t -= s;
struct connection *conn;
assert(c && data && length == sizeof(int)*3);
- idx = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(const int*)data)-1;
- lvolume = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
+ idx = MAYBE_UINT32_SWAP(c->swap_byte_order, *(const int*)data)-1;
+ lvolume = MAYBE_UINT32_SWAP(c->swap_byte_order, *((const int*)data + 1));
lvolume = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
- rvolume = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 2));
+ rvolume = MAYBE_UINT32_SWAP(c->swap_byte_order, *((const int*)data + 2));
rvolume = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
ok = connection_write(c, sizeof(int));
char name[ESD_NAME_MAX+sizeof(SCACHE_PREFIX)-1];
assert(c && data && length == (ESD_NAME_MAX+3*sizeof(int)));
- format = maybe_swap_endian_32(c->swap_byte_order, *(const int*)data);
- rate = maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
+ format = MAYBE_INT32_SWAP(c->swap_byte_order, *(const int*)data);
+ rate = MAYBE_INT32_SWAP(c->swap_byte_order, *((const int*)data + 1));
ss.rate = rate;
format_esd2native(format, c->swap_byte_order, &ss);
- sc_length = (size_t) maybe_swap_endian_32(c->swap_byte_order, (*((const int*)data + 2)));
+ sc_length = (size_t) MAYBE_INT32_SWAP(c->swap_byte_order, (*((const int*)data + 2)));
if (sc_length >= MAX_CACHE_SAMPLE_SIZE)
return -1;
uint32_t idx;
assert(c && data && length == sizeof(int));
- idx = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(const int*)data)-1;
+ idx = (uint32_t) MAYBE_INT32_SWAP(c->swap_byte_order, *(const int*)data)-1;
ok = connection_write(c, sizeof(int));
assert(ok);
if ((c->read_data_length+= r) >= sizeof(c->request)) {
struct proto_handler *handler;
- if (c->swap_byte_order)
- c->request = swap_endian_32(c->request);
+ c->request = MAYBE_INT32_SWAP(c->swap_byte_order, c->request);
if (c->request < ESD_PROTO_CONNECT || c->request > ESD_PROTO_MAX) {
pa_log(__FILE__": recieved invalid request.\n");