diff options
author | ben <benjaminfranzke@googlemail.com> | 2010-07-14 22:17:27 +0200 |
---|---|---|
committer | ben <benjaminfranzke@googlemail.com> | 2010-07-14 22:20:34 +0200 |
commit | 9ab2dc0b904c5b684c7b408c479253cb51de52de (patch) | |
tree | c478883a88516d7e30053435ce78c7cf66087cce /src/pa-sink-ctl.c | |
parent | 5dd57288b078e1201bd53a982648a0a18e56bc46 (diff) | |
download | pa-sink-ctl-9ab2dc0b904c5b684c7b408c479253cb51de52de.tar.gz pa-sink-ctl-9ab2dc0b904c5b684c7b408c479253cb51de52de.tar.bz2 pa-sink-ctl-9ab2dc0b904c5b684c7b408c479253cb51de52de.zip |
replace pulseaudio's mainloop with glib-mainloop
Diffstat (limited to 'src/pa-sink-ctl.c')
-rw-r--r-- | src/pa-sink-ctl.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c index 0d3a5bc..44a6fcc 100644 --- a/src/pa-sink-ctl.c +++ b/src/pa-sink-ctl.c @@ -1,9 +1,14 @@ #define _XOPEN_SOURCE 500 -#include <string.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <glib.h> + #include <pulse/pulseaudio.h> +#include <pulse/glib-mainloop.h> + #include <ncurses.h> -#include <stdlib.h> #include "sink_input.h" #include "sink.h" @@ -20,7 +25,7 @@ uint32_t sink_counter; uint32_t sink_max; pa_mainloop_api *mainloop_api = NULL; -pa_context *context = NULL; +pa_context *context = NULL; // ncurses WINDOW *menu_win; @@ -30,20 +35,25 @@ int starty; int main(int argc, char** argv) { + GMainContext *g_context = NULL; + GMainLoop *g_loop = NULL; + pa_glib_mainloop *m = NULL; + sink_counter = 0; sink_max = 1; sink_list = sink_list_init(sink_max); interface_init(); - pa_mainloop *m = NULL; - int ret = 1; - if (!(m = pa_mainloop_new())) { - printf("error: pa_mainloop_new() failed.\n"); + g_context = g_main_context_new(); + g_loop = g_main_loop_new(g_context, false); + + if (!(m = pa_glib_mainloop_new(g_context))) { + printf("error: pa_glib_mainloop_new() failed.\n"); return -1; } - mainloop_api = pa_mainloop_get_api(m); + mainloop_api = pa_glib_mainloop_get_api(m); if (!(context = pa_context_new(mainloop_api, "pa-sink-ctl"))) { printf("error: pa_context_new() failed.\n"); @@ -56,12 +66,14 @@ int main(int argc, char** argv) printf("error: pa_context_connect() failed.\n"); } - if (pa_mainloop_run(m, &ret) < 0) { - printf("error: pa_mainloop_run() failed.\n"); - return -1; - } + g_main_loop_run(g_loop); + + pa_glib_mainloop_free(m); + + g_main_loop_unref(g_loop); + g_main_context_unref(g_context); - return ret; + return 0; } /* * is called after connection |