aboutsummaryrefslogtreecommitdiffstats
path: root/src/comm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/comm.h')
-rw-r--r--src/comm.h44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/comm.h b/src/comm.h
index 75f098b..e4579eb 100644
--- a/src/comm.h
+++ b/src/comm.h
@@ -6,6 +6,7 @@
#include "attributes.h"
+#include "lv2/atom/atom.h"
#include "lv2/urid/urid.h"
#include "zix/ring.h"
#include "zix/status.h"
@@ -16,6 +17,47 @@ JALV_BEGIN_DECLS
// Communication between the audio and main threads via rings
+/// Type of an internal message in a communication ring
+typedef enum {
+ NO_MESSAGE, ///< Sentinel type for uninitialized messages
+ CONTROL_PORT_CHANGE, ///< Value change for a control port (float)
+ EVENT_TRANSFER, ///< Event transfer for a sequence port (atom)
+} JalvMessageType;
+
+/**
+ Message between the audio thread and the main thread.
+
+ This is the general header for any type of message in a communication ring.
+ The type determines how the message must be handled by the receiver. This
+ header is followed immediately by `size` bytes of data in the ring.
+*/
+typedef struct {
+ JalvMessageType type; ///< Type of this message
+ uint32_t size; ///< Size of payload following this header in bytes
+} JalvMessageHeader;
+
+/**
+ The payload of a CONTROL_PORT_CHANGE message.
+
+ This message has a fixed sized, and is described in its entirety by this
+ struct.
+*/
+typedef struct {
+ uint32_t port_index; ///< Control port index
+ float value; ///< Control value
+} JalvControlChange;
+
+/**
+ The start of the payload of an EVENT_TRANSFER message.
+
+ This message has a variable size, the start described by this struct is
+ followed immediately by `atom.size` bytes of data (the atom body).
+*/
+typedef struct {
+ uint32_t port_index; ///< Sequence port index
+ LV2_Atom atom; ///< Event payload header
+} JalvEventTransfer;
+
/**
Write a message in two parts to a ring.
@@ -43,7 +85,6 @@ jalv_write_split_message(ZixRing* target,
@param target Communication ring (jalv->plugin_to_ui or jalv->ui_to_plugin).
@param port_index Index of the port this change is for.
- @param protocol Port protocol (0 for float control, or atom:eventTransfer).o
@param size Size of body in bytes.
@param type Atom type URID.
@param body Atom body.
@@ -52,7 +93,6 @@ jalv_write_split_message(ZixRing* target,
ZixStatus
jalv_write_event(ZixRing* target,
uint32_t port_index,
- uint32_t protocol,
uint32_t size,
LV2_URID type,
const void* body);