void PluginLV2ChildUI::start_gui()
{
- gui->start_gui();
+ if( gui ) gui->start_gui();
update_lv2_input(config.ctls, 1);
connect_ports(config, PORTS_CONTROL | PORTS_ATOM);
+ int n = 0;
+#if 1
+// some plugins must have pointers, or they crash
+ float inp[nb_inputs], out[nb_outputs];
+ memset(&inp, 0, nb_inputs*sizeof(float));
+ memset(&out, 0, nb_outputs*sizeof(float));
+ int ich = 0, och = 0;
+ for( int i=0; i<config.nb_ports; ++i ) {
+ const LilvPort *lp = lilv_plugin_get_port_by_index(lilv, i);
+ if( !lp ) continue;
+ int port = config.ports[i];
+ if( !(port & PORTS_AUDIO) ) continue;
+ if( (port & PORTS_INPUT) ) {
+ lilv_instance_connect_port(inst, i, &inp[ich++]);
+ continue;
+ }
+ if( (port & PORTS_OUTPUT) ) {
+ lilv_instance_connect_port(inst, i, &out[och++]);
+ continue;
+ }
+ }
+ n = 1;
+#endif
updates = 0;
- run_lilv(0);
- send_host(LV2_SHOW, 0, 0);
- hidden = 0;
+ run_lilv(n);
+ if( gui ) {
+ send_host(LV2_SHOW, 0, 0);
+ hidden = 0;
+ }
}
void PluginLV2UI::update_host()
ui->hidden = -1;
}
-int PluginLV2ChildUI::init_ui(const char *path, int sample_rate)
+int PluginLV2ChildUI::init_ui(const char *path, int sample_rate, int bfrsz)
{
char *title = PluginLV2UI::title;
if( load_lv2(path, title) ) return 1;
- if( init_lv2(config, sample_rate) ) return 1;
+ if( init_lv2(config, sample_rate, bfrsz) ) return 1;
lilv_uis = lilv_plugin_get_uis(lilv);
- if( !lilv_uis ) {
- printf("lv2: lilv_plugin_get_uis(%s) failed\n", path);
- return 1;
- }
-
- if( !gui && wgt_type ) {
+ if( !gui && lilv_uis && wgt_type ) {
LilvNode *gui_type = lilv_new_uri(world, wgt_type);
LILV_FOREACH(uis, i, lilv_uis) {
const LilvUI *ui = lilv_uis_get(lilv_uis, i);
}
lilv_node_free(gui_type);
}
- if( !gui && gtk_type ) {
+ if( !gui && lilv_uis && gtk_type ) {
LilvNode *gui_type = lilv_new_uri(world, gtk_type);
LILV_FOREACH(uis, i, lilv_uis) {
const LilvUI *ui = lilv_uis_get(lilv_uis, i);
ui_type = gtk_type;
}
- if( !gui ) {
- printf("lv2_gui: init_ui failed: %s\n", title);
- return 1;
- }
-
lilv_instance_activate(inst);
return 0;
}
void PluginLV2ChildUI::reset_gui()
{
- gui->reset_gui();
+ if( gui ) gui->reset_gui();
if( sinst ) { suil_instance_free(sinst); sinst = 0; }
if( ui_host ) { suil_host_free(ui_host); ui_host = 0; }
// main loop
int PluginLV2ChildUI::run_ui()
{
- double last_time = 0, fps = 30;
- int64_t frame_usecs = 1e6 / fps;
+ double last_time = 0;
+ int64_t frame_usecs = 1e6 / refreshrate;
running = 1;
done = 0;
while( !done ) {
if( hidden < 0 ) {
- gui->top_level = 0;
+ if( gui ) gui->top_level = 0;
reset_gui();
if( !is_forked() ) {
done = -1;
int ret = 0;
if( is_forked() )
ret = read_child(usec);
- else
+ else if( gui )
usleep(usec);
+ else
+ ret = -1;
+
if( ret > 0 ) {
switch( child_token ) {
case LV2_OPEN: {
open_bfr_t *open_bfr = (open_bfr_t *)child_data;
- if( init_ui(open_bfr->path, open_bfr->sample_rate) ) {
+ if( init_ui(open_bfr->path, open_bfr->sample_rate, open_bfr->bfrsz) ) {
printf("lv2ui: unable to init: %s\n", open_bfr->path);
exit(1);
}