#include "arraylist.h"
#include "cstrdup.h"
#include "language.h"
+#include "pluginlv2.h"
#include "pluginlv2config.h"
#include <ctype.h>
#include <string.h>
PluginLV2UriTable::PluginLV2UriTable()
+ : Mutex("PluginLV2UriTable::PluginLV2UriTable")
{
set_array_delete();
}
LV2_URID PluginLV2UriTable::map(const char *uri)
{
- mLock locker(uri_table_lock);
- for( int i=0; i<size(); ++i )
- if( !strcmp(uri, get(i)) ) return i+1;
- append(cstrdup(uri));
- return size();
+ lock("PluginLV2UriTable::map");
+ int i = 0, n = size();
+ while( i<n && strcmp(uri, get(i)) ) ++i;
+ if( i >= n ) append(cstrdup(uri));
+ unlock();
+ return i+1;
}
const char *PluginLV2UriTable::unmap(LV2_URID urid)
{
- mLock locker(uri_table_lock);
+ lock("PluginLV2UriTable::unmap");
int idx = urid - 1;
- return idx>=0 && idx<size() ? get(idx) : 0;
+ const char *ret = idx>=0 && idx<size() ? get(idx) : 0;
+ unlock();
+ return ret;
}
PluginLV2Client_OptName:: PluginLV2Client_OptName(PluginLV2Client_Opt *opt)
mins = 0;
maxs = 0;
ctls = 0;
+ ports = 0;
nb_ports = 0;
}
delete [] names[i];
delete [] syms[i];
}
- delete [] names; names = 0;
- delete [] mins; mins = 0;
- delete [] maxs; maxs = 0;
- delete [] ctls; ctls = 0;
+ delete [] names; names = 0;
+ delete [] syms; syms = 0;
+ delete [] mins; mins = 0;
+ delete [] maxs; maxs = 0;
+ delete [] ctls; ctls = 0;
+ delete [] ports; ports = 0;
nb_ports = 0;
}
mins = new float[nb_ports];
maxs = new float[nb_ports];
ctls = new float[nb_ports];
+ ports = new int[nb_ports];
}
for( int i=0; i<nb_ports; ++i ) {
delete [] names[i]; names[i] = cstrdup(that.names[i]);
mins[i] = that.mins[i];
maxs[i] = that.maxs[i];
ctls[i] = that.ctls[i];
+ ports[i] = ports[i];
}
remove_all_objects();
for( int i=0; i<that.size(); ++i ) {
copy_from(prev);
}
-void PluginLV2ClientConfig::init_lv2(const LilvPlugin *lilv)
+void PluginLV2ClientConfig::init_lv2(const LilvPlugin *lilv, PluginLV2 *lv2)
{
reset();
nb_ports = lilv_plugin_get_num_ports(lilv);
mins = new float[nb_ports];
maxs = new float[nb_ports];
ctls = new float[nb_ports];
+ ports = new int[nb_ports];
lilv_plugin_get_port_ranges_float(lilv, mins, maxs, ctls);
for( int i=0; i<nb_ports; ++i ) {
const LilvPort *lp = lilv_plugin_get_port_by_index(lilv, i);
lilv_node_free(pnm);
const LilvNode *sym = lilv_port_get_symbol(lilv, lp);
syms[i] = cstrdup(lilv_node_as_string(sym));
+ int port = 0;
+ if( lilv_port_is_a(lilv, lp, lv2->lv2_AudioPort) ) port |= PORTS_AUDIO;
+ if( lilv_port_is_a(lilv, lp, lv2->lv2_ControlPort) ) port |= PORTS_CONTROL;
+ if( lilv_port_is_a(lilv, lp, lv2->lv2_InputPort) ) port |= PORTS_INPUT;
+ if( lilv_port_is_a(lilv, lp, lv2->lv2_OutputPort) ) port |= PORTS_OUTPUT;
+ if( lilv_port_is_a(lilv, lp, lv2->atom_AtomPort) ) port |= PORTS_ATOM;
+ ports[i] = port;
}
}