aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-14 02:04:59 +0000
committerDavid Robillard <d@drobilla.net>2015-02-14 02:04:59 +0000
commit98d0093e0124e377669e717d621c4feeffc9ba09 (patch)
treec5e19a5b133409125ff6cf5f535138e622f08468
parentcebeaf23baa346201e76658139caa68d7d33d42f (diff)
downloadjalv-98d0093e0124e377669e717d621c4feeffc9ba09.tar.gz
jalv-98d0093e0124e377669e717d621c4feeffc9ba09.tar.bz2
jalv-98d0093e0124e377669e717d621c4feeffc9ba09.zip
Exit GUI versions on interrupt.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5558 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--NEWS3
-rw-r--r--src/jalv.c23
-rw-r--r--src/jalv_gtk.c3
-rw-r--r--src/jalv_gtkmm2.cpp2
-rw-r--r--src/jalv_internal.h2
-rw-r--r--src/jalv_qt4.cpp2
6 files changed, 21 insertions, 14 deletions
diff --git a/NEWS b/NEWS
index b9abcb1..c54d29d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,10 +2,11 @@ jalv (1.4.7) unstable;
* Exit on Jack shutdown (Patch from Robin Gareus)
* Report Jack latency (Patch from Robin Gareus)
+ * Exit GUI versions on interrupt
* Fix semaphore correctness issues
* Use moc-qt4 if present for systems with multiple Qt versions
- -- David Robillard <d@drobilla.net> Fri, 13 Feb 2015 20:51:53 -0500
+ -- David Robillard <d@drobilla.net> Fri, 13 Feb 2015 21:04:32 -0500
jalv (1.4.6) stable;
diff --git a/src/jalv.c b/src/jalv.c
index c523e98..a40c7f6 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -850,25 +850,32 @@ jalv_ui_port_index(SuilController controller, const char* symbol)
}
bool
-jalv_emit_ui_events(Jalv* jalv)
+jalv_update(Jalv* jalv)
{
+ /* Check quit flag and close if set. */
+ if (zix_sem_try_wait(&exit_sem)) {
+ jalv_close_ui(jalv);
+ return false;
+ }
+
+ /* Emit UI events. */
ControlChange ev;
const size_t space = jack_ringbuffer_read_space(jalv->plugin_events);
for (size_t i = 0;
i + sizeof(ev) + sizeof(float) <= space;
i += sizeof(ev) + ev.size) {
- // Read event header to get the size
+ /* Read event header to get the size */
jack_ringbuffer_read(jalv->plugin_events, (char*)&ev, sizeof(ev));
- // Resize read buffer if necessary
+ /* Resize read buffer if necessary */
jalv->ui_event_buf = realloc(jalv->ui_event_buf, ev.size);
void* const buf = jalv->ui_event_buf;
- // Read event body
+ /* Read event body */
jack_ringbuffer_read(jalv->plugin_events, buf, ev.size);
if (jalv->opts.dump && ev.protocol == jalv->urids.atom_eventTransfer) {
- // Dump event in Turtle to the console
+ /* Dump event in Turtle to the console */
LV2_Atom* atom = (LV2_Atom*)buf;
char* str = sratom_to_turtle(
jalv->ui_sratom, &jalv->unmap, "jalv:", NULL, NULL,
@@ -924,8 +931,8 @@ main(int argc, char** argv)
Jalv jalv;
memset(&jalv, '\0', sizeof(Jalv));
jalv.prog_name = argv[0];
- jalv.block_length = 4096; // Should be set by jack_buffer_size_cb
- jalv.midi_buf_size = 1024; // Should be set by jack_buffer_size_cb
+ jalv.block_length = 4096; /* Should be set by jack_buffer_size_cb */
+ jalv.midi_buf_size = 1024; /* Should be set by jack_buffer_size_cb */
jalv.play_state = JALV_PAUSED;
jalv.bpm = 120.0f;
@@ -1101,7 +1108,7 @@ main(int argc, char** argv)
suil_ui_supported,
native_ui_type,
&jalv.ui_type)) {
- // TODO: Multiple UI support
+ /* TODO: Multiple UI support */
jalv.ui = this_ui;
break;
}
diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c
index 7f8ba6c..000bdd6 100644
--- a/src/jalv_gtk.c
+++ b/src/jalv_gtk.c
@@ -889,8 +889,7 @@ jalv_open_ui(Jalv* jalv)
box_size.height + controls_size.height);
}
- g_timeout_add(1000 / jalv->ui_update_hz,
- (GSourceFunc)jalv_emit_ui_events, jalv);
+ g_timeout_add(1000 / jalv->ui_update_hz, (GSourceFunc)jalv_update, jalv);
gtk_window_present(GTK_WINDOW(window));
diff --git a/src/jalv_gtkmm2.cpp b/src/jalv_gtkmm2.cpp
index 059f88d..30ccb7b 100644
--- a/src/jalv_gtkmm2.cpp
+++ b/src/jalv_gtkmm2.cpp
@@ -75,7 +75,7 @@ jalv_open_ui(Jalv* jalv)
widgetmm->show_all();
g_timeout_add(1000 / jalv->ui_update_hz,
- (GSourceFunc)jalv_emit_ui_events, jalv);
+ (GSourceFunc)jalv_update, jalv);
} else {
Gtk::Button* button = Gtk::manage(new Gtk::Button("Close"));
window->add(*Gtk::manage(button));
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 9700f1f..73bdabe 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -254,7 +254,7 @@ jalv_ui_port_event(Jalv* jalv,
const void* buffer);
bool
-jalv_emit_ui_events(Jalv* jalv);
+jalv_update(Jalv* jalv);
int
jalv_ui_resize(Jalv* jalv, int width, int height);
diff --git a/src/jalv_qt4.cpp b/src/jalv_qt4.cpp
index cbccdd2..1f227f9 100644
--- a/src/jalv_qt4.cpp
+++ b/src/jalv_qt4.cpp
@@ -90,7 +90,7 @@ public:
explicit Timer(Jalv* jalv) : _jalv(jalv) {}
void timerEvent(QTimerEvent* e) {
- jalv_emit_ui_events(_jalv);
+ jalv_update(_jalv);
}
private: