aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jalv.c14
-rw-r--r--src/jalv_internal.h15
-rw-r--r--src/log.c43
-rw-r--r--wscript2
4 files changed, 68 insertions, 6 deletions
diff --git a/src/jalv.c b/src/jalv.c
index a2b8b86..d05a546 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -94,12 +94,14 @@ static LV2_Feature unmap_feature = { NS_EXT "urid#unmap", NULL };
static LV2_Feature instance_feature = { NS_EXT "instance-access", NULL };
static LV2_Feature make_path_feature = { LV2_STATE__makePath, NULL };
static LV2_Feature schedule_feature = { LV2_WORKER__schedule, NULL };
+static LV2_Feature log_feature = { LV2_LOG__log, NULL };
-const LV2_Feature* features[8] = {
+const LV2_Feature* features[9] = {
&uri_map_feature, &map_feature, &unmap_feature,
&instance_feature,
&make_path_feature,
&schedule_feature,
+ &log_feature,
NULL
};
@@ -577,7 +579,7 @@ jalv_ui_write(SuilController controller,
return;
}
- if (protocol == host->urids.atom_eventTransfer) {
+ if (host->opts.dump && protocol == host->urids.atom_eventTransfer) {
SerdNode s = serd_node_from_string(SERD_BLANK, USTR("msg"));
SerdNode p = serd_node_from_string(SERD_URI, USTR(NS_RDF "value"));
@@ -608,7 +610,7 @@ jalv_emit_ui_events(Jalv* host)
char buf[ev.size];
jack_ringbuffer_read(host->plugin_events, buf, ev.size);
- if (ev.protocol == host->urids.atom_eventTransfer) {
+ if (host->opts.dump && ev.protocol == host->urids.atom_eventTransfer) {
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;
@@ -668,9 +670,10 @@ main(int argc, char** argv)
"http://lv2plug.in/ns/ext/event",
NS_MIDI "MidiEvent");
host.urids.atom_eventTransfer = symap_map(host.symap, LV2_ATOM__eventTransfer);
+ host.urids.log_Trace = symap_map(host.symap, LV2_LOG__Trace);
host.urids.time_Position = symap_map(host.symap, LV2_TIME__Position);
- host.urids.time_barBeat = symap_map(host.symap, LV2_TIME__barBeat);
host.urids.time_bar = symap_map(host.symap, LV2_TIME__bar);
+ host.urids.time_barBeat = symap_map(host.symap, LV2_TIME__barBeat);
host.urids.time_beatUnit = symap_map(host.symap, LV2_TIME__beatUnit);
host.urids.time_beatsPerBar = symap_map(host.symap, LV2_TIME__beatsPerBar);
host.urids.time_beatsPerMinute = symap_map(host.symap, LV2_TIME__beatsPerMinute);
@@ -687,6 +690,9 @@ main(int argc, char** argv)
LV2_Worker_Schedule schedule = { &host, jalv_worker_schedule };
schedule_feature.data = &schedule;
+ LV2_Log_Log log = { &host, jalv_printf, jalv_vprintf };
+ log_feature.data = &log;
+
zix_sem_init(&exit_sem, 0);
host.done = &exit_sem;
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 6378ec0..ccc398c 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -29,6 +29,7 @@
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
+#include "lv2/lv2plug.in/ns/ext/log/log.h"
#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "lv2/lv2plug.in/ns/ext/worker/worker.h"
@@ -89,9 +90,10 @@ typedef struct {
typedef struct {
LV2_URID atom_eventTransfer;
+ LV2_URID log_Trace;
LV2_URID time_Position;
- LV2_URID time_barBeat;
LV2_URID time_bar;
+ LV2_URID time_barBeat;
LV2_URID time_beatUnit;
LV2_URID time_beatsPerBar;
LV2_URID time_beatsPerMinute;
@@ -255,6 +257,17 @@ jalv_strjoin(const char* a, const char* b)
return out;
}
+int
+jalv_printf(LV2_Log_Handle handle,
+ LV2_URID type,
+ const char* fmt, ...);
+
+int
+jalv_vprintf(LV2_Log_Handle handle,
+ LV2_URID type,
+ const char* fmt,
+ va_list ap);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/src/log.c b/src/log.c
new file mode 100644
index 0000000..9bc71ef
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,43 @@
+/*
+ Copyright 2007-2012 David Robillard <http://drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include "jalv_internal.h"
+
+int
+jalv_printf(LV2_Log_Handle handle,
+ LV2_URID type,
+ const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ const int ret = jalv_vprintf(handle, type, fmt, args);
+ va_end(args);
+ return ret;
+}
+
+int
+jalv_vprintf(LV2_Log_Handle handle,
+ LV2_URID type,
+ const char* fmt,
+ va_list ap)
+{
+ // TODO: Lock
+ Jalv* jalv = (Jalv*)handle;
+ if (type == jalv->urids.log_Trace && !jalv->opts.dump) {
+ return 0;
+ }
+ return vfprintf(stderr, fmt, ap);
+}
diff --git a/wscript b/wscript
index a4b4446..7edfb0e 100644
--- a/wscript
+++ b/wscript
@@ -71,7 +71,7 @@ def configure(conf):
def build(bld):
libs = 'LILV SUIL JACK SERD SRATOM LV2'
- source = 'src/jalv.c src/symap.c src/state.c src/lv2_evbuf.c src/worker.c'
+ source = 'src/jalv.c src/symap.c src/state.c src/lv2_evbuf.c src/worker.c src/log.c'
# Non-GUI version
obj = bld(features = 'c cprogram',