mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
add initial glib mainloop adapter
clean up mainloop API git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@105 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
839f99ffbf
commit
964bdfd1e8
36 changed files with 1312 additions and 628 deletions
|
|
@ -45,7 +45,7 @@ struct connection {
|
|||
struct pa_source_output *source_output;
|
||||
struct pa_client *client;
|
||||
struct pa_memblockq *input_memblockq, *output_memblockq;
|
||||
void *fixed_source;
|
||||
struct pa_defer_event *defer_event;
|
||||
|
||||
struct {
|
||||
struct pa_memblock *current_memblock;
|
||||
|
|
@ -91,8 +91,8 @@ static void connection_free(struct connection *c) {
|
|||
pa_memblockq_free(c->input_memblockq);
|
||||
if (c->output_memblockq)
|
||||
pa_memblockq_free(c->output_memblockq);
|
||||
if (c->fixed_source)
|
||||
c->protocol->core->mainloop->cancel_fixed(c->protocol->core->mainloop, c->fixed_source);
|
||||
if (c->defer_event)
|
||||
c->protocol->core->mainloop->defer_free(c->defer_event);
|
||||
pa_xfree(c);
|
||||
}
|
||||
|
||||
|
|
@ -169,8 +169,8 @@ static int do_write(struct connection *c) {
|
|||
static void do_work(struct connection *c) {
|
||||
assert(c);
|
||||
|
||||
assert(c->protocol && c->protocol->core && c->protocol->core->mainloop && c->protocol->core->mainloop->enable_fixed);
|
||||
c->protocol->core->mainloop->enable_fixed(c->protocol->core->mainloop, c->fixed_source, 0);
|
||||
assert(c->protocol && c->protocol->core && c->protocol->core->mainloop && c->protocol->core->mainloop->defer_enable);
|
||||
c->protocol->core->mainloop->defer_enable(c->defer_event, 0);
|
||||
|
||||
if (pa_iochannel_is_hungup(c->io))
|
||||
goto fail;
|
||||
|
|
@ -209,8 +209,8 @@ static void sink_input_drop_cb(struct pa_sink_input *i, size_t length) {
|
|||
pa_memblockq_drop(c->input_memblockq, length);
|
||||
|
||||
/* do something */
|
||||
assert(c->protocol && c->protocol->core && c->protocol->core->mainloop && c->protocol->core->mainloop->enable_fixed);
|
||||
c->protocol->core->mainloop->enable_fixed(c->protocol->core->mainloop, c->fixed_source, 1);
|
||||
assert(c->protocol && c->protocol->core && c->protocol->core->mainloop && c->protocol->core->mainloop->defer_enable);
|
||||
c->protocol->core->mainloop->defer_enable(c->defer_event, 1);
|
||||
}
|
||||
|
||||
static void sink_input_kill_cb(struct pa_sink_input *i) {
|
||||
|
|
@ -234,8 +234,8 @@ static void source_output_push_cb(struct pa_source_output *o, const struct pa_me
|
|||
pa_memblockq_push(c->output_memblockq, chunk, 0);
|
||||
|
||||
/* do something */
|
||||
assert(c->protocol && c->protocol->core && c->protocol->core->mainloop && c->protocol->core->mainloop->enable_fixed);
|
||||
c->protocol->core->mainloop->enable_fixed(c->protocol->core->mainloop, c->fixed_source, 1);
|
||||
assert(c->protocol && c->protocol->core && c->protocol->core->mainloop && c->protocol->core->mainloop->defer_enable);
|
||||
c->protocol->core->mainloop->defer_enable(c->defer_event, 1);
|
||||
}
|
||||
|
||||
static void source_output_kill_cb(struct pa_source_output *o) {
|
||||
|
|
@ -261,9 +261,9 @@ static void io_callback(struct pa_iochannel*io, void *userdata) {
|
|||
|
||||
/*** fixed callback ***/
|
||||
|
||||
static void fixed_callback(struct pa_mainloop_api*a, void *id, void *userdata) {
|
||||
static void defer_callback(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata) {
|
||||
struct connection *c = userdata;
|
||||
assert(a && c && c->fixed_source == id);
|
||||
assert(a && c && c->defer_event == e);
|
||||
|
||||
do_work(c);
|
||||
}
|
||||
|
|
@ -280,7 +280,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
|
|||
c->io = io;
|
||||
c->sink_input = NULL;
|
||||
c->source_output = NULL;
|
||||
c->fixed_source = NULL;
|
||||
c->defer_event = NULL;
|
||||
c->input_memblockq = c->output_memblockq = NULL;
|
||||
c->protocol = p;
|
||||
c->playback.current_memblock = NULL;
|
||||
|
|
@ -353,9 +353,9 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
|
|||
pa_iochannel_set_callback(c->io, io_callback, c);
|
||||
pa_idxset_put(p->connections, c, NULL);
|
||||
|
||||
c->fixed_source = p->core->mainloop->source_fixed(p->core->mainloop, fixed_callback, c);
|
||||
assert(c->fixed_source);
|
||||
p->core->mainloop->enable_fixed(p->core->mainloop, c->fixed_source, 0);
|
||||
c->defer_event = p->core->mainloop->defer_new(p->core->mainloop, defer_callback, c);
|
||||
assert(c->defer_event);
|
||||
p->core->mainloop->defer_enable(c->defer_event, 0);
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue