From f4ee02db64ee39f1653cbc5373abaa748707e580 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 31 Jul 2016 15:24:34 -0400 Subject: Support thread-safe state restoration --- src/state.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/state.c') diff --git a/src/state.c b/src/state.c index d50ef66..f59ea43 100644 --- a/src/state.c +++ b/src/state.c @@ -1,5 +1,5 @@ /* - Copyright 2007-2015 David Robillard + Copyright 2007-2016 David Robillard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -37,6 +37,27 @@ #define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#" #define NS_XSD "http://www.w3.org/2001/XMLSchema#" +extern LV2_Feature uri_map_feature; +extern LV2_Feature map_feature; +extern LV2_Feature unmap_feature; +extern LV2_Feature make_path_feature; +extern LV2_Feature sched_feature; +extern LV2_Feature state_sched_feature; +extern LV2_Feature safe_restore_feature; +extern LV2_Feature log_feature; +extern LV2_Feature options_feature; +extern LV2_Feature def_state_feature; + +const LV2_Feature* state_features[9] = { + &uri_map_feature, &map_feature, &unmap_feature, + &make_path_feature, + &state_sched_feature, + &safe_restore_feature, + &log_feature, + &options_feature, + NULL +}; + char* jalv_make_path(LV2_State_Make_Path_Handle handle, const char* path) @@ -178,19 +199,19 @@ set_port_value(const char* port_symbol, void jalv_apply_state(Jalv* jalv, LilvState* state) { + bool must_pause = !jalv->safe_restore && jalv->play_state == JALV_RUNNING; if (state) { - const bool must_pause = (jalv->play_state == JALV_RUNNING); if (must_pause) { jalv->play_state = JALV_PAUSE_REQUESTED; zix_sem_wait(&jalv->paused); } lilv_state_restore( - state, jalv->instance, set_port_value, jalv, 0, NULL); + state, jalv->instance, set_port_value, jalv, 0, state_features); - jalv->state_changed = true; if (must_pause) { - jalv->play_state = JALV_RUNNING; + jalv->request_update = true; + jalv->play_state = JALV_RUNNING; } } } -- cgit v1.2.1