aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-05-21 09:41:10 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-05-21 09:41:10 +0200
commit0f2954ac0278ce6e5ea95b9d42bdb98736415eb6 (patch)
tree1ae33e594de19d11ec8a92cd4b6097eed679741d
parentc50abfff6b7ae8b93c990681ee9df50cefd92330 (diff)
downloadsynthpod-0f2954ac0278ce6e5ea95b9d42bdb98736415eb6.tar.xz
prototype automatic UI loading.
* re-add -g/-G command line arguments. * if started with UI, closing UI closes app, too.
-rw-r--r--VERSION2
-rw-r--r--bin/synthpod_alsa.112
-rw-r--r--bin/synthpod_alsa.c9
-rw-r--r--bin/synthpod_bin.c79
-rw-r--r--bin/synthpod_bin.h4
-rw-r--r--bin/synthpod_dummy.112
-rw-r--r--bin/synthpod_dummy.c9
-rw-r--r--bin/synthpod_jack.112
-rw-r--r--bin/synthpod_jack.c9
-rw-r--r--include/synthpod_common.h8
-rw-r--r--include/synthpod_private.h5
-rw-r--r--plugins/synthpod_common_nk.c15
-rw-r--r--plugins/synthpod_lv2.h49
13 files changed, 177 insertions, 48 deletions
diff --git a/VERSION b/VERSION
index 622672aa..888a67fc 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.4975
+0.1.4977
diff --git a/bin/synthpod_alsa.1 b/bin/synthpod_alsa.1
index c4a0aeae..e8cb54e3 100644
--- a/bin/synthpod_alsa.1
+++ b/bin/synthpod_alsa.1
@@ -26,6 +26,16 @@ Print version and license information
Print usage information
.HP
+\fB\-g\fR
+.IP
+Load GUI
+
+.HP
+\fB\-G\fR
+.IP
+Do NOT load GUI (default)
+
+.HP
\fB\-b\fR
.IP
Enable bad plugins
@@ -33,7 +43,7 @@ Enable bad plugins
.HP
\fB\-B\fR
.IP
-Disable bad plugins (default
+Disable bad plugins (default)
.HP
\fB\-O\fR
diff --git a/bin/synthpod_alsa.c b/bin/synthpod_alsa.c
index 190b1d89..d113e992 100644
--- a/bin/synthpod_alsa.c
+++ b/bin/synthpod_alsa.c
@@ -876,6 +876,7 @@ main(int argc, char **argv)
bin->worker_prio = 60;
bin->num_slaves = sysconf(_SC_NPROCESSORS_ONLN) - 1;
bin->bad_plugins = false;
+ bin->has_gui = false;
bin->socket_path = "shm:///synthpod";
bin->update_rate = 25;
@@ -919,6 +920,8 @@ main(int argc, char **argv)
"OPTIONS\n"
" [-v] print version and full license information\n"
" [-h] print usage information\n"
+ " [-g] load GUI\n"
+ " [-G] do NOT load GUI (default)\n"
" [-b] enable bad plugins\n"
" [-B] disable bad plugins (default)\n"
" [-I] disable capture\n"
@@ -943,6 +946,12 @@ main(int argc, char **argv)
" [-f] update-rate GUI update rate (25)\n\n"
, argv[0]);
return 0;
+ case 'g':
+ bin->has_gui = true;
+ break;
+ case 'G':
+ bin->has_gui = true;
+ break;
case 'b':
bin->bad_plugins = true;
break;
diff --git a/bin/synthpod_bin.c b/bin/synthpod_bin.c
index 512ee14e..699aafa4 100644
--- a/bin/synthpod_bin.c
+++ b/bin/synthpod_bin.c
@@ -17,6 +17,9 @@
#include <getopt.h>
#include <inttypes.h>
+#include <unistd.h> // fork
+#include <sys/wait.h> // waitpid
+#include <errno.h> // waitpid
#include <synthpod_bin.h>
@@ -311,6 +314,31 @@ bin_init(bin_t *bin)
signal(SIGQUIT, _sig);
signal(SIGINT, _sig);
+ if(bin->has_gui)
+ {
+ char urate [32];
+ char wname [128];
+ snprintf(urate, 32, "%i", bin->update_rate);
+ snprintf(wname, 128, "Synthpod - %s", bin->socket_path);
+
+ bin->child = fork();
+ if(bin->child == 0) // child
+ {
+ char *const args [] = {
+ SYNTHPOD_BIN_DIR"synthpod_sandbox_x11",
+ "-p", SYNTHPOD_STEREO_URI,
+ "-b", SYNTHPOD_PLUGIN_DIR,
+ "-u", SYNTHPOD_ROOT_NK_URI,
+ "-s", (char *)bin->socket_path,
+ "-w", wname,
+ "-r", urate,
+ NULL
+ };
+
+ execvp(args[0], args);
+ }
+ }
+
uv_loop_init(&bin->loop);
}
@@ -337,9 +365,51 @@ bin_run(bin_t *bin, char **argv, const synthpod_nsm_driver_t *nsm_driver)
}
}
+ const unsigned nsecs = 1000000000;
+ struct timespec to;
+ clock_gettime(CLOCK_REALTIME, &to);
+ unsigned count = 0;
+
while(!atomic_load_explicit(&done, memory_order_relaxed))
{
- sandbox_master_wait(bin->sb);
+ const bool timedout = sandbox_master_timedwait(bin->sb, &to);
+
+ if(timedout)
+ {
+ // check if GUI still running
+ if(bin->has_gui && bin->child)
+ {
+ bool rolling = true;
+
+ int status;
+ const int res = waitpid(bin->child, &status, WUNTRACED | WNOHANG);
+ if(res < 0)
+ {
+ if(errno == ECHILD) // child not existing
+ rolling = false;
+ }
+ else if(res == bin->child)
+ {
+ if(!WIFSTOPPED(status) && !WIFCONTINUED(status)) // child exited/crashed
+ rolling = false;
+ }
+
+ if(!rolling)
+ {
+ bin->child = 0; // invalidate
+ atomic_store_explicit(&done, true, memory_order_relaxed);
+ }
+ }
+
+ // schedule next timeout
+ uint64_t nanos = to.tv_nsec + nsecs/20; // 10 Hz
+ while(nanos >= nsecs)
+ {
+ nanos -= nsecs;
+ to.tv_sec += 1;
+ }
+ to.tv_nsec = nanos;
+ }
// read events from UI shared mem
if(sandbox_master_recv(bin->sb))
@@ -380,6 +450,7 @@ bin_run(bin_t *bin, char **argv, const synthpod_nsm_driver_t *nsm_driver)
varchunk_read_advance(bin->app_to_log);
}
}
+
sched_yield();
}
}
@@ -390,6 +461,12 @@ bin_stop(bin_t *bin)
// NSM deinit
synthpod_nsm_free(bin->nsm);
+ if(bin->has_gui && bin->child)
+ {
+ kill(bin->child, SIGTERM);
+ bin->child = 0;
+ }
+
if(bin->path)
free(bin->path);
}
diff --git a/bin/synthpod_bin.h b/bin/synthpod_bin.h
index 3ed76e96..981cee75 100644
--- a/bin/synthpod_bin.h
+++ b/bin/synthpod_bin.h
@@ -30,6 +30,7 @@
#include <varchunk.h>
#include <sandbox_master.h>
+#include <synthpod_common.h>
#include <synthpod_nsm.h>
#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
@@ -88,6 +89,7 @@ struct _bin_t {
uv_thread_t self;
atomic_flag trace_lock;
+ bool has_gui;
int audio_prio;
int worker_prio;
int num_slaves;
@@ -98,6 +100,8 @@ struct _bin_t {
sandbox_master_driver_t sb_driver;
sandbox_master_t *sb;
+ pid_t child;
+
uv_loop_t loop;
};
diff --git a/bin/synthpod_dummy.1 b/bin/synthpod_dummy.1
index febbcde0..7804d2da 100644
--- a/bin/synthpod_dummy.1
+++ b/bin/synthpod_dummy.1
@@ -26,6 +26,16 @@ Print version and license information
Print usage information
.HP
+\fB\-g\fR
+.IP
+Load GUI
+
+.HP
+\fB\-G\fR
+.IP
+Do NOT load GUI (default)
+
+.HP
\fB\-b\fR
.IP
Enable bad plugins
@@ -33,7 +43,7 @@ Enable bad plugins
.HP
\fB\-B\fR
.IP
-Disable bad plugins (default
+Disable bad plugins (default)
.HP
\fB\-y\fR audio-priority
diff --git a/bin/synthpod_dummy.c b/bin/synthpod_dummy.c
index 56417c0d..6b920b79 100644
--- a/bin/synthpod_dummy.c
+++ b/bin/synthpod_dummy.c
@@ -446,6 +446,7 @@ main(int argc, char **argv)
bin->worker_prio = 60;
bin->num_slaves = sysconf(_SC_NPROCESSORS_ONLN) - 1;
bin->bad_plugins = false;
+ bin->has_gui = false;
bin->socket_path = "shm:///synthpod";
bin->update_rate = 25;
@@ -484,6 +485,8 @@ main(int argc, char **argv)
"OPTIONS\n"
" [-v] print version and full license information\n"
" [-h] print usage information\n"
+ " [-g] load GUI\n"
+ " [-G] do NOT load GUI (default)\n"
" [-b] enable bad plugins\n"
" [-B] disable bad plugins (default)\n"
" [-y] audio-priority audio thread realtime priority (70)\n"
@@ -498,6 +501,12 @@ main(int argc, char **argv)
" [-f] update-rate GUI update rate (25)\n\n"
, argv[0]);
return 0;
+ case 'g':
+ bin->has_gui = true;
+ break;
+ case 'G':
+ bin->has_gui = true;
+ break;
case 'b':
bin->bad_plugins = true;
break;
diff --git a/bin/synthpod_jack.1 b/bin/synthpod_jack.1
index 1480a55a..cf1c0d2e 100644
--- a/bin/synthpod_jack.1
+++ b/bin/synthpod_jack.1
@@ -26,6 +26,16 @@ Print version and license information
Print usage information
.HP
+\fB\-g\fR
+.IP
+Load GUI
+
+.HP
+\fB\-G\fR
+.IP
+Do NOT load GUI (default)
+
+.HP
\fB\-b\fR
.IP
Enable bad plugins
@@ -33,7 +43,7 @@ Enable bad plugins
.HP
\fB\-B\fR
.IP
-Disable bad plugins (default
+Disable bad plugins (default)
.HP
\fB\-w\fR worker-priority
diff --git a/bin/synthpod_jack.c b/bin/synthpod_jack.c
index 18252f53..2df686a1 100644
--- a/bin/synthpod_jack.c
+++ b/bin/synthpod_jack.c
@@ -955,6 +955,7 @@ main(int argc, char **argv)
bin->worker_prio = 60;
bin->num_slaves = sysconf(_SC_NPROCESSORS_ONLN) - 1;
bin->bad_plugins = false;
+ bin->has_gui = false;
bin->socket_path = "shm:///synthpod";
bin->update_rate = 25;
@@ -993,6 +994,8 @@ main(int argc, char **argv)
"OPTIONS\n"
" [-v] print version and full license information\n"
" [-h] print usage information\n"
+ " [-g] load GUI\n"
+ " [-G] do NOT load GUI (default)\n"
" [-b] enable bad plugins\n"
" [-B] disable bad plugins (default)\n"
" [-w] worker-priority worker thread realtime priority (60)\n"
@@ -1005,6 +1008,12 @@ main(int argc, char **argv)
" [-f] update-rate GUI update rate (25)\n\n"
, argv[0]);
return 0;
+ case 'g':
+ bin->has_gui = true;
+ break;
+ case 'G':
+ bin->has_gui = true;
+ break;
case 'b':
bin->bad_plugins = true;
break;
diff --git a/include/synthpod_common.h b/include/synthpod_common.h
index 2523859d..bdb32431 100644
--- a/include/synthpod_common.h
+++ b/include/synthpod_common.h
@@ -18,6 +18,7 @@
#ifndef _SYNTHPOD_COMMON_H
#define _SYNTHPOD_COMMON_H
+#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
@@ -25,11 +26,14 @@
#include <string.h>
#include <ftw.h>
-#define SYNTHPOD_PREFIX "http://open-music-kontrollers.ch/lv2/synthpod#"
+#define SYNTHPOD_PREFIX "http://open-music-kontrollers.ch/lv2/synthpod#"
+
+#define SYNTHPOD_STEREO_URI SYNTHPOD_PREFIX"stereo"
+#define SYNTHPOD_COMMON_NK_URI SYNTHPOD_PREFIX"common_4_nk"
+#define SYNTHPOD_ROOT_NK_URI SYNTHPOD_PREFIX"root_4_nk"
#ifdef _WIN32
# define SYNTHPOD_SYMBOL_EXTERN __declspec(dllexport)
-# include <Evil.h>
# define mlock(...)
# define munlock(...)
#else
diff --git a/include/synthpod_private.h b/include/synthpod_private.h
index fc1ea85d..df03dea4 100644
--- a/include/synthpod_private.h
+++ b/include/synthpod_private.h
@@ -18,9 +18,7 @@
#ifndef _SYNTHPOD_PRIVATE_H
#define _SYNTHPOD_PRIVATE_H
-#define SYNTHPOD_PREFIX "http://open-music-kontrollers.ch/lv2/synthpod#"
#define SYNTHPOD_WORLD SYNTHPOD_PREFIX"world"
-#define LV2_UI__EoUI LV2_UI_PREFIX"EoUI"
#if defined(HAS_BUILTIN_ASSUME_ALIGNED)
# define ASSUME_ALIGNED(PTR) __builtin_assume_aligned((PTR), 8)
@@ -165,7 +163,6 @@ struct _reg_t {
} log;
struct {
- reg_item_t eo;
reg_item_t window_title;
reg_item_t show_interface;
reg_item_t idle_interface;
@@ -452,7 +449,6 @@ sp_regs_init(reg_t *regs, LilvWorld *world, LV2_URID_Map *map)
_register(&regs->log.trace, world, map, LV2_LOG__Trace);
_register(&regs->log.warning, world, map, LV2_LOG__Warning);
- _register(&regs->ui.eo, world, map, LV2_UI__EoUI);
_register(&regs->ui.window_title, world, map, LV2_UI__windowTitle);
_register(&regs->ui.show_interface, world, map, LV2_UI__showInterface);
_register(&regs->ui.idle_interface, world, map, LV2_UI__idleInterface);
@@ -694,7 +690,6 @@ sp_regs_deinit(reg_t *regs)
_unregister(&regs->log.trace);
_unregister(&regs->log.warning);
- _unregister(&regs->ui.eo);
_unregister(&regs->ui.window_title);
_unregister(&regs->ui.show_interface);
_unregister(&regs->ui.idle_interface);
diff --git a/plugins/synthpod_common_nk.c b/plugins/synthpod_common_nk.c
index 093d3706..017be5eb 100644
--- a/plugins/synthpod_common_nk.c
+++ b/plugins/synthpod_common_nk.c
@@ -17,6 +17,7 @@
#include <synthpod_lv2.h>
#include <synthpod_patcher.h>
+#include <synthpod_common.h>
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
@@ -2012,31 +2013,31 @@ _mod_ui_run(mod_ui_t *mod_ui)
{} // never reached
#if defined(SANDBOX_X11)
else if(lilv_ui_is_a(ui, handle->regs.ui.x11.node))
- exec_uri = "/usr/local/bin/synthpod_sandbox_x11"; //FIXME prefix
+ exec_uri = SYNTHPOD_BIN_DIR"synthpod_sandbox_x11";
#endif
#if defined(SANDBOX_GTK2)
else if(lilv_ui_is_a(ui, handle->regs.ui.gtk2.node))
- exec_uri = "/usr/local/bin/synthpod_sandbox_gtk2"; //FIXME prefix
+ exec_uri = SYNTHPOD_BIN_DIR"synthpod_sandbox_gtk2";
#endif
#if defined(SANDBOX_GTK3)
else if(lilv_ui_is_a(ui, handle->regs.ui.gtk3.node))
- exec_uri = "/usr/local/bin/synthpod_sandbox_gtk3"; //FIXME prefix
+ exec_uri = SYNTHPOD_BIN_DIR"synthpod_sandbox_gtk3";
#endif
#if defined(SANDBOX_QT4)
else if(lilv_ui_is_a(ui, handle->regs.ui.qt4.node))
- exec_uri = "/usr/local/bin/synthpod_sandbox_qt4"; //FIXME prefix
+ exec_uri = SYNTHPOD_BIN_DIR"synthpod_sandbox_qt4";
#endif
#if defined(SANDBOX_QT5)
else if(lilv_ui_is_a(ui, handle->regs.ui.qt5.node))
- exec_uri = "/usr/local/bin/synthpod_sandbox_qt5"; //FIXME prefix
+ exec_uri = SYNTHPOD_BIN_DIR"synthpod_sandbox_qt5";
#endif
#if defined(SANDBOX_KX)
else if(lilv_ui_is_a(ui, handle->regs.ui.kx_widget.node))
- exec_uri = "/usr/local/bin/synthpod_sandbox_kx"; //FIXME prefix
+ exec_uri = SYNTHPOD_BIN_DIR"synthpod_sandbox_kx";
#endif
#if defined(SANDBOX_SHOW)
else if(lilv_world_ask(handle->world, ui_node, handle->regs.core.extension_data.node, handle->regs.ui.show_interface.node))
- exec_uri = "/usr/local/bin/synthpod_sandbox_show"; //FIXME prefix
+ exec_uri = SYNTHPOD_BIN_DIR"synthpod_sandbox_show";
#endif
mod_ui->sbox.sb = sandbox_master_new(&mod_ui->sbox.driver, mod_ui);
diff --git a/plugins/synthpod_lv2.h b/plugins/synthpod_lv2.h
index 42b128e7..7b58de9c 100644
--- a/plugins/synthpod_lv2.h
+++ b/plugins/synthpod_lv2.h
@@ -30,6 +30,8 @@
#include <xpress.lv2/xpress.h>
+#include <synthpod_common.h>
+
#define __realtime __attribute__((annotate("realtime")))
#define __non_realtime __attribute__((annotate("non-realtime")))
@@ -38,29 +40,27 @@
#define _ATOM_ALIGNED __attribute__((aligned(8)))
// bundle uri
-#define SYNTHPOD_URI "http://open-music-kontrollers.ch/lv2/synthpod"
-#define SYNTHPOD_EVENT_URI SYNTHPOD_URI"#event"
+#define SYNTHPOD_EVENT_URI SYNTHPOD_PREFIX"event"
extern xpress_map_t voice_map_fallback;
// plugin uris
-#define SYNTHPOD_STEREO_URI SYNTHPOD_URI"#stereo"
-#define SYNTHPOD_KEYBOARD_URI SYNTHPOD_URI"#keyboard"
-#define SYNTHPOD_CV2CONTROL_URI SYNTHPOD_URI"#cv2control"
-#define SYNTHPOD_CONTROL2CV_URI SYNTHPOD_URI"#control2cv"
-#define SYNTHPOD_CV2ATOM_URI SYNTHPOD_URI"#cv2atom"
-#define SYNTHPOD_ATOM2CV_URI SYNTHPOD_URI"#atom2cv"
-#define SYNTHPOD_MIDISPLITTER_URI SYNTHPOD_URI"#midisplitter"
-#define SYNTHPOD_HEAVYLOAD_URI SYNTHPOD_URI"#heavyload"
-#define SYNTHPOD_AUDIOXFADEMONO_URI SYNTHPOD_URI"#audioxfademono"
-#define SYNTHPOD_AUDIOXFADESTEREO_URI SYNTHPOD_URI"#audioxfadestereo"
-#define SYNTHPOD_ATOM2CONTROL_URI SYNTHPOD_URI"#atom2control"
-#define SYNTHPOD_MIDI2CONTROL_URI SYNTHPOD_URI"#midi2control"
-#define SYNTHPOD_PANIC_URI SYNTHPOD_URI"#panic"
-#define SYNTHPOD_STRING2CONTROL_URI SYNTHPOD_URI"#string2control"
-#define SYNTHPOD_CONTROL2ATOM_URI SYNTHPOD_URI"#control2atom"
-#define SYNTHPOD_MIXER_URI SYNTHPOD_URI"#mixer"
-#define SYNTHPOD_ANONYMIZER_URI SYNTHPOD_URI"#anonymizer"
+#define SYNTHPOD_KEYBOARD_URI SYNTHPOD_PREFIX"keyboard"
+#define SYNTHPOD_CV2CONTROL_URI SYNTHPOD_PREFIX"cv2control"
+#define SYNTHPOD_CONTROL2CV_URI SYNTHPOD_PREFIX"control2cv"
+#define SYNTHPOD_CV2ATOM_URI SYNTHPOD_PREFIX"cv2atom"
+#define SYNTHPOD_ATOM2CV_URI SYNTHPOD_PREFIX"atom2cv"
+#define SYNTHPOD_MIDISPLITTER_URI SYNTHPOD_PREFIX"midisplitter"
+#define SYNTHPOD_HEAVYLOAD_URI SYNTHPOD_PREFIX"heavyload"
+#define SYNTHPOD_AUDIOXFADEMONO_URI SYNTHPOD_PREFIX"audioxfademono"
+#define SYNTHPOD_AUDIOXFADESTEREO_URI SYNTHPOD_PREFIX"audioxfadestereo"
+#define SYNTHPOD_ATOM2CONTROL_URI SYNTHPOD_PREFIX"atom2control"
+#define SYNTHPOD_MIDI2CONTROL_URI SYNTHPOD_PREFIX"midi2control"
+#define SYNTHPOD_PANIC_URI SYNTHPOD_PREFIX"panic"
+#define SYNTHPOD_STRING2CONTROL_URI SYNTHPOD_PREFIX"string2control"
+#define SYNTHPOD_CONTROL2ATOM_URI SYNTHPOD_PREFIX"control2atom"
+#define SYNTHPOD_MIXER_URI SYNTHPOD_PREFIX"mixer"
+#define SYNTHPOD_ANONYMIZER_URI SYNTHPOD_PREFIX"anonymizer"
extern const LV2_Descriptor synthpod_stereo;
extern const LV2_Descriptor synthpod_keyboard;
@@ -80,15 +80,6 @@ extern const LV2_Descriptor synthpod_control2atom;
extern const LV2_Descriptor synthpod_mixer;
extern const LV2_Descriptor synthpod_anonymizer;
-// common UI uris
-#define SYNTHPOD_COMMON_UI_URI SYNTHPOD_URI"#common_1_ui"
-#define SYNTHPOD_COMMON_KX_URI SYNTHPOD_URI"#common_2_kx"
-#define SYNTHPOD_COMMON_EO_URI SYNTHPOD_URI"#common_3_eo"
-#define SYNTHPOD_COMMON_NK_URI SYNTHPOD_URI"#common_4_nk"
-
-#define SYNTHPOD_ROOT_EO_URI SYNTHPOD_URI"#root_3_eo"
-#define SYNTHPOD_ROOT_NK_URI SYNTHPOD_URI"#root_4_nk"
-
extern const LV2UI_Descriptor synthpod_common_1_ui;
extern const LV2UI_Descriptor synthpod_common_2_kx;
extern const LV2UI_Descriptor synthpod_common_3_eo;
@@ -98,7 +89,7 @@ extern const LV2UI_Descriptor synthpod_root_3_eo;
extern const LV2UI_Descriptor synthpod_root_4_nk;
// keyboard UI uris
-#define SYNTHPOD_KEYBOARD_NK_URI SYNTHPOD_URI"#keyboard_4_nk"
+#define SYNTHPOD_KEYBOARD_NK_URI SYNTHPOD_PREFIX"keyboard_4_nk"
extern const LV2UI_Descriptor synthpod_keyboard_4_nk;