#include #include #include #include #include #include #include "paman.hh" #include "SinkWindow.hh" #include "MainWindow.hh" MainWindow *mainWindow = NULL; ServerInfo *serverInfo = NULL; struct pa_context *context = NULL; struct pa_mainloop_api *mainloop_api = NULL; static void context_complete_callback(struct pa_context *c, int success, void *userdata) { g_assert(c && mainWindow && !serverInfo); if (!success) { mainWindow->showFailure(pa_strerror(pa_context_errno(c))); //pa_context_free(context); /* Mrprmfmfl! */ context = NULL; mainWindow->connectButton->set_sensitive(true); return; } mainWindow->showSuccess("Connected"); mainWindow->connectButton->set_sensitive(false); serverInfo = new ServerInfo(*c); } static void die_callback(struct pa_context *c, void *userdata) { mainWindow->clearAllData(); mainWindow->showFailure(pa_strerror(pa_context_errno(c))); delete serverInfo; serverInfo = NULL; //pa_context_free(contetx); /* Mrprmfmfl! */ context = NULL; mainWindow->connectButton->set_sensitive(true); } void create_connection() { if (serverInfo) { delete serverInfo; serverInfo = NULL; } if (context) { pa_context_free(context); context = NULL; } mainWindow->showSuccess("Connecting ..."); context = pa_context_new(mainloop_api, "Polypaudio Manager"); g_assert(context); pa_context_set_die_callback(context, die_callback, NULL); if (pa_context_connect(context, NULL, context_complete_callback, NULL) < 0) { context_complete_callback(context, 0, NULL); return; } mainWindow->connectButton->set_sensitive(false); } int main(int argc, char *argv[]) { struct pa_glib_mainloop *m; signal(SIGPIPE, SIG_IGN); Gtk::Main kit(argc, argv); mainWindow = MainWindow::create(); g_assert(mainWindow); m = pa_glib_mainloop_new(g_main_context_default()); g_assert(m); mainloop_api = pa_glib_mainloop_get_api(m); g_assert(mainloop_api); create_connection(); Gtk::Main::run(*mainWindow); quit: if (serverInfo) delete serverInfo; if (context) pa_context_free(context); mainloop_api = NULL; if (mainWindow) delete mainWindow; pa_glib_mainloop_free(m); return 0; }