summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--main.c194
-rw-r--r--plugins/gtkui/Makefile.am6
-rw-r--r--plugins/gtkui/callbacks.c5
-rw-r--r--plugins/gtkui/gtkui.c43
-rw-r--r--plugins/gtkui/gtkuigl.c2
-rw-r--r--plugins/gtkui/gtkuigl.h3
-rw-r--r--plugins/gtkui/hotkeys.c16
-rw-r--r--plugins/gtkui/widgets.c10
-rw-r--r--plugins/supereq/Makefile.am2
-rw-r--r--streamer.c10
11 files changed, 185 insertions, 108 deletions
diff --git a/Makefile.am b/Makefile.am
index 8e4a6bf3..f87ca513 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,7 +46,7 @@ deadbeef_SOURCES =\
sdkdir = $(pkgincludedir)
sdk_HEADERS = deadbeef.h
-deadbeef_LDADD = $(LDADD) $(DEPS_LIBS) $(ICONV_LIB) $(DL_LIBS) -lm -lpthread
+deadbeef_LDADD = $(LDADD) $(DEPS_LIBS) $(ICONV_LIB) $(DL_LIBS) -lm -lpthread
AM_CFLAGS = $(DEPS_CFLAGS) -std=c99
AM_CPPFLAGS = $(DEPS_CFLAGS)
diff --git a/main.c b/main.c
index e651aee9..f6bd4eca 100644
--- a/main.c
+++ b/main.c
@@ -697,6 +697,109 @@ restore_resume_state (void) {
}
}
+typedef struct {
+ int argc;
+ char **argv;
+ char *cmdline;
+ int size;
+} main_args_t;
+
+uintptr_t gui_cond, gui_mutex;
+void
+plugloader (void *ctx) {
+ main_args_t *args = ctx;
+ int argc = args->argc;
+ char **argv = args->argv;
+ char *cmdline = args->cmdline;
+ int size = args->size;
+
+ messagepump_init (); // required to push messages while handling commandline
+ if (plug_load_all ()) { // required to add files to playlist from commandline
+ exit (-1);
+ }
+
+ cond_signal (gui_cond);
+
+ pl_load_all ();
+ plt_set_curr_idx (conf_get_int ("playlist.current", 0));
+
+ // execute server commands in local context
+ int noloadpl = 0;
+ if (argc > 1) {
+ int res = server_exec_command_line (cmdline, size, NULL, 0);
+ // some of the server commands ran on 1st instance should terminate it
+ if (res == 2) {
+ noloadpl = 1;
+ }
+ else if (res > 0) {
+ exit (0);
+ }
+ else if (res < 0) {
+ exit (-1);
+ }
+ }
+
+ free (cmdline);
+
+#if 0
+ signal (SIGTERM, sigterm_handler);
+ atexit (atexit_handler); // helps to save in simple cases
+#endif
+
+ // start all subsystems
+ messagepump_push (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
+
+ streamer_init ();
+
+ plug_connect_all ();
+ messagepump_push (DB_EV_PLUGINSLOADED, 0, 0, 0);
+
+ if (!noloadpl) {
+ restore_resume_state ();
+ }
+
+ server_tid = thread_start (server_loop, NULL);
+ // this runs in main thread (blocks right here)
+ player_mainloop ();
+
+ // terminate server and wait for completion
+ if (server_tid) {
+ server_terminate = 1;
+ thread_join (server_tid);
+ server_tid = 0;
+ }
+
+ // save config
+ pl_save_all ();
+ conf_save ();
+
+ // delete legacy session file
+ {
+ char sessfile[1024]; // $HOME/.config/deadbeef/session
+ if (snprintf (sessfile, sizeof (sessfile), "%s/deadbeef/session", confdir) < sizeof (sessfile)) {
+ unlink (sessfile);
+ }
+ }
+
+ // stop receiving messages from outside
+ server_close ();
+
+ // plugins might still hold references to playitems,
+ // and query configuration in background
+ // so unload everything 1st before final cleanup
+ plug_disconnect_all ();
+ plug_unload_all ();
+
+ // at this point we can simply do exit(0), but let's clean up for debugging
+ pl_free (); // may access conf_*
+ conf_free ();
+ messagepump_free ();
+ plug_cleanup ();
+
+ fprintf (stderr, "hej-hej!\n");
+ return;
+}
+
int
main (int argc, char *argv[]) {
int portable = 0;
@@ -940,87 +1043,18 @@ main (int argc, char *argv[]) {
conf_set_str ("deadbeef_version", VERSION);
volume_set_db (conf_get_float ("playback.volume", 0)); // volume need to be initialized before plugins start
- messagepump_init (); // required to push messages while handling commandline
- if (plug_load_all ()) { // required to add files to playlist from commandline
- exit (-1);
- }
- pl_load_all ();
- plt_set_curr_idx (conf_get_int ("playlist.current", 0));
-
- // execute server commands in local context
- int noloadpl = 0;
- if (argc > 1) {
- int res = server_exec_command_line (cmdline, size, NULL, 0);
- // some of the server commands ran on 1st instance should terminate it
- if (res == 2) {
- noloadpl = 1;
- }
- else if (res > 0) {
- exit (0);
- }
- else if (res < 0) {
- exit (-1);
- }
- }
-
- free (cmdline);
-
-#if 0
- signal (SIGTERM, sigterm_handler);
- atexit (atexit_handler); // helps to save in simple cases
-#endif
+
+
+ gui_cond = cond_create ();
+ gui_mutex = mutex_create ();
+ main_args_t args = {argc,argv,cmdline,size};
+ thread_start (plugloader, NULL);
+ printf ("waiting for GUI\n");
+ cond_wait (gui_cond, gui_mutex);
+
+ DB_plugin_t *gui = plug_get_for_id ("gtkui3_1");
+ gui->command (10, 0);
- // start all subsystems
- messagepump_push (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
-
- streamer_init ();
-
- plug_connect_all ();
- messagepump_push (DB_EV_PLUGINSLOADED, 0, 0, 0);
-
- if (!noloadpl) {
- restore_resume_state ();
- }
-
- server_tid = thread_start (server_loop, NULL);
- // this runs in main thread (blocks right here)
- player_mainloop ();
-
- // terminate server and wait for completion
- if (server_tid) {
- server_terminate = 1;
- thread_join (server_tid);
- server_tid = 0;
- }
-
- // save config
- pl_save_all ();
- conf_save ();
-
- // delete legacy session file
- {
- char sessfile[1024]; // $HOME/.config/deadbeef/session
- if (snprintf (sessfile, sizeof (sessfile), "%s/deadbeef/session", confdir) < sizeof (sessfile)) {
- unlink (sessfile);
- }
- }
-
- // stop receiving messages from outside
- server_close ();
-
- // plugins might still hold references to playitems,
- // and query configuration in background
- // so unload everything 1st before final cleanup
- plug_disconnect_all ();
- plug_unload_all ();
-
- // at this point we can simply do exit(0), but let's clean up for debugging
- pl_free (); // may access conf_*
- conf_free ();
- messagepump_free ();
- plug_cleanup ();
-
- fprintf (stderr, "hej-hej!\n");
return 0;
}
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am
index 718418c2..b6651f8a 100644
--- a/plugins/gtkui/Makefile.am
+++ b/plugins/gtkui/Makefile.am
@@ -150,10 +150,10 @@ GTKGLEXT_SOURCES = \
gtkglext-gtk3/gdk/x11/gdkx11glquery.h\
gtkglext-gtk3/gdk/x11/gdkx11glwindow.h
-GTKGLEXT_CFLAGS = -I@top_srcdir@/plugins/gtkui/gtkglext-gtk3 -I@top_srcdir@/plugins/gtkui/gtkglext-gtk3/gdk -DGTK_GL_COMPILATION -DGDK_GL_COMPILATION
-GTKGLEXT_LIBS = -lGL
+GTKGLEXT_CFLAGS =
+GTKGLEXT_LIBS =
-ddb_gui_GTK3_la_SOURCES = $(GTKUI_SOURCES) $(GTKGLEXT_SOURCES)
+ddb_gui_GTK3_la_SOURCES = $(GTKUI_SOURCES)
ddb_gui_GTK3_la_LDFLAGS = -module
if STATICLINK
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index c1f09515..031aeb7d 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -27,7 +27,7 @@
#include <assert.h>
#include <ctype.h>
#include <gdk/gdkkeysyms.h>
-#include <X11/Xlib.h>
+//#include <X11/Xlib.h>
#include "../../gettext.h"
#include "callbacks.h"
@@ -183,6 +183,7 @@ on_mainwin_key_press_event (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
{
+#if 0
// local hotkeys
// first translate gdk modifiers into X11 constants
int mods = 0;
@@ -230,7 +231,7 @@ on_mainwin_key_press_event (GtkWidget *widget,
}
}
trace ("action not found\n");
-
+#endif
return FALSE;
}
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 8f54643b..ead2e28b 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -51,7 +51,7 @@
#include "gtkui_api.h"
#include "wingeom.h"
#include "widgets.h"
-#include "X11/Xlib.h"
+//#include "X11/Xlib.h"
#undef EGG_SM_CLIENT_BACKEND_XSMP
#ifdef EGG_SM_CLIENT_BACKEND_XSMP
#include "smclient/eggsmclient.h"
@@ -817,6 +817,12 @@ DB_playItem_t *
gtkui_plt_load (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
int
+gtkui_command (int n, ...) {
+ gtkui_thread (NULL);
+ return 0;
+}
+
+int
gtkui_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) {
ddb_gtkui_widget_t *rootwidget = w_get_rootwidget ();
if (rootwidget) {
@@ -824,6 +830,7 @@ gtkui_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) {
}
switch (id) {
case DB_EV_PLUGINSLOADED:
+ break;
// gtk must be running in separate thread
gtk_initialized = 0;
gtk_tid = deadbeef->thread_start (gtkui_thread, NULL);
@@ -832,21 +839,6 @@ gtkui_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) {
usleep (10000);
}
- // override default file adding APIs to show progress bar
- gtkui_original_plt_add_dir = deadbeef->plt_add_dir;
- deadbeef->plt_add_dir = gtkui_plt_add_dir;
-
- gtkui_original_plt_add_file = deadbeef->plt_add_file;
- deadbeef->plt_add_file = gtkui_plt_add_file;
-
- gtkui_original_pl_add_files_begin = deadbeef->pl_add_files_begin;
- deadbeef->pl_add_files_begin = gtkui_pl_add_files_begin;
-
- gtkui_original_pl_add_files_end = deadbeef->pl_add_files_end;
- deadbeef->pl_add_files_end = gtkui_pl_add_files_end;
-
- gtkui_original_plt_load = deadbeef->plt_load;
- deadbeef->plt_load = gtkui_plt_load;
break;
case DB_EV_ACTIVATED:
g_idle_add (activate_cb, NULL);
@@ -948,7 +940,7 @@ gtkui_thread (void *ctx) {
#ifdef __linux__
prctl (PR_SET_NAME, "deadbeef-gtkui", 0, 0, 0, 0);
#endif
- XInitThreads (); // gtkglext/xcb doesn't work without this
+ //XInitThreads (); // gtkglext/xcb doesn't work without this
// let's start some gtk
g_thread_init (NULL);
add_pixmap_directory (deadbeef->get_pixmap_dir ());
@@ -1110,6 +1102,22 @@ gtkui_thread (void *ctx) {
g_idle_add (unlock_playlist_columns_cb, NULL);
+ // override default file adding APIs to show progress bar
+ gtkui_original_plt_add_dir = deadbeef->plt_add_dir;
+ deadbeef->plt_add_dir = gtkui_plt_add_dir;
+
+ gtkui_original_plt_add_file = deadbeef->plt_add_file;
+ deadbeef->plt_add_file = gtkui_plt_add_file;
+
+ gtkui_original_pl_add_files_begin = deadbeef->pl_add_files_begin;
+ deadbeef->pl_add_files_begin = gtkui_pl_add_files_begin;
+
+ gtkui_original_pl_add_files_end = deadbeef->pl_add_files_end;
+ deadbeef->pl_add_files_end = gtkui_pl_add_files_end;
+
+ gtkui_original_plt_load = deadbeef->plt_load;
+ deadbeef->plt_load = gtkui_plt_load;
+
gtk_main ();
w_free ();
@@ -1766,5 +1774,6 @@ static ddb_gtkui_t plugin = {
.w_append = w_append,
.w_replace = w_replace,
.w_remove = w_remove,
+ .gui.plugin.command = gtkui_command,
.create_pltmenu = gtkui_create_pltmenu,
};
diff --git a/plugins/gtkui/gtkuigl.c b/plugins/gtkui/gtkuigl.c
index db2a5667..24423a10 100644
--- a/plugins/gtkui/gtkuigl.c
+++ b/plugins/gtkui/gtkuigl.c
@@ -21,6 +21,7 @@
#include "support.h"
#include "gtkuigl.h"
+#if 0
static int gl_initialized;
static int gl_init_state;
//PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
@@ -50,3 +51,4 @@ void
gtkui_gl_free (void) {
// ???
}
+#endif
diff --git a/plugins/gtkui/gtkuigl.h b/plugins/gtkui/gtkuigl.h
index ddba54dd..a19b36e2 100644
--- a/plugins/gtkui/gtkuigl.h
+++ b/plugins/gtkui/gtkuigl.h
@@ -19,6 +19,7 @@
#ifndef __GTKUIGL_H
#define __GTKUIGL_H
+#if 0
#include <gtk/gtkgl.h>
#include <GL/gl.h>
#include <GL/glu.h>
@@ -32,5 +33,5 @@
int
gtkui_gl_init (void);
-
+#endif
#endif
diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c
index d3026b5d..7b3d1664 100644
--- a/plugins/gtkui/hotkeys.c
+++ b/plugins/gtkui/hotkeys.c
@@ -57,9 +57,19 @@ typedef struct
#include "interface.h"
#include "../libparser/parser.h"
#include "../hotkeys/hotkeys.h"
-#include <X11/Xlib.h> // only for the KeySym type
+//#include <X11/Xlib.h> // only for the KeySym type
#include "hotkeys.h"
+#ifndef strdupa
+# define strdupa(s) \
+ ({ \
+ const char *old = (s); \
+ size_t len = strlen (old) + 1; \
+ char *new = (char *) alloca (len); \
+ (char *) memcpy (new, old, len); \
+ })
+#endif
+
void
on_hotkeys_actions_cursor_changed (GtkTreeView *treeview,
gpointer user_data);
@@ -600,13 +610,13 @@ on_hotkey_is_global_toggled (GtkToggleButton *togglebutton,
typedef struct {
const char *name;
- KeySym keysym;
+ int keysym;
} xkey_t;
#define KEY(kname, kcode) { .name=kname, .keysym=kcode },
static const xkey_t keys[] = {
- #include "../hotkeys/keysyms.inc"
+// #include "../hotkeys/keysyms.inc"
};
static const char *
diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c
index cbb9358e..7318d894 100644
--- a/plugins/gtkui/widgets.c
+++ b/plugins/gtkui/widgets.c
@@ -41,6 +41,16 @@
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
+#ifndef strdupa
+# define strdupa(s) \
+ ({ \
+ const char *old = (s); \
+ size_t len = strlen (old) + 1; \
+ char *new = (char *) alloca (len); \
+ (char *) memcpy (new, old, len); \
+ })
+#endif
+
// utility code for parsing keyvalues
#define get_keyvalue(s,key,val) {\
s = gettoken_ext (s, key, "={}();");\
diff --git a/plugins/supereq/Makefile.am b/plugins/supereq/Makefile.am
index 0096e4ab..ad476ee6 100644
--- a/plugins/supereq/Makefile.am
+++ b/plugins/supereq/Makefile.am
@@ -6,7 +6,7 @@ supereq_la_SOURCES = supereq.c Equ.cpp Equ.h Fftsg_fl.c paramlist.hpp
AM_CFLAGS = $(CFLAGS) -std=c99 -DUSE_OOURA
AM_CPPFLAGS = $(CXXFLAGS) -fno-exceptions -fno-rtti -nostdlib -fno-unwind-tables -DUSE_OOURA
-supereq_la_LDFLAGS = -module -nostdlib -lsupc++
+supereq_la_LDFLAGS = -module
supereq_la_LIBADD = $(LDADD)
endif
diff --git a/streamer.c b/streamer.c
index fe655d07..58e97172 100644
--- a/streamer.c
+++ b/streamer.c
@@ -57,6 +57,16 @@
//#define WRITE_DUMP 1
//#define DETECT_PL_LOCK_RC 1
+#ifndef strdupa
+# define strdupa(s) \
+ ({ \
+ const char *old = (s); \
+ size_t len = strlen (old) + 1; \
+ char *new = (char *) alloca (len); \
+ (char *) memcpy (new, old, len); \
+ })
+#endif
+
#if WRITE_DUMP
FILE *out;
#endif