23 #ifndef LVTK_WORKER_HPP 24 #define LVTK_WORKER_HPP 28 #include <lv2/lv2plug.in/ns/ext/worker/worker.h> 30 #include "lvtk/private/types.hpp" 48 LV2_Worker_Respond_Function wrfunc,
49 LV2_Worker_Respond_Handle handle)
50 : p_instance(instance),
61 WorkerStatus
operator () (uint32_t size,
const void* data)
const 63 return (WorkerStatus) p_wrfunc (p_handle, size, data);
67 LV2_Handle p_instance;
68 LV2_Worker_Respond_Handle p_handle;
69 LV2_Worker_Respond_Function p_wrfunc;
76 template <
bool Required = true>
79 template <
class Derived>
80 struct I : Extension<Required>
94 Derived* d =
reinterpret_cast<Derived*
>(instance);
96 LV2_Worker_Schedule *ws =
reinterpret_cast<LV2_Worker_Schedule*
>(data);
98 fe->m_work_schedule_handle = ws->handle;
108 std::clog<<
" [Worker] validation " 109 <<(this->m_ok ?
"succeeded" :
"failed")<<
"."<<std::endl;
118 if (!std::strcmp (uri, LV2_WORKER__interface)) {
159 return (WorkerStatus)m_schedule_work_func(
160 m_work_schedule_handle, size, data);
216 LV2_Worker_Schedule_Handle m_work_schedule_handle;
219 LV2_Worker_Status (*m_schedule_work_func)(LV2_Worker_Schedule_Handle handle,
224 static LV2_Worker_Status _work(LV2_Handle instance,
225 LV2_Worker_Respond_Function respond,
226 LV2_Worker_Respond_Handle handle,
230 Derived* plugin =
reinterpret_cast<Derived*
>(instance);
232 return (LV2_Worker_Status)plugin->work(wrsp, size, data);
236 static LV2_Worker_Status _work_response (LV2_Handle instance,
240 Derived* plugin =
reinterpret_cast<Derived*
>(instance);
241 return (LV2_Worker_Status)plugin->work_response (size, body);
245 static LV2_Worker_Status _end_run (LV2_Handle instance)
247 Derived* plugin =
reinterpret_cast<Derived*
>(instance);
248 return (LV2_Worker_Status)plugin->end_run();
static void map_feature_handlers(FeatureHandlerMap &hmap)
Definition: worker.hpp:85
static void handle_feature(void *instance, FeatureData data)
Definition: worker.hpp:92
WorkerStatus schedule_work(uint32_t size, const void *data)
Definition: worker.hpp:157
Definition: worker.hpp:80
bool check_ok()
Definition: worker.hpp:105
void * FeatureData
Definition: feature.hpp:47
WorkerStatus work(WorkerRespond &respond, uint32_t size, const void *data)
Definition: worker.hpp:175
Definition: worker.hpp:38
Definition: worker.hpp:46
Definition: feature.hpp:34
Definition: worker.hpp:36
WorkerStatus operator()(uint32_t size, const void *data) const
Definition: worker.hpp:61
WorkerStatus end_run()
Definition: worker.hpp:206
Definition: worker.hpp:77
WorkerStatus
Definition: worker.hpp:35
Definition: worker.hpp:37
static const void * extension_data(const char *uri)
Definition: worker.hpp:116
WorkerStatus work_response(uint32_t size, const void *body)
Definition: worker.hpp:189
map< string, FeatureHandler > FeatureHandlerMap
Definition: feature.hpp:57