diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jalv.c | 1 | ||||
-rw-r--r-- | src/jalv_internal.h | 1 | ||||
-rw-r--r-- | src/worker.c | 4 |
3 files changed, 6 insertions, 0 deletions
@@ -1001,6 +1001,7 @@ main(int argc, char** argv) jalv.symap = symap_new(); zix_sem_init(&jalv.symap_lock, 1); + zix_sem_init(&jalv.work_lock, 1); uri_map_feature.data = &uri_map; uri_map.callback_data = &jalv; diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 818f19c..96433c5 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -267,6 +267,7 @@ struct Jalv { void* ui_event_buf; ///< Buffer for reading UI port events JalvWorker worker; ///< Worker thread implementation JalvWorker state_worker; ///< Synchronous worker for state restore + ZixSem work_lock; ///< Lock for plugin work() method ZixSem* done; ///< Exit semaphore ZixSem paused; ///< Paused signal from process thread JalvPlayState play_state; ///< Current play state diff --git a/src/worker.c b/src/worker.c index 79b220c..9035733 100644 --- a/src/worker.c +++ b/src/worker.c @@ -50,8 +50,10 @@ worker_func(void* data) jack_ringbuffer_read(worker->requests, (char*)buf, size); + zix_sem_wait(&jalv->work_lock); worker->iface->work( jalv->instance->lv2_handle, jalv_worker_respond, worker, size, buf); + zix_sem_post(&jalv->work_lock); } free(buf); @@ -105,8 +107,10 @@ jalv_worker_schedule(LV2_Worker_Schedule_Handle handle, zix_sem_post(&worker->sem); } else { // Execute work immediately in this thread + zix_sem_wait(&jalv->work_lock); worker->iface->work( jalv->instance->lv2_handle, jalv_worker_respond, worker, size, data); + zix_sem_post(&jalv->work_lock); } return LV2_WORKER_SUCCESS; } |