summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-08-28 22:00:28 +0200
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-08-28 22:00:28 +0200
commit1d61239879e12ccbd0ac80fabfd272e8b785e8cf (patch)
treecc379ae31f3e7b81c1c330ada9e278907be68abd /main.c
parentd48b231a9f258688fbe87cb6a07934d72e16b855 (diff)
osx: cleanup, use of proper APIs; added new GUI plugin type to the enum in deadbeef.h
Diffstat (limited to 'main.c')
-rw-r--r--main.c46
1 files changed, 20 insertions, 26 deletions
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);