From 1d61239879e12ccbd0ac80fabfd272e8b785e8cf Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Wed, 28 Aug 2013 22:00:28 +0200 Subject: osx: cleanup, use of proper APIs; added new GUI plugin type to the enum in deadbeef.h --- main.c | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 38492360..26671058 100644 --- a/main.c +++ b/main.c @@ -697,31 +697,29 @@ restore_resume_state (void) { } } -typedef struct { - int argc; - char **argv; - char *cmdline; - int size; -} main_args_t; - -//uintptr_t gui_cond, gui_mutex; uintptr_t mainloop_tid; +DB_plugin_t * +plug_get_gui (void) { + struct DB_plugin_s **plugs = plug_get_list (); + for (int i = 0; plugs[i]; i++) { + if (plugs[i]->type == DB_PLUGIN_GUI) { + return plugs[i]; + } + } + return NULL; +} + static void mainloop_thread (void *ctx) { - main_args_t *args = ctx; - int argc = args->argc; - char **argv = args->argv; - char *cmdline = args->cmdline; - int size = args->size; - // this runs until DB_EV_TERMINATE is sent (blocks right here) player_mainloop (); // tell the gui thread to finish - DB_plugin_t *gui = plug_get_for_id ("gtkui3_1"); - gui->stop (); - //cond_signal (gui_cond); + DB_plugin_t *gui = plug_get_gui (); + if (gui) { + gui->stop (); + } return; } @@ -1014,16 +1012,12 @@ main (int argc, char *argv[]) { server_tid = thread_start (server_loop, NULL); - //gui_cond = cond_create (); - //gui_mutex = mutex_create (); - main_args_t args = {argc,argv,cmdline,size}; - mainloop_tid = thread_start (mainloop_thread, &args); -// fprintf (stderr, "waiting for GUI\n"); -// cond_wait (gui_cond, gui_mutex); -// mutex_unlock (gui_mutex); + mainloop_tid = thread_start (mainloop_thread, NULL); - DB_plugin_t *gui = plug_get_for_id ("gtkui3_1"); - gui->command (10, 0); + DB_plugin_t *gui = plug_get_gui (); + if (gui) { + gui->start (); + } fprintf (stderr, "gui plugin has quit; waiting for mainloop thread to finish\n"); thread_join (mainloop_tid); -- cgit v1.2.3