lv2: add support for host features
authorStefan Sauer <ensonic@users.sf.net>
Thu, 12 May 2016 06:12:07 +0000 (23:12 -0700)
committerStefan Sauer <ensonic@users.sf.net>
Fri, 13 May 2016 18:54:08 +0000 (11:54 -0700)
Implement a log handler as the first one.

ext/lv2/gstlv2utils.c

index 589f6c5..44700c6 100644 (file)
 #include "gstlv2.h"
 #include "gstlv2utils.h"
 
+#include <lv2/lv2plug.in/ns/ext/log/log.h>
+
 GST_DEBUG_CATEGORY_EXTERN (lv2_debug);
 #define GST_CAT_DEFAULT lv2_debug
 
+/* host features */
+
+/* - log extension */
+
+static int
+lv2_log_printf (LV2_Log_Handle handle, LV2_URID type, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  gst_debug_log_valist (lv2_debug, GST_LEVEL_INFO, "", "", 0, NULL, fmt, ap);
+  va_end (ap);
+  return 1;
+}
+
+static int
+lv2_log_vprintf (LV2_Log_Handle handle, LV2_URID type,
+    const char *fmt, va_list ap)
+{
+  gst_debug_log_valist (lv2_debug, GST_LEVEL_INFO, "", "", 0, NULL, fmt, ap);
+  return 1;
+}
+
+static LV2_Log_Log lv2_log = {
+  NULL,                         /* handle */
+  lv2_log_printf, lv2_log_vprintf,
+};
+
+static const LV2_Feature lv2_log_feature = { LV2_LOG__log, &lv2_log };
+
+/* feature list */
+
+static const LV2_Feature *lv2_features[] = {
+  &lv2_log_feature,
+  NULL
+};
+
+/* api helpers */
+
 void
 gst_lv2_init (GstLV2 * lv2, GstLV2Class * lv2_class)
 {
@@ -57,7 +98,7 @@ gst_lv2_setup (GstLV2 * lv2, unsigned long rate)
     lilv_instance_free (lv2->instance);
 
   if (!(lv2->instance =
-          lilv_plugin_instantiate (lv2_class->plugin, rate, NULL)))
+          lilv_plugin_instantiate (lv2_class->plugin, rate, lv2_features)))
     return FALSE;
 
   /* connect the control ports */