diff options
author | ben <benjaminfranzke@googlemail.com> | 2010-07-23 00:15:03 +0200 |
---|---|---|
committer | ben <benjaminfranzke@googlemail.com> | 2010-07-23 00:15:03 +0200 |
commit | 621dba06222979156f4efd02832058b8f3900cd7 (patch) | |
tree | 08b8a756f0e2018a7cad18cd2fcbe70935568f77 /src/pa-sink-ctl.c | |
parent | f0fe027dc5e9ed9056c60f3b7300ea0bc8466411 (diff) | |
download | pa-sink-ctl-621dba06222979156f4efd02832058b8f3900cd7.tar.gz pa-sink-ctl-621dba06222979156f4efd02832058b8f3900cd7.tar.bz2 pa-sink-ctl-621dba06222979156f4efd02832058b8f3900cd7.zip |
smoothly exit now (pulse con & glib loop explicit)
Diffstat (limited to 'src/pa-sink-ctl.c')
-rw-r--r-- | src/pa-sink-ctl.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c index 23e0dbb..d541156 100644 --- a/src/pa-sink-ctl.c +++ b/src/pa-sink-ctl.c @@ -19,18 +19,15 @@ gboolean state_callback_pending = FALSE; int main(int argc, char** argv) { - GMainContext *g_context = NULL; - GMainLoop *g_loop = NULL; pa_glib_mainloop *m = NULL; sink_list = sink_list_alloc(); - interface_init(); + GMainLoop *g_loop = g_main_loop_new(NULL, FALSE); - g_context = g_main_context_default(); - g_loop = g_main_loop_new(g_context, FALSE); + interface_init(); - if (!(m = pa_glib_mainloop_new(g_context))) { + if (!(m = pa_glib_mainloop_new(NULL))) { printf("error: pa_glib_mainloop_new() failed.\n"); return -1; } @@ -43,17 +40,17 @@ int main(int argc, char** argv) } // define callback for connection init - pa_context_set_state_callback(context, context_state_callback, NULL); + pa_context_set_state_callback(context, context_state_callback, g_loop); if (pa_context_connect(context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL)) { printf("error: pa_context_connect() failed.\n"); } g_main_loop_run(g_loop); - pa_glib_mainloop_free(m); + printf("main loop quit\n"); + pa_glib_mainloop_free(m); g_main_loop_unref(g_loop); - g_main_context_unref(g_context); return 0; } @@ -93,6 +90,10 @@ void context_state_callback(pa_context *c, gpointer userdata) ), NULL, NULL))); break; + case PA_CONTEXT_TERMINATED: + printf("pulse connection terminated\n"); + g_main_loop_quit((GMainLoop *)userdata); + break; default: printf("unknown state\n"); break; @@ -171,7 +172,7 @@ void quit(void) { sink_list_free(sink_list); interface_clear(); - exit(0); + pa_context_disconnect(context); } /* |