diff options
author | David Robillard <d@drobilla.net> | 2024-11-15 10:08:24 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-11-24 18:59:41 -0500 |
commit | 800356e507c5cc098e89b1cbe96f5f150dc12d96 (patch) | |
tree | 0859bac836bc25f147a5d51cdb67fc619d2726c8 /src/comm.h | |
parent | 7c9858897ff6014a6cf36cefbd05f1f4f63817c4 (diff) | |
download | jalv-800356e507c5cc098e89b1cbe96f5f150dc12d96.tar.gz jalv-800356e507c5cc098e89b1cbe96f5f150dc12d96.tar.bz2 jalv-800356e507c5cc098e89b1cbe96f5f150dc12d96.zip |
Move low-level event sending functions to a separate file
Takes advantage of the dependency trimming of the previous commit to work
towards separating things more cleanly.
Diffstat (limited to 'src/comm.h')
-rw-r--r-- | src/comm.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/comm.h b/src/comm.h new file mode 100644 index 0000000..75f098b --- /dev/null +++ b/src/comm.h @@ -0,0 +1,76 @@ +// Copyright 2007-2024 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#ifndef JALV_COMM_H +#define JALV_COMM_H + +#include "attributes.h" + +#include "lv2/urid/urid.h" +#include "zix/ring.h" +#include "zix/status.h" + +#include <stdint.h> + +JALV_BEGIN_DECLS + +// Communication between the audio and main threads via rings + +/** + Write a message in two parts to a ring. + + This is used to conveniently write a message with a fixed-size header and + possibly variably-sized body in a single call. + + @param target Communication ring (jalv->plugin_to_ui or jalv->ui_to_plugin). + @param header Pointer to start of header data. + @param header_size Size of header in bytes. + @param body Pointer to start of body data. + @param body_size Size of body in bytes. + @return 0 on success, non-zero on failure (overflow). +*/ +ZixStatus +jalv_write_split_message(ZixRing* target, + const void* header, + uint32_t header_size, + const void* body, + uint32_t body_size); + +/** + Write a port event using the atom:eventTransfer protocol. + + This is used to transfer atoms between the plugin and UI via sequence ports. + + @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. + @return 0 on success, non-zero on failure (overflow). +*/ +ZixStatus +jalv_write_event(ZixRing* target, + uint32_t port_index, + uint32_t protocol, + uint32_t size, + LV2_URID type, + const void* body); + +/** + Write a control port change using the default (0) protocol. + + This is used to transfer control port value changes between the plugin and + UI. + + @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 value New control port value. + @return 0 on success, non-zero on failure (overflow). +*/ +ZixStatus +jalv_write_control(ZixRing* target, uint32_t port_index, float value); + +JALV_END_DECLS + +#endif // JALV_COMM_H |