From 9ab2dc0b904c5b684c7b408c479253cb51de52de Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 14 Jul 2010 22:17:27 +0200 Subject: replace pulseaudio's mainloop with glib-mainloop --- src/Makefile.am | 6 +++--- src/pa-sink-ctl.c | 38 +++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 8b4e688..1d800a5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ bin_PROGRAMS = pa_sink_ctl -pa_sink_ctl_SOURCES =interface.c pa-sink-ctl.c sink.c sink_input.c +pa_sink_ctl_SOURCES = interface.c pa-sink-ctl.c sink.c sink_input.c -AM_CFLAGS =-std=c99 -pedantic -Wall -Werror @PULSE_CFLAGS@ -pa_sink_ctl_LDADD =@PULSE_LIBS@ @CURSES_LIBS@ +AM_CFLAGS = -std=c99 -pedantic -Wall -Werror @PULSE_CFLAGS@ @PULSE_MAINLOOP_CFLAGS@ @GLIB_CFLAGS@ +pa_sink_ctl_LDADD = @PULSE_LIBS@ @PULSE_MAINLOOP_LIBS@ @GLIB_LIBS@ @CURSES_LIBS@ noinst_HEADERS = interface.h pa-sink-ctl.h sink.h sink_input.h 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 #include +#include +#include + +#include + #include +#include + #include -#include #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 -- cgit