aboutsummaryrefslogtreecommitdiffstats
path: root/src/jalv.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-15 10:26:30 -0500
committerDavid Robillard <d@drobilla.net>2024-11-24 18:59:52 -0500
commit7ab8a8f8771aed943e1e154c7a7c7040f7e7be3b (patch)
treeb0efeaba83991d4d1a48d3e52a191de1f5bdb7b1 /src/jalv.c
parent0051a8f9be546e18c01901c76c3a9cd3c8cf9cfc (diff)
downloadjalv-7ab8a8f8771aed943e1e154c7a7c7040f7e7be3b.tar.gz
jalv-7ab8a8f8771aed943e1e154c7a7c7040f7e7be3b.tar.bz2
jalv-7ab8a8f8771aed943e1e154c7a7c7040f7e7be3b.zip
Move jalv_send_to_plugin() to avoid the need for a prototype
Diffstat (limited to 'src/jalv.c')
-rw-r--r--src/jalv.c103
1 files changed, 48 insertions, 55 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 6db1478..bb40963 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -368,11 +368,54 @@ jalv_create_controls(Jalv* jalv, bool writable)
}
static void
-jalv_send_to_plugin(void* jalv_handle,
- uint32_t port_index,
- uint32_t buffer_size,
- uint32_t protocol,
- const void* buffer);
+jalv_send_to_plugin(void* const jalv_handle,
+ const uint32_t port_index,
+ const uint32_t buffer_size,
+ const uint32_t protocol,
+ const void* const buffer)
+{
+ Jalv* const jalv = (Jalv*)jalv_handle;
+ ZixStatus st = ZIX_STATUS_SUCCESS;
+
+ if (port_index >= jalv->num_ports) {
+ jalv_log(JALV_LOG_ERR, "UI wrote to invalid port index %u\n", port_index);
+
+ } else if (protocol == 0U) {
+ if (buffer_size != sizeof(float)) {
+ st = ZIX_STATUS_BAD_ARG;
+ } else {
+ const float value = *(const float*)buffer;
+ st = jalv_write_control(jalv->ui_to_plugin, port_index, value);
+ }
+
+ } else if (protocol == jalv->urids.atom_eventTransfer) {
+ const LV2_Atom* const atom = (const LV2_Atom*)buffer;
+ if (buffer_size < sizeof(LV2_Atom) ||
+ (sizeof(LV2_Atom) + atom->size != buffer_size)) {
+ st = ZIX_STATUS_BAD_ARG;
+ } else {
+ jalv_dump_atom(jalv, stdout, "UI => Plugin", atom, 36);
+ st = jalv_write_event(jalv->ui_to_plugin,
+ port_index,
+ jalv->urids.atom_eventTransfer,
+ atom->size,
+ atom->type,
+ atom + 1U);
+ }
+
+ } else {
+ jalv_log(JALV_LOG_ERR,
+ "UI wrote with unsupported protocol %u (%s)\n",
+ protocol,
+ unmap_uri(jalv, protocol));
+ }
+
+ if (st) {
+ jalv_log(JALV_LOG_ERR,
+ "Failed to write to plugin from UI (%s)\n",
+ zix_strerror(st));
+ }
+}
void
jalv_set_control(Jalv* jalv,
@@ -496,56 +539,6 @@ jalv_ui_is_resizable(Jalv* jalv)
}
static void
-jalv_send_to_plugin(void* const jalv_handle,
- uint32_t port_index,
- uint32_t buffer_size,
- uint32_t protocol,
- const void* buffer)
-{
- Jalv* const jalv = (Jalv*)jalv_handle;
- ZixStatus st = ZIX_STATUS_SUCCESS;
-
- if (port_index >= jalv->num_ports) {
- jalv_log(JALV_LOG_ERR, "UI wrote to invalid port index %u\n", port_index);
-
- } else if (protocol == 0U) {
- if (buffer_size != sizeof(float)) {
- st = ZIX_STATUS_BAD_ARG;
- } else {
- const float value = *(const float*)buffer;
- st = jalv_write_control(jalv->ui_to_plugin, port_index, value);
- }
-
- } else if (protocol == jalv->urids.atom_eventTransfer) {
- const LV2_Atom* const atom = (const LV2_Atom*)buffer;
- if (buffer_size < sizeof(LV2_Atom) ||
- (sizeof(LV2_Atom) + atom->size != buffer_size)) {
- st = ZIX_STATUS_BAD_ARG;
- } else {
- jalv_dump_atom(jalv, stdout, "UI => Plugin", atom, 36);
- st = jalv_write_event(jalv->ui_to_plugin,
- port_index,
- jalv->urids.atom_eventTransfer,
- atom->size,
- atom->type,
- atom + 1U);
- }
-
- } else {
- jalv_log(JALV_LOG_ERR,
- "UI wrote with unsupported protocol %u (%s)\n",
- protocol,
- unmap_uri(jalv, protocol));
- }
-
- if (st) {
- jalv_log(JALV_LOG_ERR,
- "Failed to write to plugin from UI (%s)\n",
- zix_strerror(st));
- }
-}
-
-static void
jalv_apply_ui_events(Jalv* jalv, uint32_t nframes)
{
if (!jalv->has_ui) {