pa_iochannel_cb_t callback;
void*userdata;
- pa_bool_t readable;
- pa_bool_t writable;
- pa_bool_t hungup;
-
- pa_bool_t no_close;
+ pa_bool_t readable:1;
+ pa_bool_t writable:1;
+ pa_bool_t hungup:1;
+ pa_bool_t no_close:1;
pa_io_event* input_event, *output_event;
};
#ifdef HAVE_CREDS
pa_bool_t pa_iochannel_creds_supported(pa_iochannel *io) {
- struct sockaddr_un sa;
+ struct {
+ struct sockaddr sa;
+ struct sockaddr_un un;
+ struct sockaddr_storage storage;
+ } sa;
+
socklen_t l;
pa_assert(io);
pa_assert(io->ofd == io->ifd);
l = sizeof(sa);
+ if (getsockname(io->ifd, &sa.sa, &l) < 0)
+ return FALSE;
- if (getsockname(io->ifd, (struct sockaddr*) &sa, &l) < 0)
- return 0;
-
- return sa.sun_family == AF_UNIX;
+ return sa.sa.sa_family == AF_UNIX;
}
int pa_iochannel_creds_enable(pa_iochannel *io) {
pa_assert(l);
pa_assert(io->ofd >= 0);
- memset(&iov, 0, sizeof(iov));
+ pa_zero(iov);
iov.iov_base = (void*) data;
iov.iov_len = l;
- memset(&cmsg, 0, sizeof(cmsg));
+ pa_zero(cmsg);
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(struct ucred));
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_CREDENTIALS;
pa_assert(creds);
pa_assert(creds_valid);
- memset(&iov, 0, sizeof(iov));
+ pa_zero(iov);
iov.iov_base = data;
iov.iov_len = l;
- memset(&cmsg, 0, sizeof(cmsg));
-
- memset(&mh, 0, sizeof(mh));
- mh.msg_name = NULL;
- mh.msg_namelen = 0;
+ pa_zero(cmsg);
+ pa_zero(mh);
mh.msg_iov = &iov;
mh.msg_iovlen = 1;
mh.msg_control = &cmsg;
mh.msg_controllen = sizeof(cmsg);
- mh.msg_flags = 0;
if ((r = recvmsg(io->ifd, &mh, 0)) >= 0) {
struct cmsghdr *cmh;
- *creds_valid = 0;
+ *creds_valid = FALSE;
for (cmh = CMSG_FIRSTHDR(&mh); cmh; cmh = CMSG_NXTHDR(&mh, cmh)) {
return format;
}
-#define CHECK_VALIDITY(expression, ...) do { \
- if (!(expression)) { \
- pa_log_warn(__FILE__ ": " __VA_ARGS__); \
- return -1; \
- } \
-} while(0);
+#define CHECK_VALIDITY(expression, ...) do { \
+ if (PA_UNLIKELY(!(expression))) { \
+ pa_log_warn(__FILE__ ": " __VA_ARGS__); \
+ return -1; \
+ } \
+ } while(0);
/*** esound commands ***/
memset(terminator, 0, sizeof(terminator));
- for (conn = pa_idxset_first(c->protocol->connections, &idx); conn; conn = pa_idxset_next(c->protocol->connections, &idx)) {
+ PA_IDXSET_FOREACH(conn, c->protocol->connections, idx) {
int32_t id, format = ESD_BITS16 | ESD_STEREO, rate = 44100, lvolume = ESD_VOLUME_BASE, rvolume = ESD_VOLUME_BASE;
char name[ESD_NAME_MAX];
pa_scache_entry *ce;
idx = PA_IDXSET_INVALID;
- for (ce = pa_idxset_first(c->protocol->core->scache, &idx); ce; ce = pa_idxset_next(c->protocol->core->scache, &idx)) {
+
+ PA_IDXSET_FOREACH(ce, c->protocol->core->scache, idx) {
int32_t id, rate, lvolume, rvolume, format, len;
char name[ESD_NAME_MAX];
pa_channel_map stereo = { .channels = 2, .map = { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT } };
/* pa_log("STREAMING_DATA"); */
- if (!(l = (size_t) pa_atomic_load(&c->playback.missing)))
+ if ((l = (size_t) pa_atomic_load(&c->playback.missing)) <= 0)
return 0;
if (c->playback.current_memblock) {
c->playback.memblock_index += (size_t) r;
- pa_asyncmsgq_post(c->sink_input->sink->asyncmsgq, PA_MSGOBJECT(c->sink_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, 0, &chunk, NULL);
pa_atomic_sub(&c->playback.missing, (int) r);
+ pa_asyncmsgq_post(c->sink_input->sink->asyncmsgq, PA_MSGOBJECT(c->sink_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, 0, &chunk, NULL);
}
return 0;
} else {
size_t m;
- chunk->length = PA_MIN(length, chunk->length);
-
c->playback.underrun = FALSE;
+ chunk->length = PA_MIN(length, chunk->length);
pa_memblockq_drop(c->input_memblockq, chunk->length);
m = pa_memblockq_pop_missing(c->input_memblockq);