diff options
author | David Robillard <d@drobilla.net> | 2013-01-22 05:05:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-22 05:05:29 +0000 |
commit | 4d1649e313da9d658bb6c653b3f4a2c6d983299d (patch) | |
tree | 7e66c111569b7432344fbb37aee951320b407f67 /src/jalv.c | |
parent | 29eb515f2a75eeb9a4a0baf658a10da21f4dd187 (diff) | |
download | jalv-4d1649e313da9d658bb6c653b3f4a2c6d983299d.tar.gz jalv-4d1649e313da9d658bb6c653b3f4a2c6d983299d.tar.bz2 jalv-4d1649e313da9d658bb6c653b3f4a2c6d983299d.zip |
Use a dynamically allocated buffer for reading from plugin=>UI ring to avoid blowing the stack if a plugin sends very large updates to the UI.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5003 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/jalv.c')
-rw-r--r-- | src/jalv.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -732,11 +732,18 @@ jalv_emit_ui_events(Jalv* jalv) ControlChange ev; const size_t space = jack_ringbuffer_read_space(jalv->plugin_events); for (size_t i = 0; i < space; i += sizeof(ev) + ev.size) { + // Read event header to get the size jack_ringbuffer_read(jalv->plugin_events, (char*)&ev, sizeof(ev)); - char buf[ev.size]; + + // 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 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 SerdNode s = serd_node_from_string(SERD_BLANK, USTR("msg")); SerdNode p = serd_node_from_string(SERD_URI, USTR(NS_RDF "value")); LV2_Atom* atom = (LV2_Atom*)buf; @@ -1130,6 +1137,7 @@ main(int argc, char** argv) remove(jalv.temp_dir); free(jalv.temp_dir); + free(jalv.ui_event_buf); return 0; } |