git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@10
fefdeb5f-60dc-0310-8127-
8f9354f1896f
s->hash_table[h] = e;
/* Insert into array */
s->hash_table[h] = e;
/* Insert into array */
- extend_array(s, s->index);
- a = array_index(s, s->index);
+ extend_array(s, e->index);
+ a = array_index(s, e->index);
assert(a && !*a);
*a = e;
assert(a && !*a);
*a = e;
if (!(a = array_index(s, index)))
return NULL;
if (!(a = array_index(s, index)))
return NULL;
+ if (!*a)
+ return NULL;
+
static void callback(struct mainloop_source*s, int fd, enum mainloop_io_event events, void *userdata) {
struct iochannel *io = userdata;
static void callback(struct mainloop_source*s, int fd, enum mainloop_io_event events, void *userdata) {
struct iochannel *io = userdata;
assert(s && fd >= 0 && userdata);
assert(s && fd >= 0 && userdata);
- if (events & MAINLOOP_IO_EVENT_IN && !io->readable) {
+ if ((events & MAINLOOP_IO_EVENT_IN) && !io->readable) {
io->readable = 1;
changed = 1;
}
io->readable = 1;
changed = 1;
}
- if (events & MAINLOOP_IO_EVENT_OUT && !io->writable) {
+ if ((events & MAINLOOP_IO_EVENT_OUT) && !io->writable) {
io->writable = 1;
changed = 1;
}
io->writable = 1;
changed = 1;
}
if (io->input_source)
mainloop_source_free(io->input_source);
if (io->input_source)
mainloop_source_free(io->input_source);
+ if (io->output_source && io->output_source != io->input_source)
mainloop_source_free(io->output_source);
free(io);
mainloop_source_free(io->output_source);
free(io);
- if (m->rebuild_pollfds)
+ if (m->rebuild_pollfds) {
+ m->rebuild_pollfds = 0;
+ }
void mainloop_source_io_set_events(struct mainloop_source*s, enum mainloop_io_event events) {
assert(s && !s->dead && s->type == MAINLOOP_SOURCE_TYPE_IO);
void mainloop_source_io_set_events(struct mainloop_source*s, enum mainloop_io_event events) {
assert(s && !s->dead && s->type == MAINLOOP_SOURCE_TYPE_IO);
- if ((s->io.events && !events) || (!s->io.events && events)) {
+ if (s->io.events != events) {
assert(s->mainloop);
s->mainloop->rebuild_pollfds = 1;
}
assert(s->mainloop);
s->mainloop->rebuild_pollfds = 1;
}
void memblockq_push(struct memblockq* bq, struct memchunk *chunk, size_t delta) {
struct memblock_list *q;
void memblockq_push(struct memblockq* bq, struct memchunk *chunk, size_t delta) {
struct memblock_list *q;
- assert(bq && chunk && chunk->memblock && chunk->index);
+ assert(bq && chunk && chunk->memblock && chunk->length);
q = malloc(sizeof(struct memblock_list));
assert(q);
q = malloc(sizeof(struct memblock_list));
assert(q);
int memblockq_is_empty(struct memblockq *bq) {
assert(bq);
int memblockq_is_empty(struct memblockq *bq) {
assert(bq);
- return bq->total_length >= bq->base;
+ return bq->total_length < bq->base;
c->istream = NULL;
c->ostream = NULL;
c->protocol = p;
c->istream = NULL;
c->ostream = NULL;
c->protocol = p;
+
+ c->client = client_new(p->core, "SIMPLE", "Client");
+ assert(c->client);
+
if (p->mode & PROTOCOL_SIMPLE_RECORD) {
struct source *source;
if (p->mode & PROTOCOL_SIMPLE_RECORD) {
struct source *source;
- c->client = client_new(p->core, "SIMPLE", "Client");
- assert(c->client);
iochannel_set_callback(c->io, io_callback, c);
idxset_put(p->connections, c, NULL);
iochannel_set_callback(c->io, io_callback, c);
idxset_put(p->connections, c, NULL);
+ if (c->client)
+ client_free(c->client);
if (c->istream)
input_stream_free(c->istream);
if (c->ostream)
if (c->istream)
input_stream_free(c->istream);
if (c->ostream)
info->count++;
info->last_input_stream = i;
info->count++;
info->last_input_stream = i;
+ memblock_unref(chunk.memblock);
+
struct socket_server* socket_server_new_ipv4(struct mainloop *m, uint32_t address, uint16_t port) {
int fd = -1;
struct sockaddr_in sa;
struct socket_server* socket_server_new_ipv4(struct mainloop *m, uint32_t address, uint16_t port) {
int fd = -1;
struct sockaddr_in sa;
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
+ fprintf(stderr, "setsockopt(): %s\n", strerror(errno));
+
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
sa.sin_addr.s_addr = htonl(address);
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
sa.sin_addr.s_addr = htonl(address);
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
fprintf(stderr, "bind(): %s\n", strerror(errno));
goto fail;
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
fprintf(stderr, "bind(): %s\n", strerror(errno));
goto fail;
-static void do_free(void *p, void *userdata) {
- struct output_stream *o = p;
- assert(o);
- output_stream_free(o);
-};
-
void source_free(struct source *s) {
struct output_stream *o;
assert(s);
void source_free(struct source *s) {
struct output_stream *o;
assert(s);
idxset_free(s->output_streams, NULL, NULL);
idxset_remove_by_data(s->core->sources, s, NULL);
idxset_free(s->output_streams, NULL, NULL);
idxset_remove_by_data(s->core->sources, s, NULL);
- idxset_free(s->output_streams, do_free, NULL);