From ac68a26a30d9f6917da9c2cab29b6f612648c4d0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 13 Jun 2012 00:59:30 +0000 Subject: Tolerate loading presets with port values that aren't xsd:decimal (fix #824). git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@4499 a436a847-0d15-0410-975c-d299462d15a1 --- NEWS | 1 + src/state.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 4f0315a..82b1099 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ jalv (9999) unstable; * Tune UI update rate and ring size based on JACK rate and MIDI buffer size to handle the handle the maximum message rate the plugin can send. * Support lv2:sampleRate control ports. + * Tolerate loading presets with port values that aren't xsd:decimal -- David Robillard diff --git a/src/state.c b/src/state.c index aff7e13..965ed15 100644 --- a/src/state.c +++ b/src/state.c @@ -132,14 +132,21 @@ set_port_value(const char* port_symbol, return; } - if (type != jalv->forge.Float) { - fprintf(stderr, "error: Preset port `%s' value is a <%s>, not float\n", + float fvalue; + if (type == jalv->forge.Float) { + fvalue = *(float*)value; + } else if (type == jalv->forge.Double) { + fvalue = *(double*)value; + } else if (type == jalv->forge.Int) { + fvalue = *(int32_t*)value; + } else if (type == jalv->forge.Long) { + fvalue = *(int64_t*)value; + } else { + fprintf(stderr, "error: Preset `%s' value has bad type <%s>\n", port_symbol, jalv->unmap.unmap(jalv->unmap.handle, type)); return; } - const float fvalue = *(float*)value; - // Send value to plugin jalv_ui_write(jalv, port->index, sizeof(fvalue), 0, &fvalue); -- cgit v1.2.1