diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-08-20 20:20:20 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-08-20 20:20:20 +0000 |
commit | 5e8bb1410e422e144538f1bf6e56dcf47ff0b99d (patch) | |
tree | c95b5a0a48cc082db91008c407f471ea00c798cb /polyp/mainloop-test.c | |
parent | 669452e4e59add411023aa3ae1ef1e67d380026c (diff) |
add support for glib12
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@150 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/mainloop-test.c')
-rw-r--r-- | polyp/mainloop-test.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/polyp/mainloop-test.c b/polyp/mainloop-test.c index c2517065..92b83c14 100644 --- a/polyp/mainloop-test.c +++ b/polyp/mainloop-test.c @@ -29,12 +29,21 @@ #include <assert.h> #ifdef GLIB_MAIN_LOOP + #include <glib.h> #include "glib-mainloop.h" static GMainLoop* glib_main_loop = NULL; + +#if GLIB_MAJOR_VERSION >= 2 +#define GLIB20 #else +#undef GLIB20 +#endif + + +#else /* GLIB_MAIN_LOOP */ #include "mainloop.h" -#endif +#endif /* GLIB_MAIN_LOOP */ static struct pa_defer_event *de; @@ -53,8 +62,10 @@ static void dcb(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userda static void tcb(struct pa_mainloop_api*a, struct pa_time_event *e, const struct timeval *tv, void *userdata) { fprintf(stderr, "TIME EVENT\n"); -#ifdef GLIB_MAIN_LOOP +#if defined(GLIB_MAIN_LOOP) && defined(GLIB20) g_main_loop_quit(glib_main_loop); +#elif defined(GLIB_MAIN_LOOP) + g_main_quit(glib_main_loop); #else a->quit(a, 0); #endif @@ -68,15 +79,23 @@ int main(int argc, char *argv[]) { #ifdef GLIB_MAIN_LOOP struct pa_glib_mainloop *g; + +#ifdef GLIB20 glib_main_loop = g_main_loop_new(NULL, FALSE); assert(glib_main_loop); g = pa_glib_mainloop_new(NULL); +#else /* GLIB20 */ + glib_main_loop = g_main_new(FALSE); + assert(glib_main_loop); + + g = pa_glib_mainloop_new(); +#endif /* GLIB20 */ assert(g); a = pa_glib_mainloop_get_api(g); assert(a); -#else +#else /* GLIB_MAIN_LOOP */ struct pa_mainloop *m; m = pa_mainloop_new(); @@ -84,7 +103,7 @@ int main(int argc, char *argv[]) { a = pa_mainloop_get_api(m); assert(a); -#endif +#endif /* GLIB_MAIN_LOOP */ ioe = a->io_new(a, 0, PA_IO_EVENT_INPUT, iocb, NULL); assert(ioe); @@ -96,8 +115,10 @@ int main(int argc, char *argv[]) { tv.tv_sec += 10; te = a->time_new(a, &tv, tcb, NULL); -#ifdef GLIB_MAIN_LOOP +#if defined(GLIB_MAIN_LOOP) && defined(GLIB20) g_main_loop_run(glib_main_loop); +#elif defined(GLIB_MAIN_LOOP) + g_main_run(glib_main_loop); #else pa_mainloop_run(m, NULL); #endif @@ -108,8 +129,12 @@ int main(int argc, char *argv[]) { #ifdef GLIB_MAIN_LOOP pa_glib_mainloop_free(g); +#ifdef GLIB20 g_main_loop_unref(glib_main_loop); #else + g_main_destroy(glib_main_loop); +#endif +#else pa_mainloop_free(m); #endif |