aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-04-27 00:43:14 +0000
committerDavid Robillard <d@drobilla.net>2014-04-27 00:43:14 +0000
commit4e70264247f9314f24a2b32189766c96596bd451 (patch)
tree794a572cf73df30f93bfc243b7477b517054406e /src
parent1006c95de39c99b41efb51aeeedbdc56b3bb9f57 (diff)
downloadjalv-4e70264247f9314f24a2b32189766c96596bd451.tar.gz
jalv-4e70264247f9314f24a2b32189766c96596bd451.tar.bz2
jalv-4e70264247f9314f24a2b32189766c96596bd451.zip
Support new UI show/hide interface in console version.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5377 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c4
-rw-r--r--src/jalv_console.c46
-rw-r--r--src/jalv_internal.h1
3 files changed, 39 insertions, 12 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 50a818a..9fd7288 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -1013,9 +1013,9 @@ main(int argc, char** argv)
/* Get a plugin UI */
const char* native_ui_type_uri = jalv_native_ui_type(&jalv);
+ jalv.uis = lilv_plugin_get_uis(jalv.plugin);
if (!jalv.opts.generic_ui && native_ui_type_uri) {
const LilvNode* native_ui_type = lilv_new_uri(jalv.world, native_ui_type_uri);
- jalv.uis = lilv_plugin_get_uis(jalv.plugin);
LILV_FOREACH(uis, u, jalv.uis) {
const LilvUI* this_ui = lilv_uis_get(jalv.uis, u);
if (lilv_ui_is_supported(this_ui,
@@ -1027,6 +1027,8 @@ main(int argc, char** argv)
break;
}
}
+ } else if (!jalv.opts.generic_ui && jalv.opts.show_ui) {
+ jalv.ui = lilv_uis_get(jalv.uis, lilv_uis_begin(jalv.uis));
}
/* Create ringbuffers for UI if necessary */
diff --git a/src/jalv_console.c b/src/jalv_console.c
index b75bb3c..c13880b 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -14,13 +14,18 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <string.h>
+#define _XOPEN_SOURCE 500
+
#include <stdbool.h>
#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
#include "jalv_config.h"
#include "jalv_internal.h"
+#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
+
static int
print_usage(const char* name, bool error)
{
@@ -28,6 +33,7 @@ print_usage(const char* name, bool error)
fprintf(os, "Usage: %s [OPTION...] PLUGIN_URI\n", name);
fprintf(os, "Run an LV2 plugin as a Jack application.\n");
fprintf(os, " -h Display this help and exit\n");
+ fprintf(os, " -s Show non-embedded UI if possible\n");
fprintf(os, " -u UUID UUID for Jack session restoration\n");
fprintf(os, " -l DIR Load state from save directory\n");
fprintf(os, " -d DIR Dump plugin <=> UI communication\n");
@@ -61,6 +67,8 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
for (; a < *argc && (*argv)[a][0] == '-'; ++a) {
if ((*argv)[a][1] == 'h') {
return print_usage((*argv)[0], true);
+ } else if ((*argv)[a][1] == 's') {
+ opts->show_ui = true;
} else if ((*argv)[a][1] == 'u') {
if (++a == *argc) {
fprintf(stderr, "Missing argument for -u\n");
@@ -108,16 +116,32 @@ jalv_native_ui_type(Jalv* jalv)
int
jalv_open_ui(Jalv* jalv)
{
-#ifdef JALV_JACK_SESSION
- printf("\nPress Ctrl-C to quit: ");
- fflush(stdout);
-#else
- printf("\nPress enter to quit: ");
- fflush(stdout);
- getc(stdin);
- zix_sem_post(jalv->done);
-#endif
- printf("\n");
+ const LV2UI_Idle_Interface* idle_iface = NULL;
+ const LV2UI_Show_Interface* show_iface = NULL;
+ if (jalv->ui && jalv->opts.show_ui) {
+ jalv_ui_instantiate(jalv, jalv_native_ui_type(jalv), NULL);
+ idle_iface = (const LV2UI_Idle_Interface*)
+ suil_instance_extension_data(jalv->ui_instance, LV2_UI__idleInterface);
+ show_iface = (LV2UI_Show_Interface*)
+ suil_instance_extension_data(jalv->ui_instance, LV2_UI__showInterface);
+ }
+
+ if (show_iface && idle_iface) {
+ show_iface->show(suil_instance_get_handle(jalv->ui_instance));
+
+ // Drive idle interface until interrupted
+ while (!zix_sem_try_wait(jalv->done)) {
+ if (idle_iface->idle(suil_instance_get_handle(jalv->ui_instance))) {
+ break;
+ }
+ usleep(33333);
+ }
+
+ show_iface->hide(suil_instance_get_handle(jalv->ui_instance));
+
+ // Caller waits on the done sem, so increment it again to exit
+ zix_sem_post(jalv->done);
+ }
return 0;
}
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 4531ee6..47a210d 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -94,6 +94,7 @@ typedef struct {
int generic_ui; ///< Use generic UI iff true
int show_hidden; ///< Show controls for notOnGUI ports
int no_menu; ///< Hide menu iff true
+ int show_ui; ///< Show non-embedded UI
} JalvOptions;
typedef struct {