Skip to content

Commit

Permalink
UI query state on GUI realization
Browse files Browse the repository at this point in the history
  • Loading branch information
x42 committed Aug 28, 2012
1 parent f2000b3 commit dc1643b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
33 changes: 22 additions & 11 deletions lv2.c
Expand Up @@ -190,17 +190,8 @@ work(LV2_Handle instance,
return LV2_WORKER_SUCCESS;
}

static LV2_Worker_Status
work_response(LV2_Handle instance,
uint32_t size,
const void* data)
{
// swap engine instances
static void inform_ui(LV2_Handle instance) {
convoLV2* self = (convoLV2*)instance;
LV2convolv *old = self->clv_online;
self->clv_online = self->clv_offline;
self->clv_offline = old;

// message to UI
char fn[1024];
if (clv_query_setting(self->clv_online, "convolution.ir.file", fn, 1024) > 0) {
Expand All @@ -220,6 +211,20 @@ work_response(LV2_Handle instance,
free(cfg);
}
#endif
}

static LV2_Worker_Status
work_response(LV2_Handle instance,
uint32_t size,
const void* data)
{
// swap engine instances
convoLV2* self = (convoLV2*)instance;
LV2convolv *old = self->clv_online;
self->clv_online = self->clv_offline;
self->clv_offline = old;

inform_ui(instance);

int d = CMD_FREE;
self->schedule->schedule_work(self->schedule->handle, sizeof(int), &d);
Expand Down Expand Up @@ -283,7 +288,13 @@ run(LV2_Handle instance, uint32_t n_samples)

/* Read incoming events */
LV2_ATOM_SEQUENCE_FOREACH(self->control_port, ev) {
self->schedule->schedule_work(self->schedule->handle, lv2_atom_total_size(&ev->body), &ev->body);
const LV2_Atom_Object* obj = (LV2_Atom_Object*)&ev->body;
ConvoLV2URIs* uris = &self->uris;
if (obj->body.otype == uris->clv2_uiinit) {
inform_ui(instance);
} else {
self->schedule->schedule_work(self->schedule->handle, lv2_atom_total_size(&ev->body), &ev->body);
}
}

if (self->bufsize != n_samples) {
Expand Down
14 changes: 14 additions & 0 deletions ui.c
Expand Up @@ -146,6 +146,20 @@ instantiate(const LV2UI_Descriptor* descriptor,

*widget = ui->box;

#if 1 //ask plugin about current state
uint8_t obj_buf[OBJ_BUF_SIZE];
lv2_atom_forge_set_buffer(&ui->forge, obj_buf, OBJ_BUF_SIZE);

LV2_Atom_Forge_Frame set_frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_blank(
&ui->forge, &set_frame, 1, ui->uris.clv2_uiinit);
lv2_atom_forge_pop(&ui->forge, &set_frame);

ui->write(ui->controller, 0, lv2_atom_total_size(msg),
ui->uris.atom_eventTransfer,
msg);
#endif

return ui;
}

Expand Down
3 changes: 3 additions & 0 deletions uris.h
Expand Up @@ -30,6 +30,7 @@
#define CONVOLV2__file CONVOLV2_URI "#file"
#define CONVOLV2__load CONVOLV2_URI "#load"
#define CONVOLV2__state CONVOLV2_URI "#state"
#define CONVOLV2__uiinit CONVOLV2_URI "#uiinit"

typedef struct {
LV2_URID atom_Blank;
Expand All @@ -42,6 +43,7 @@ typedef struct {

LV2_URID clv2_ir_file;
LV2_URID clv2_state;
LV2_URID clv2_uiinit;
} ConvoLV2URIs;

static inline void
Expand All @@ -57,6 +59,7 @@ map_convolv2_uris(LV2_URID_Map* map, ConvoLV2URIs* uris)

uris->clv2_ir_file = map->map(map->handle, CONVOLV2__file);
uris->clv2_state = map->map(map->handle, CONVOLV2__state);
uris->clv2_uiinit = map->map(map->handle, CONVOLV2__uiinit);
}


Expand Down

0 comments on commit dc1643b

Please sign in to comment.