From e398656940fdc931f58a9a502134bbe3574b4f2a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 22 Mar 2019 14:09:03 +0100 Subject: [PATCH] Prevent crashes when copying LV2 plugin state LV2 plugin state-loading is generally safe to perform concurrently with running the plugin (as per LV2 spec). However concurrent run() is not. --- libs/ardour/lv2_plugin.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index c4a1e0c24f..2b45e9e28a 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -2197,7 +2197,17 @@ LV2Plugin::set_state(const XMLNode& node, int version) set_state_dir (""); } - latency_compute_run(); + /* Do not call latency_compute_run() concurrently with connect_and_run(). + * So far this can only guarnteed when the session is loading, + * and the plugin has not been added to the processor chain. + * + * Ideally this would clso be called when copying a plugin from another track, + * but NOT when copying the state from a plugin to another (active) plugin + * instance. + */ + if (_session.loading ()) { + latency_compute_run(); + } #endif return Plugin::set_state(node, version);