From 8a0bcb4610de9367861c7b10ec938df9a433e363 Mon Sep 17 00:00:00 2001 From: Nick Lanham Date: Mon, 16 Apr 2012 17:09:26 +0200 Subject: [PATCH] Updates for evolving LV2 spec. Fixes atom calls (now have atom in name) and state interface --- drmr.c | 104 ++++++++++++++++++++++++++++-------------------------- drmr_ui.c | 6 ++-- 2 files changed, 57 insertions(+), 53 deletions(-) diff --git a/drmr.c b/drmr.c index c726f94..923a3be 100644 --- a/drmr.c +++ b/drmr.c @@ -280,8 +280,7 @@ static void run(LV2_Handle instance, uint32_t n_samples) { LV2_Atom_Forge_Frame seq_frame; lv2_atom_forge_sequence_head(&drmr->forge, &seq_frame, 0); - LV2_SEQUENCE_FOREACH(drmr->control_port, i) { - LV2_Atom_Event* const ev = lv2_sequence_iter_get(i); + LV2_ATOM_SEQUENCE_FOREACH(drmr->control_port, ev) { if (ev->body.type == drmr->uris.midi_event) { uint8_t nn; uint8_t* const data = (uint8_t* const)(ev + 1); @@ -312,13 +311,13 @@ static void run(LV2_Handle instance, uint32_t n_samples) { const LV2_Atom* ignvel = NULL; const LV2_Atom* ignno = NULL; const LV2_Atom* zerop = NULL; - lv2_object_get(obj, - drmr->uris.kit_path, &path, - drmr->uris.sample_trigger, &trigger, - drmr->uris.velocity_toggle, &ignvel, - drmr->uris.note_off_toggle, &ignno, - drmr->uris.zero_position, &zerop, - 0); + lv2_atom_object_get(obj, + drmr->uris.kit_path, &path, + drmr->uris.sample_trigger, &trigger, + drmr->uris.velocity_toggle, &ignvel, + drmr->uris.note_off_toggle, &ignno, + drmr->uris.zero_position, &zerop, + 0); if (path) { int reqPos = (drmr->curReq+1)%REQ_BUF_SIZE; char *tmp = NULL; @@ -419,14 +418,16 @@ static void cleanup(LV2_Handle instance) { free(instance); } -void save_state(LV2_Handle instance, - LV2_State_Store_Function store, - void* handle, - uint32_t flags, - const LV2_Feature *const * features) { +static LV2_State_Status +save_state(LV2_Handle instance, + LV2_State_Store_Function store, + void* handle, + uint32_t flags, + const LV2_Feature *const * features) { DrMr *drmr = (DrMr*)instance; LV2_State_Map_Path* map_path = NULL; int32_t flag; + LV2_State_Status stat = LV2_STATE_SUCCESS; while(*features) { if (!strcmp((*features)->URI, LV2_STATE__mapPath)) @@ -436,52 +437,53 @@ void save_state(LV2_Handle instance, if (map_path == NULL) { fprintf(stderr,"Host does not support map_path, cannot save state\n"); - return; + return LV2_STATE_ERR_NO_FEATURE; } char* mapped_path = map_path->abstract_path(map_path->handle, drmr->current_path); - if (store(handle, - drmr->uris.kit_path, - mapped_path, - strlen(mapped_path) + 1, - drmr->uris.string_urid, - LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) - fprintf(stderr,"Store of kit path failed\n"); + stat = store(handle, + drmr->uris.kit_path, + mapped_path, + strlen(mapped_path) + 1, + drmr->uris.string_urid, + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); + if (stat) return stat; flag = drmr->ignore_velocity?1:0; - if (store(handle, - drmr->uris.velocity_toggle, - &flag, - sizeof(int32_t), - drmr->uris.bool_urid, - LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) - fprintf(stderr,"Store of ignore velocity failed\n"); + stat = store(handle, + drmr->uris.velocity_toggle, + &flag, + sizeof(int32_t), + drmr->uris.bool_urid, + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); + if (stat) return stat; flag = drmr->ignore_note_off?1:0; - if (store(handle, - drmr->uris.note_off_toggle, - &flag, - sizeof(uint32_t), - drmr->uris.bool_urid, - LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) - fprintf(stderr,"Store of ignore note off failed\n"); + stat = store(handle, + drmr->uris.note_off_toggle, + &flag, + sizeof(uint32_t), + drmr->uris.bool_urid, + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); + if (stat) return stat; - if (store(handle, - drmr->uris.zero_position, - &drmr->zero_position, - sizeof(int), - drmr->uris.int_urid, - LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) - fprintf(stderr,"Store of sample zero position failed\n"); + stat = store(handle, + drmr->uris.zero_position, + &drmr->zero_position, + sizeof(int), + drmr->uris.int_urid, + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); + return stat; } -void restore_state(LV2_Handle instance, - LV2_State_Retrieve_Function retrieve, - void* handle, - uint32_t flags, - const LV2_Feature *const * features) { +static LV2_State_Status +restore_state(LV2_Handle instance, + LV2_State_Retrieve_Function retrieve, + void* handle, + uint32_t flags, + const LV2_Feature *const * features) { DrMr* drmr = (DrMr*)instance; size_t size; uint32_t type; @@ -496,7 +498,7 @@ void restore_state(LV2_Handle instance, if (map_path == NULL) { fprintf(stderr,"Host does not support map_path, cannot restore state\n"); - return; + return LV2_STATE_ERR_NO_FEATURE; } @@ -505,7 +507,7 @@ void restore_state(LV2_Handle instance, if (!abstract_path) { fprintf(stderr,"Found no path in state, not restoring\n"); - return; + return LV2_STATE_ERR_NO_PROPERTY; } char *kit_path = map_path->absolute_path(map_path->handle,abstract_path); @@ -534,6 +536,8 @@ void restore_state(LV2_Handle instance, retrieve(handle, drmr->uris.zero_position, &size, &type, &fgs); if (zero_position) drmr->zero_position = *zero_position; + + return LV2_STATE_SUCCESS; } diff --git a/drmr_ui.c b/drmr_ui.c index fa10b13..b8f7702 100644 --- a/drmr_ui.c +++ b/drmr_ui.c @@ -716,7 +716,7 @@ port_event(LV2UI_Handle handle, obj->body.otype == ui->uris.ui_msg) { // both state and ui_msg are the same at the moment const LV2_Atom* path = NULL; - lv2_object_get(obj, ui->uris.kit_path, &path, 0); + lv2_atom_object_get(obj, ui->uris.kit_path, &path, 0); if (path) { char *kitpath = LV2_ATOM_BODY(path); char *realp = realpath(kitpath,NULL); @@ -739,7 +739,7 @@ port_event(LV2UI_Handle handle, const LV2_Atom* ignvel = NULL; const LV2_Atom* ignno = NULL; const LV2_Atom* zerop = NULL; - lv2_object_get(obj, + lv2_atom_object_get(obj, ui->uris.velocity_toggle, &ignvel, ui->uris.note_off_toggle, &ignno, ui->uris.zero_position, &zerop, @@ -757,7 +757,7 @@ port_event(LV2UI_Handle handle, } else if (obj->body.otype == ui->uris.midi_info) { const LV2_Atom *midi_atom = NULL; - lv2_object_get(obj, ui->uris.midi_event, &midi_atom, 0); + lv2_atom_object_get(obj, ui->uris.midi_event, &midi_atom, 0); if(!midi_atom) { fprintf(stderr,"Midi info with no midi data\n"); return;