aboutsummaryrefslogtreecommitdiffstats
path: root/src/state.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-17 08:20:17 -0500
committerDavid Robillard <d@drobilla.net>2024-11-24 19:04:07 -0500
commit660d0e3591e6a972f5d4adfd7d0d3bf6cef566f9 (patch)
tree046c2c571efb23cc24fbe90dd885c44dd0b52743 /src/state.c
parent06bd42a00bd86f5d487727ff8f08797f9286b27f (diff)
downloadjalv-660d0e3591e6a972f5d4adfd7d0d3bf6cef566f9.tar.gz
jalv-660d0e3591e6a972f5d4adfd7d0d3bf6cef566f9.tar.bz2
jalv-660d0e3591e6a972f5d4adfd7d0d3bf6cef566f9.zip
Use message mechanism to pause plugin execution
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/state.c b/src/state.c
index 1bfe6ce..767db0a 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1,4 +1,4 @@
-// Copyright 2007-2016 David Robillard <d@drobilla.net>
+// Copyright 2007-2024 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
#include "state.h"
@@ -150,7 +150,7 @@ set_port_value(const char* port_symbol,
}
ZixStatus st = ZIX_STATUS_SUCCESS;
- if (jalv->play_state != JALV_RUNNING) {
+ if (jalv->run_state != JALV_RUNNING) {
// Set value on port struct directly
port->control = fvalue;
} else {
@@ -172,10 +172,18 @@ set_port_value(const char* port_symbol,
void
jalv_apply_state(Jalv* jalv, const LilvState* state)
{
+ typedef struct {
+ JalvMessageHeader head;
+ JalvRunStateChange body;
+ } PauseMessage;
+
const bool must_pause =
- !jalv->safe_restore && jalv->play_state == JALV_RUNNING;
+ !jalv->safe_restore && jalv->run_state == JALV_RUNNING;
if (must_pause) {
- jalv->play_state = JALV_PAUSE_REQUESTED;
+ const PauseMessage pause_msg = {
+ {RUN_STATE_CHANGE, sizeof(JalvRunStateChange)}, {JALV_PAUSED}};
+ zix_ring_write(jalv->ui_to_plugin, &pause_msg, sizeof(pause_msg));
+
zix_sem_wait(&jalv->paused);
}
@@ -194,9 +202,12 @@ jalv_apply_state(Jalv* jalv, const LilvState* state)
state, jalv->instance, set_port_value, jalv, 0, state_features);
if (must_pause) {
- const JalvMessageHeader msg = {STATE_REQUEST, 0U};
- zix_ring_write(jalv->ui_to_plugin, &msg, sizeof(msg));
- jalv->play_state = JALV_RUNNING;
+ const JalvMessageHeader state_msg = {STATE_REQUEST, 0U};
+ zix_ring_write(jalv->ui_to_plugin, &state_msg, sizeof(state_msg));
+
+ const PauseMessage run_msg = {
+ {RUN_STATE_CHANGE, sizeof(JalvRunStateChange)}, {JALV_RUNNING}};
+ zix_ring_write(jalv->ui_to_plugin, &run_msg, sizeof(run_msg));
}
}