aboutsummaryrefslogtreecommitdiffstats
path: root/src/worker.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-17 16:56:05 -0500
committerDavid Robillard <d@drobilla.net>2024-11-24 19:06:49 -0500
commitffc643c1c5f23a5c993c30bf72363dc9567aa65a (patch)
tree1ab58ff4bfae7516171e2c68f518df972ff23d2e /src/worker.h
parent73e0744d9c2381038fbda7f2c53a0aabd6780b03 (diff)
downloadjalv-ffc643c1c5f23a5c993c30bf72363dc9567aa65a.tar.gz
jalv-ffc643c1c5f23a5c993c30bf72363dc9567aa65a.tar.bz2
jalv-ffc643c1c5f23a5c993c30bf72363dc9567aa65a.zip
Clean up worker interface
Diffstat (limited to 'src/worker.h')
-rw-r--r--src/worker.h39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/worker.h b/src/worker.h
index 88b011b..b95fcc2 100644
--- a/src/worker.h
+++ b/src/worker.h
@@ -6,10 +6,10 @@
#include "attributes.h"
-#include "zix/sem.h"
-
#include "lv2/core/lv2.h"
#include "lv2/worker/worker.h"
+#include "zix/sem.h"
+#include "zix/status.h"
#include <stdbool.h>
#include <stdint.h>
@@ -37,18 +37,23 @@ JalvWorker*
jalv_worker_new(ZixSem* lock, bool threaded);
/**
- Attach the worker to a plugin instance.
-
- This must be called before scheduling any work.
+ Free a worker allocated with jalv_worker_new().
- @param worker Worker to activate and attach to a plugin.
- @param iface Worker interface from plugin.
- @param handle Handle to the LV2 plugin this worker is for.
+ Calls jalv_worker_exit() to terminate the running thread if necessary.
*/
void
-jalv_worker_attach(JalvWorker* worker,
- const LV2_Worker_Interface* iface,
- LV2_Handle handle);
+jalv_worker_free(JalvWorker* worker);
+
+/**
+ Launch the worker's thread.
+
+ For threaded workers, this launches the thread if it isn't already running.
+ For non-threaded workers, this does nothing.
+
+ @return Zero on success, or a non-zero error code if launching failed.
+*/
+ZixStatus
+jalv_worker_launch(JalvWorker* worker);
/**
Terminate the worker's thread if necessary.
@@ -60,12 +65,18 @@ void
jalv_worker_exit(JalvWorker* worker);
/**
- Free a worker allocated with jalv_worker_new().
+ Attach the worker to a plugin instance.
- Calls jalv_worker_exit() to terminate the running thread if necessary.
+ This must be called before scheduling any work.
+
+ @param worker Worker to activate and attach to a plugin.
+ @param iface Worker interface from plugin.
+ @param handle Handle to the LV2 plugin this worker is for.
*/
void
-jalv_worker_free(JalvWorker* worker);
+jalv_worker_attach(JalvWorker* worker,
+ const LV2_Worker_Interface* iface,
+ LV2_Handle handle);
/**
Schedule work to be performed by the worker in the audio thread.