From 6f22ee045e7535c5961374d57453c39d1cee224c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 23 Sep 2018 15:48:27 +0200 Subject: Remove support for deprecated event and uri-map extensions --- NEWS | 3 +- src/jack.c | 6 +- src/jalv.c | 36 +--------- src/jalv_internal.h | 2 - src/lv2_evbuf.c | 186 +++++++++++++--------------------------------------- src/lv2_evbuf.h | 27 +------- src/portaudio.c | 2 +- src/state.c | 3 +- src/symap.h | 1 - 9 files changed, 55 insertions(+), 211 deletions(-) diff --git a/NEWS b/NEWS index 4e70ee3..f381b69 100644 --- a/NEWS +++ b/NEWS @@ -4,13 +4,14 @@ jalv (1.6.1) unstable; * Add jalv -i option to ignore stdin for background use * Add several commands to console interface * Make Suil dependency optional + * Remove support for deprecated event and uri-map extensions * Fix Jack deactivation * Fix potential crash when closed with worker (thanks JP Cimalando) * Fix potential hang after Ctrl-c in console interface (thanks Laxmi Devi) * Add support for underscore in port names on command line (thanks Jośe Fernando Moyano) - -- David Robillard Sat, 22 Sep 2018 23:40:18 +0200 + -- David Robillard Sun, 23 Sep 2018 15:49:05 +0200 jalv (1.6.0) stable; diff --git a/src/jack.c b/src/jack.c index 7abd42d..f85490a 100644 --- a/src/jack.c +++ b/src/jack.c @@ -179,7 +179,7 @@ jack_process_cb(jack_nframes_t nframes, void* data) jack_midi_event_get(&ev, buf, i); lv2_evbuf_write(&iter, ev.time, 0, - jalv->midi_event_id, + jalv->urids.midi_MidiEvent, ev.size, ev.buffer); } } @@ -218,12 +218,12 @@ jack_process_cb(jack_nframes_t nframes, void* data) uint8_t* body; lv2_evbuf_get(i, &frames, &subframes, &type, &size, &body); - if (buf && type == jalv->midi_event_id) { + if (buf && type == jalv->urids.midi_MidiEvent) { // Write MIDI event to Jack output jack_midi_event_write(buf, frames, body, size); } - if (jalv->has_ui && !port->old_api) { + if (jalv->has_ui) { // Forward event to UI jalv_send_to_ui(jalv, p, type, size, body); } diff --git a/src/jalv.c b/src/jalv.c index 28b54dc..14d791c 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -43,7 +43,6 @@ #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h" #include "lv2/lv2plug.in/ns/ext/data-access/data-access.h" -#include "lv2/lv2plug.in/ns/ext/event/event.h" #include "lv2/lv2plug.in/ns/ext/options/options.h" #include "lv2/lv2plug.in/ns/ext/parameters/parameters.h" #include "lv2/lv2plug.in/ns/ext/patch/patch.h" @@ -52,7 +51,6 @@ #include "lv2/lv2plug.in/ns/ext/presets/presets.h" #include "lv2/lv2plug.in/ns/ext/state/state.h" #include "lv2/lv2plug.in/ns/ext/time/time.h" -#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "lv2/lv2plug.in/ns/ext/worker/worker.h" #include "lv2/lv2plug.in/ns/extensions/ui/ui.h" @@ -108,28 +106,10 @@ unmap_uri(LV2_URID_Unmap_Handle handle, return uri; } -/** - Map function for URI map extension. -*/ -static uint32_t -uri_to_id(LV2_URI_Map_Callback_Data callback_data, - const char* map, - const char* uri) -{ - Jalv* jalv = (Jalv*)callback_data; - zix_sem_wait(&jalv->symap_lock); - const LV2_URID id = symap_map(jalv->symap, uri); - zix_sem_post(&jalv->symap_lock); - return id; -} - #define NS_EXT "http://lv2plug.in/ns/ext/" -static LV2_URI_Map_Feature uri_map = { NULL, &uri_to_id }; - static LV2_Extension_Data_Feature ext_data = { NULL }; -LV2_Feature uri_map_feature = { NS_EXT "uri-map", NULL }; LV2_Feature map_feature = { LV2_URID__map, NULL }; LV2_Feature unmap_feature = { LV2_URID__unmap, NULL }; LV2_Feature make_path_feature = { LV2_STATE__makePath, NULL }; @@ -147,7 +127,7 @@ static LV2_Feature buf_size_features[3] = { { LV2_BUF_SIZE__boundedBlockLength, NULL } }; const LV2_Feature* features[12] = { - &uri_map_feature, &map_feature, &unmap_feature, + &map_feature, &unmap_feature, &sched_feature, &log_feature, &options_feature, @@ -235,14 +215,9 @@ create_port(Jalv* jalv, jalv->nodes.lv2_CVPort)) { port->type = TYPE_CV; #endif - } else if (lilv_port_is_a(jalv->plugin, port->lilv_port, - jalv->nodes.ev_EventPort)) { - port->type = TYPE_EVENT; - port->old_api = true; } else if (lilv_port_is_a(jalv->plugin, port->lilv_port, jalv->nodes.atom_AtomPort)) { port->type = TYPE_EVENT; - port->old_api = false; } else if (!optional) { die("Mandatory port has unknown data type"); } @@ -298,7 +273,6 @@ jalv_allocate_port_buffers(Jalv* jalv) : jalv->midi_buf_size; port->evbuf = lv2_evbuf_new( buf_size, - port->old_api ? LV2_EVBUF_EVENT : LV2_EVBUF_ATOM, jalv->map.map(jalv->map.handle, lilv_node_as_string(jalv->nodes.atom_Chunk)), jalv->map.map(jalv->map.handle, @@ -453,7 +427,7 @@ jalv_ui_instantiate(Jalv* jalv, const char* native_ui_type, void* parent) LV2_UI__idleInterface, NULL }; const LV2_Feature* ui_features[] = { - &uri_map_feature, &map_feature, &unmap_feature, + &map_feature, &unmap_feature, &instance_feature, &data_feature, &log_feature, @@ -780,8 +754,6 @@ main(int argc, char** argv) jalv.symap = symap_new(); zix_sem_init(&jalv.symap_lock, 1); zix_sem_init(&jalv.work_lock, 1); - uri_map_feature.data = &uri_map; - uri_map.callback_data = &jalv; jalv.map.handle = &jalv; jalv.map.map = map_uri; @@ -809,9 +781,6 @@ main(int argc, char** argv) sratom_set_env(jalv.sratom, jalv.env); sratom_set_env(jalv.ui_sratom, jalv.env); - jalv.midi_event_id = uri_to_id( - &jalv, "http://lv2plug.in/ns/ext/event", LV2_MIDI__MidiEvent); - jalv.urids.atom_Float = symap_map(jalv.symap, LV2_ATOM__Float); jalv.urids.atom_Int = symap_map(jalv.symap, LV2_ATOM__Int); jalv.urids.atom_Object = symap_map(jalv.symap, LV2_ATOM__Object); @@ -894,7 +863,6 @@ main(int argc, char** argv) jalv.nodes.atom_Float = lilv_new_uri(world, LV2_ATOM__Float); jalv.nodes.atom_Path = lilv_new_uri(world, LV2_ATOM__Path); jalv.nodes.atom_Sequence = lilv_new_uri(world, LV2_ATOM__Sequence); - jalv.nodes.ev_EventPort = lilv_new_uri(world, LV2_EVENT__EventPort); jalv.nodes.lv2_AudioPort = lilv_new_uri(world, LV2_CORE__AudioPort); jalv.nodes.lv2_CVPort = lilv_new_uri(world, LV2_CORE__CVPort); jalv.nodes.lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort); diff --git a/src/jalv_internal.h b/src/jalv_internal.h index b193c22..bbf3049 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -86,7 +86,6 @@ struct Port { size_t buf_size; ///< Custom buffer size, or 0 uint32_t index; ///< Port index float control; ///< For control ports, otherwise 0.0f - bool old_api; ///< True for event, false for atom }; /* Controls */ @@ -312,7 +311,6 @@ struct Jalv { float ui_update_hz; ///< Frequency of UI updates uint32_t sample_rate; ///< Sample rate uint32_t event_delta_t; ///< Frames since last update sent to UI - uint32_t midi_event_id; ///< MIDI event class ID in event context uint32_t position; ///< Transport position in frames float bpm; ///< Transport tempo in beats per minute bool rolling; ///< Transport speed (0=stop, 1=play) diff --git a/src/lv2_evbuf.c b/src/lv2_evbuf.c index 2307c12..d7012c7 100644 --- a/src/lv2_evbuf.c +++ b/src/lv2_evbuf.c @@ -1,5 +1,5 @@ /* - Copyright 2008-2016 David Robillard + Copyright 2008-2018 David Robillard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -19,19 +19,14 @@ #include #include "lv2/lv2plug.in/ns/ext/atom/atom.h" -#include "lv2/lv2plug.in/ns/ext/event/event.h" #include "lv2_evbuf.h" struct LV2_Evbuf_Impl { - LV2_Evbuf_Type type; - uint32_t capacity; - uint32_t atom_Chunk; - uint32_t atom_Sequence; - union { - LV2_Event_Buffer event; - LV2_Atom_Sequence atom; - } buf; + uint32_t capacity; + uint32_t atom_Chunk; + uint32_t atom_Sequence; + LV2_Atom_Sequence buf; }; static inline uint32_t @@ -41,10 +36,7 @@ lv2_evbuf_pad_size(uint32_t size) } LV2_Evbuf* -lv2_evbuf_new(uint32_t capacity, - LV2_Evbuf_Type type, - uint32_t atom_Chunk, - uint32_t atom_Sequence) +lv2_evbuf_new(uint32_t capacity, uint32_t atom_Chunk, uint32_t atom_Sequence) { // FIXME: memory must be 64-bit aligned LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc( @@ -52,7 +44,6 @@ lv2_evbuf_new(uint32_t capacity, evbuf->capacity = capacity; evbuf->atom_Chunk = atom_Chunk; evbuf->atom_Sequence = atom_Sequence; - lv2_evbuf_set_type(evbuf, type); lv2_evbuf_reset(evbuf, true); return evbuf; } @@ -63,68 +54,32 @@ lv2_evbuf_free(LV2_Evbuf* evbuf) free(evbuf); } -void -lv2_evbuf_set_type(LV2_Evbuf* evbuf, LV2_Evbuf_Type type) -{ - evbuf->type = type; - switch (type) { - case LV2_EVBUF_EVENT: - evbuf->buf.event.data = (uint8_t*)(evbuf + 1); - evbuf->buf.event.capacity = evbuf->capacity; - break; - case LV2_EVBUF_ATOM: - break; - } - lv2_evbuf_reset(evbuf, true); -} - void lv2_evbuf_reset(LV2_Evbuf* evbuf, bool input) { - switch (evbuf->type) { - case LV2_EVBUF_EVENT: - evbuf->buf.event.header_size = sizeof(LV2_Event_Buffer); - evbuf->buf.event.stamp_type = LV2_EVENT_AUDIO_STAMP; - evbuf->buf.event.event_count = 0; - evbuf->buf.event.size = 0; - break; - case LV2_EVBUF_ATOM: - if (input) { - evbuf->buf.atom.atom.size = sizeof(LV2_Atom_Sequence_Body); - evbuf->buf.atom.atom.type = evbuf->atom_Sequence; - } else { - evbuf->buf.atom.atom.size = evbuf->capacity; - evbuf->buf.atom.atom.type = evbuf->atom_Chunk; - } + if (input) { + evbuf->buf.atom.size = sizeof(LV2_Atom_Sequence_Body); + evbuf->buf.atom.type = evbuf->atom_Sequence; + } else { + evbuf->buf.atom.size = evbuf->capacity; + evbuf->buf.atom.type = evbuf->atom_Chunk; } } uint32_t lv2_evbuf_get_size(LV2_Evbuf* evbuf) { - switch (evbuf->type) { - case LV2_EVBUF_EVENT: - return evbuf->buf.event.size; - case LV2_EVBUF_ATOM: - assert(evbuf->buf.atom.atom.type != evbuf->atom_Sequence - || evbuf->buf.atom.atom.size >= sizeof(LV2_Atom_Sequence_Body)); - return evbuf->buf.atom.atom.type == evbuf->atom_Sequence - ? evbuf->buf.atom.atom.size - sizeof(LV2_Atom_Sequence_Body) - : 0; - } - return 0; + assert(evbuf->buf.atom.type != evbuf->atom_Sequence + || evbuf->buf.atom.size >= sizeof(LV2_Atom_Sequence_Body)); + return evbuf->buf.atom.type == evbuf->atom_Sequence + ? evbuf->buf.atom.size - sizeof(LV2_Atom_Sequence_Body) + : 0; } void* lv2_evbuf_get_buffer(LV2_Evbuf* evbuf) { - switch (evbuf->type) { - case LV2_EVBUF_EVENT: - return &evbuf->buf.event; - case LV2_EVBUF_ATOM: - return &evbuf->buf.atom; - } - return NULL; + return &evbuf->buf; } LV2_Evbuf_Iterator @@ -158,18 +113,10 @@ lv2_evbuf_next(LV2_Evbuf_Iterator iter) LV2_Evbuf* evbuf = iter.evbuf; uint32_t offset = iter.offset; uint32_t size; - switch (evbuf->type) { - case LV2_EVBUF_EVENT: - size = ((LV2_Event*)(evbuf->buf.event.data + offset))->size; - offset += lv2_evbuf_pad_size(sizeof(LV2_Event) + size); - break; - case LV2_EVBUF_ATOM: - size = ((LV2_Atom_Event*) - ((char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, &evbuf->buf.atom) - + offset))->body.size; - offset += lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size); - break; - } + size = ((LV2_Atom_Event*) + ((char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, &evbuf->buf.atom) + + offset))->body.size; + offset += lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size); LV2_Evbuf_Iterator next = { evbuf, offset }; return next; @@ -190,32 +137,15 @@ lv2_evbuf_get(LV2_Evbuf_Iterator iter, return false; } - LV2_Event_Buffer* ebuf; - LV2_Event* ev; - LV2_Atom_Sequence* aseq; - LV2_Atom_Event* aev; - switch (iter.evbuf->type) { - case LV2_EVBUF_EVENT: - ebuf = &iter.evbuf->buf.event; - ev = (LV2_Event*)((char*)ebuf->data + iter.offset); - *frames = ev->frames; - *subframes = ev->subframes; - *type = ev->type; - *size = ev->size; - *data = (uint8_t*)ev + sizeof(LV2_Event); - break; - case LV2_EVBUF_ATOM: - aseq = &iter.evbuf->buf.atom; - aev = (LV2_Atom_Event*)( - (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) - + iter.offset); - *frames = aev->time.frames; - *subframes = 0; - *type = aev->body.type; - *size = aev->body.size; - *data = (uint8_t*)LV2_ATOM_BODY(&aev->body); - break; - } + LV2_Atom_Sequence* aseq = &iter.evbuf->buf; + LV2_Atom_Event* aev = (LV2_Atom_Event*)( + (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) + iter.offset); + + *frames = aev->time.frames; + *subframes = 0; + *type = aev->body.type; + *size = aev->body.size; + *data = (uint8_t*)LV2_ATOM_BODY(&aev->body); return true; } @@ -228,49 +158,23 @@ lv2_evbuf_write(LV2_Evbuf_Iterator* iter, uint32_t size, const uint8_t* data) { - LV2_Event_Buffer* ebuf; - LV2_Event* ev; - LV2_Atom_Sequence* aseq; - LV2_Atom_Event* aev; - switch (iter->evbuf->type) { - case LV2_EVBUF_EVENT: - ebuf = &iter->evbuf->buf.event; - if (ebuf->capacity - ebuf->size < sizeof(LV2_Event) + size) { - return false; - } - - ev = (LV2_Event*)(ebuf->data + iter->offset); - ev->frames = frames; - ev->subframes = subframes; - ev->type = type; - ev->size = size; - memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size); + LV2_Atom_Sequence* aseq = &iter->evbuf->buf; + if (iter->evbuf->capacity - sizeof(LV2_Atom) - aseq->atom.size < + sizeof(LV2_Atom_Event) + size) { + return false; + } - size = lv2_evbuf_pad_size(sizeof(LV2_Event) + size); - ebuf->size += size; - ebuf->event_count += 1; - iter->offset += size; - break; - case LV2_EVBUF_ATOM: - aseq = &iter->evbuf->buf.atom; - if (iter->evbuf->capacity - sizeof(LV2_Atom) - aseq->atom.size - < sizeof(LV2_Atom_Event) + size) { - return false; - } + LV2_Atom_Event* aev = (LV2_Atom_Event*)( + (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) + iter->offset); - aev = (LV2_Atom_Event*)( - (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) - + iter->offset); - aev->time.frames = frames; - aev->body.type = type; - aev->body.size = size; - memcpy(LV2_ATOM_BODY(&aev->body), data, size); + aev->time.frames = frames; + aev->body.type = type; + aev->body.size = size; + memcpy(LV2_ATOM_BODY(&aev->body), data, size); - size = lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size); - aseq->atom.size += size; - iter->offset += size; - break; - } + size = lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size); + aseq->atom.size += size; + iter->offset += size; return true; } diff --git a/src/lv2_evbuf.h b/src/lv2_evbuf.h index 42951f0..fad1006 100644 --- a/src/lv2_evbuf.h +++ b/src/lv2_evbuf.h @@ -25,21 +25,6 @@ extern "C" { #include #endif -/** - Format of actual buffer. -*/ -typedef enum { - /** - An (old) ev:EventBuffer (LV2_Event_Buffer). - */ - LV2_EVBUF_EVENT, - - /** - A (new) atom:Sequence (LV2_Atom_Sequence). - */ - LV2_EVBUF_ATOM -} LV2_Evbuf_Type; - /** An abstract/opaque LV2 event buffer. */ @@ -58,10 +43,7 @@ typedef struct { URIDs for atom:Chunk and atom:Sequence must be passed for LV2_EVBUF_ATOM. */ LV2_Evbuf* -lv2_evbuf_new(uint32_t capacity, - LV2_Evbuf_Type type, - uint32_t atom_Chunk, - uint32_t atom_Sequence); +lv2_evbuf_new(uint32_t capacity, uint32_t atom_Chunk, uint32_t atom_Sequence); /** Free an event buffer allocated with lv2_evbuf_new. @@ -69,13 +51,6 @@ lv2_evbuf_new(uint32_t capacity, void lv2_evbuf_free(LV2_Evbuf* evbuf); -/** - Reset and change the type of an existing event buffer. - URIDs for atom:Chunk and atom:Sequence must be passed for LV2_EVBUF_ATOM. -*/ -void -lv2_evbuf_set_type(LV2_Evbuf* evbuf, LV2_Evbuf_Type type); - /** Clear and initialize an existing event buffer. The contents of buf are ignored entirely and overwritten, except capacity diff --git a/src/portaudio.c b/src/portaudio.c index cb16c63..1425e4d 100644 --- a/src/portaudio.c +++ b/src/portaudio.c @@ -81,7 +81,7 @@ pa_process_cb(const void* inputs, uint8_t* body; lv2_evbuf_get(i, &frames, &subframes, &type, &size, &body); - if (jalv->has_ui && !port->old_api) { + if (jalv->has_ui) { // Forward event to UI jalv_send_to_ui(jalv, p, type, size, body); } diff --git a/src/state.c b/src/state.c index e2f2b47..eeeda78 100644 --- a/src/state.c +++ b/src/state.c @@ -36,7 +36,6 @@ #define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#" #define NS_XSD "http://www.w3.org/2001/XMLSchema#" -extern LV2_Feature uri_map_feature; extern LV2_Feature map_feature; extern LV2_Feature unmap_feature; extern LV2_Feature make_path_feature; @@ -48,7 +47,7 @@ extern LV2_Feature options_feature; extern LV2_Feature def_state_feature; const LV2_Feature* state_features[9] = { - &uri_map_feature, &map_feature, &unmap_feature, + &map_feature, &unmap_feature, &make_path_feature, &state_sched_feature, &safe_restore_feature, diff --git a/src/symap.h b/src/symap.h index 8333298..918d914 100644 --- a/src/symap.h +++ b/src/symap.h @@ -20,7 +20,6 @@ Particularly useful for implementing LV2 URI mapping. @see LV2 URID - @see LV2 URI Map */ #ifndef SYMAP_H -- cgit v1.2.1