summaryrefslogtreecommitdiff
path: root/ext/lv2
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2011-05-25 23:13:17 +0300
committerStefan Kost <ensonic@users.sf.net>2011-05-25 23:26:39 +0300
commit579188d43601e59e14b19cfdeb22e3cb609ea181 (patch)
tree8b32788a385402992a16174ed05c799e62c8b8b0 /ext/lv2
parent7751dbb8e1d548ac6dfdf0f583daeb45594c9e3e (diff)
downloadgstreamer-plugins-bad-579188d43601e59e14b19cfdeb22e3cb609ea181.tar.gz
lv2: ensure uniqe property names
Copy and adjust the code from ladspa plugin to ensure unique gobject property names.
Diffstat (limited to 'ext/lv2')
-rw-r--r--ext/lv2/gstlv2.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/ext/lv2/gstlv2.c b/ext/lv2/gstlv2.c
index caa82b7f0..dd1df3df1 100644
--- a/ext/lv2/gstlv2.c
+++ b/ext/lv2/gstlv2.c
@@ -382,9 +382,38 @@ static gchar *
gst_lv2_class_get_param_name (GstLV2Class * klass, SLV2Port port)
{
SLV2Plugin lv2plugin = klass->plugin;
+ gchar *ret;
- return g_strdup (slv2_value_as_string (slv2_port_get_symbol (lv2plugin,
+ ret = g_strdup (slv2_value_as_string (slv2_port_get_symbol (lv2plugin,
port)));
+
+ /* this is the same thing that param_spec_* will do */
+ g_strcanon (ret, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ /* satisfy glib2 (argname[0] must be [A-Za-z]) */
+ if (!((ret[0] >= 'a' && ret[0] <= 'z') || (ret[0] >= 'A' && ret[0] <= 'Z'))) {
+ gchar *tempstr = ret;
+
+ ret = g_strconcat ("param-", ret, NULL);
+ g_free (tempstr);
+ }
+
+ /* check for duplicate property names */
+ if (g_object_class_find_property (G_OBJECT_CLASS (klass), ret)) {
+ gint n = 1;
+ gchar *nret = g_strdup_printf ("%s-%d", ret, n++);
+
+ while (g_object_class_find_property (G_OBJECT_CLASS (klass), nret)) {
+ g_free (nret);
+ nret = g_strdup_printf ("%s-%d", ret, n++);
+ }
+ g_free (ret);
+ ret = nret;
+ }
+
+ GST_DEBUG ("built property name '%s' from port name '%s'", ret,
+ slv2_value_as_string (slv2_port_get_symbol (lv2plugin, port)));
+
+ return ret;
}
static gchar *
@@ -408,14 +437,6 @@ gst_lv2_class_get_param_spec (GstLV2Class * klass, gint portnum)
nick = gst_lv2_class_get_param_nick (klass, port);
name = gst_lv2_class_get_param_name (klass, port);
- g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
- if (!((name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'A'
- && name[0] <= 'Z'))) {
- gchar *tempstr = name;
-
- name = g_strconcat ("param-", name, NULL);
- g_free (tempstr);
- }
GST_DEBUG ("%s trying port %s : %s",
slv2_value_as_string (slv2_plugin_get_uri (lv2plugin)), name, nick);