diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-08-05 19:53:57 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-08-05 19:53:57 +0000 |
commit | 964bdfd1e8255b57e9d22cd22b3784e2fc79b905 (patch) | |
tree | 11676e2930adb42af6ac00e721c4b2a73baf35ef /polyp/module-oss-mmap.c | |
parent | 839f99ffbf5b01e585845a061830a6fa5f0743dc (diff) |
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
Diffstat (limited to 'polyp/module-oss-mmap.c')
-rw-r--r-- | polyp/module-oss-mmap.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/polyp/module-oss-mmap.c b/polyp/module-oss-mmap.c index 37710fc5..ea768a98 100644 --- a/polyp/module-oss-mmap.c +++ b/polyp/module-oss-mmap.c @@ -59,7 +59,7 @@ struct userdata { void *in_mmap, *out_mmap; size_t in_mmap_length, out_mmap_length; - void *mainloop_source; + struct pa_io_event *io_event; struct pa_memblock **in_memblocks, **out_memblocks; unsigned out_current, in_current; @@ -195,14 +195,13 @@ static void do_read(struct userdata *u) { in_clear_memblocks(u, u->in_fragments/2); }; -static void io_callback(struct pa_mainloop_api *m, void *id, int fd, enum pa_mainloop_api_io_events events, void *userdata) { +static void io_callback(struct pa_mainloop_api *m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) { struct userdata *u = userdata; + assert (u && u->core->mainloop == m && u->io_event == e); - assert (u && u->core->mainloop == m && u->mainloop_source == id); - - if (events & PA_MAINLOOP_API_IO_EVENT_INPUT) + if (f & PA_IO_EVENT_INPUT) do_read(u); - if (events & PA_MAINLOOP_API_IO_EVENT_OUTPUT) + if (f & PA_IO_EVENT_OUTPUT) do_write(u); } @@ -352,8 +351,8 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) { assert(u->source || u->sink); - u->mainloop_source = c->mainloop->source_io(c->mainloop, u->fd, (u->source ? PA_MAINLOOP_API_IO_EVENT_INPUT : 0) | (u->sink ? PA_MAINLOOP_API_IO_EVENT_OUTPUT : 0), io_callback, u); - assert(u->mainloop_source); + u->io_event = c->mainloop->io_new(c->mainloop, u->fd, (u->source ? PA_IO_EVENT_INPUT : 0) | (u->sink ? PA_IO_EVENT_OUTPUT : 0), io_callback, u); + assert(u->io_event); pa_modargs_free(ma); @@ -403,8 +402,8 @@ void pa_module_done(struct pa_core *c, struct pa_module*m) { if (u->source) pa_source_free(u->source); - if (u->mainloop_source) - u->core->mainloop->cancel_io(u->core->mainloop, u->mainloop_source); + if (u->io_event) + u->core->mainloop->io_free(u->io_event); if (u->fd >= 0) close(u->fd); |