mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
a bunch of fixes
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@10 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
edfad835cb
commit
c8cf0c1ce9
8 changed files with 28 additions and 21 deletions
|
|
@ -152,8 +152,8 @@ int idxset_put(struct idxset*s, void *p, uint32_t *index) {
|
|||
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;
|
||||
|
||||
|
|
@ -185,6 +185,9 @@ void* idxset_get_by_index(struct idxset*s, uint32_t index) {
|
|||
if (!(a = array_index(s, index)))
|
||||
return NULL;
|
||||
|
||||
if (!*a)
|
||||
return NULL;
|
||||
|
||||
return (*a)->data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,15 +41,15 @@ static void enable_mainloop_sources(struct iochannel *io) {
|
|||
|
||||
static void callback(struct mainloop_source*s, int fd, enum mainloop_io_event events, void *userdata) {
|
||||
struct iochannel *io = userdata;
|
||||
int changed;
|
||||
int changed = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
if (events & MAINLOOP_IO_EVENT_OUT && !io->writable) {
|
||||
if ((events & MAINLOOP_IO_EVENT_OUT) && !io->writable) {
|
||||
io->writable = 1;
|
||||
changed = 1;
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ void iochannel_free(struct iochannel*io) {
|
|||
|
||||
if (io->input_source)
|
||||
mainloop_source_free(io->input_source);
|
||||
if (io->output_source)
|
||||
if (io->output_source && io->output_source != io->input_source)
|
||||
mainloop_source_free(io->output_source);
|
||||
|
||||
free(io);
|
||||
|
|
|
|||
|
|
@ -248,8 +248,10 @@ int mainloop_iterate(struct mainloop *m, int block) {
|
|||
}
|
||||
}
|
||||
|
||||
if (m->rebuild_pollfds)
|
||||
if (m->rebuild_pollfds) {
|
||||
rebuild_pollfds(m);
|
||||
m->rebuild_pollfds = 0;
|
||||
}
|
||||
|
||||
m->running = 1;
|
||||
|
||||
|
|
@ -431,7 +433,7 @@ void mainloop_source_enable(struct mainloop_source*s, int b) {
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void memblockq_free(struct memblockq* bq) {
|
|||
|
||||
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);
|
||||
|
|
@ -152,5 +152,5 @@ void memblockq_empty(struct memblockq *bq) {
|
|||
int memblockq_is_empty(struct memblockq *bq) {
|
||||
assert(bq);
|
||||
|
||||
return bq->total_length >= bq->base;
|
||||
return bq->total_length < bq->base;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,10 @@ static void on_connection(struct socket_server*s, struct iochannel *io, void *us
|
|||
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;
|
||||
|
||||
|
|
@ -128,8 +131,6 @@ static void on_connection(struct socket_server*s, struct iochannel *io, void *us
|
|||
assert(c->istream);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -137,6 +138,8 @@ static void on_connection(struct socket_server*s, struct iochannel *io, void *us
|
|||
|
||||
fail:
|
||||
if (c) {
|
||||
if (c->client)
|
||||
client_free(c->client);
|
||||
if (c->istream)
|
||||
input_stream_free(c->istream);
|
||||
if (c->ostream)
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ static int get_max_length(void *p, uint32_t index, int *del, void*userdata) {
|
|||
info->count++;
|
||||
info->last_input_stream = i;
|
||||
|
||||
memblock_unref(chunk.memblock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ fail:
|
|||
struct socket_server* socket_server_new_ipv4(struct mainloop *m, uint32_t address, uint16_t port) {
|
||||
int fd = -1;
|
||||
struct sockaddr_in sa;
|
||||
int on = 1;
|
||||
|
||||
assert(m && port);
|
||||
|
||||
|
|
@ -112,10 +113,13 @@ struct socket_server* socket_server_new_ipv4(struct mainloop *m, uint32_t addres
|
|||
goto fail;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
|
||||
fprintf(stderr, "bind(): %s\n", strerror(errno));
|
||||
goto fail;
|
||||
|
|
|
|||
|
|
@ -27,12 +27,6 @@ struct source* source_new(struct core *core, const char *name, const struct samp
|
|||
return s;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -42,7 +36,6 @@ void source_free(struct source *s) {
|
|||
idxset_free(s->output_streams, NULL, NULL);
|
||||
|
||||
idxset_remove_by_data(s->core->sources, s, NULL);
|
||||
idxset_free(s->output_streams, do_free, NULL);
|
||||
|
||||
free(s->name);
|
||||
free(s);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue