diff options
author | David Robillard <d@drobilla.net> | 2012-02-25 04:16:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-02-25 04:16:42 +0000 |
commit | f122504784e8e38be7d7df87af3f2a7044a7f14c (patch) | |
tree | 7c172067c6d9979db7348c8b42a1ccc897a3161b /libs/ardour/lv2_evbuf.h | |
parent | 4f96a1006bbee939e258c844e49d41e207184b48 (diff) |
Support LV2 atom sequence ports alongside old event ports.
git-svn-id: svn://localhost/ardour2/branches/3.0@11517 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/lv2_evbuf.h')
-rw-r--r-- | libs/ardour/lv2_evbuf.h | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/libs/ardour/lv2_evbuf.h b/libs/ardour/lv2_evbuf.h new file mode 100644 index 0000000000..b2caa12e28 --- /dev/null +++ b/libs/ardour/lv2_evbuf.h @@ -0,0 +1,161 @@ +/* + Copyright 2008-2012 David Robillard <http://drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef LV2_EVBUF_H +#define LV2_EVBUF_H + +#include <stdint.h> +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#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. +*/ +typedef struct LV2_Evbuf_Impl LV2_Evbuf; + +/** + An iterator over an LV2_Evbuf. +*/ +typedef struct { + LV2_Evbuf* evbuf; + uint32_t offset; +} LV2_Evbuf_Iterator; + +/** + Allocate a new, empty event buffer. + The URID for atom:Sequence must be passed for atom_Sequence if type is + LV2_EVBUF_ATOM. +*/ +LV2_Evbuf* +lv2_evbuf_new(uint32_t capacity, LV2_Evbuf_Type type, uint32_t atom_type); + +/** + Free an event buffer allocated with lv2_evbuf_new. +*/ +void +lv2_evbuf_free(LV2_Evbuf* evbuf); + +/** + Change the type of an existing event buffer. This will clear and reset the + buffer, it is not possible to change the type and preserve the buffer + contents since the formats differ. The URID for atom:Sequence must be + passed for atom_Sequence if type is LV2_EVBUF_ATOM. +*/ +void +lv2_evbuf_set_type(LV2_Evbuf* evbuf, LV2_Evbuf_Type type, uint32_t atom_type); + +/** + Clear and initialize an existing event buffer. + The contents of buf are ignored entirely and overwritten, except capacity + which is unmodified. +*/ +void +lv2_evbuf_reset(LV2_Evbuf* evbuf); + +/** + Return the total padded size of the events stored in the buffer. +*/ +uint32_t +lv2_evbuf_get_size(LV2_Evbuf* evbuf); + +/** + Return the actual buffer implementation. + The format of the buffer returned depends on the buffer type. +*/ +void* +lv2_evbuf_get_buffer(LV2_Evbuf* evbuf); + +/** + Return an iterator to the start of @p buf. +*/ +LV2_Evbuf_Iterator +lv2_evbuf_begin(LV2_Evbuf* evbuf); + +/** + Return an iterator to the end of @a buf. +*/ +LV2_Evbuf_Iterator +lv2_evbuf_end(LV2_Evbuf* evbuf); + +/** + Check if @p iter is valid. + @return True if @p iter is valid, otherwise false (past end of buffer) +*/ +bool +lv2_evbuf_is_valid(LV2_Evbuf_Iterator iter); + +/** + Advance @p iter forward one event. + @p iter must be valid. + @return True if @p iter is valid, otherwise false (reached end of buffer) +*/ +LV2_Evbuf_Iterator +lv2_evbuf_next(LV2_Evbuf_Iterator iter); + +/** + Dereference an event iterator (i.e. get the event currently pointed to). + @p iter must be valid. + @p type Set to the type of the event. + @p size Set to the size of the event. + @p data Set to the contents of the event. + @return True on success. +*/ +bool +lv2_evbuf_get(LV2_Evbuf_Iterator iter, + uint32_t* frames, + uint32_t* subframes, + uint32_t* type, + uint32_t* size, + uint8_t** data); + +/** + Write an event at @p iter. + The event (if any) pointed to by @p iter will be overwritten, and @p iter + incremented to point to the following event (i.e. several calls to this + function can be done in sequence without twiddling iter in-between). + @return True if event was written, otherwise false (buffer is full). +*/ +bool +lv2_evbuf_write(LV2_Evbuf_Iterator* iter, + uint32_t frames, + uint32_t subframes, + uint32_t type, + uint32_t size, + const uint8_t* data); + +#ifdef __cplusplus +} +#endif + +#endif /* LV2_EVBUF_H */ |