Permalink
Browse files

UI query state on GUI realization

  • Loading branch information...
1 parent f2000b3 commit dc1643bffc65ccf588ec17b6fe930eda52af492d @x42 committed Aug 28, 2012
Showing with 39 additions and 11 deletions.
  1. +22 −11 lv2.c
  2. +14 −0 ui.c
  3. +3 −0 uris.h
View
33 lv2.c
@@ -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) {
@@ -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);
@@ -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) {
View
14 ui.c
@@ -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;
}
View
3 uris.h
@@ -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;
@@ -42,6 +43,7 @@ typedef struct {
LV2_URID clv2_ir_file;
LV2_URID clv2_state;
+ LV2_URID clv2_uiinit;
} ConvoLV2URIs;
static inline void
@@ -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);
}

0 comments on commit dc1643b

Please sign in to comment.