From 85d509a292725d7bf19606f1c5cbe1a2db60ab4b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 22 Jul 2021 17:05:40 +0200 Subject: [PATCH] PM: change scan timeout to from out-out to opt-in --- libs/ardour/ardour/plugin_manager.h | 2 ++ libs/ardour/plugin_manager.cc | 29 +++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index 98ade047e4..d4bd3ae8e0 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -86,6 +86,7 @@ public: void cancel_scan_one (); void cancel_scan_timeout_all (); void cancel_scan_timeout_one (); + void enable_scan_timeout (); void clear_vst_cache (); void clear_vst_blacklist (); @@ -293,6 +294,7 @@ private: bool _cancel_scan_all; bool _cancel_scan_timeout_one; bool _cancel_scan_timeout_all; + bool _enable_scan_timeout; void reset_scan_cancel_state (bool single = false); diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 31361f9a8e..58a60e0253 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -186,6 +186,7 @@ PluginManager::PluginManager () , _cancel_scan_all (false) , _cancel_scan_timeout_one (false) , _cancel_scan_timeout_all (false) + , _enable_scan_timeout (false) { char* s; string lrdf_path; @@ -651,6 +652,12 @@ PluginManager::detect_ambiguities () PluginListChanged (); /* EMIT SIGNAL */ } +void +PluginManager::enable_scan_timeout () +{ + _enable_scan_timeout = true; +} + void PluginManager::cancel_scan_all () { @@ -685,6 +692,7 @@ PluginManager::reset_scan_cancel_state (bool single) } _cancel_scan_all = false; _cancel_scan_timeout_all = false; + _enable_scan_timeout = false; } void @@ -1199,19 +1207,22 @@ PluginManager::run_auv2_scanner_app (CAComponentDescription const& desc, AUv2Des return false; } - int timeout = Config->get_vst_scan_timeout(); // deciseconds + int timeout = _enable_scan_timeout ? 1 + Config->get_plugin_scan_timeout() : 0; /* deciseconds */ bool notime = (timeout <= 0); while (scanner.is_running () && (notime || timeout > 0)) { if (!notime && no_timeout ()) { notime = true; timeout = -1; + } else if (notime && !no_timeout() && _enable_scan_timeout) { + notime = false; + timeout = 1 + Config->get_plugin_scan_timeout (); } - ARDOUR::PluginScanTimeout (timeout); if (timeout > -864000) { --timeout; } + ARDOUR::PluginScanTimeout (timeout); Glib::usleep (100000); if (cancelled () || (!notime && timeout == 0)) { @@ -1489,19 +1500,22 @@ PluginManager::run_vst2_scanner_app (std::string path, PSLEPtr psle) const return false; } - int timeout = Config->get_vst_scan_timeout(); // deciseconds + int timeout = _enable_scan_timeout ? 1 + Config->get_plugin_scan_timeout() : 0; /* deciseconds */ bool notime = (timeout <= 0); while (scanner.is_running () && (notime || timeout > 0)) { if (!notime && no_timeout ()) { notime = true; timeout = -1; + } else if (notime && !no_timeout() && _enable_scan_timeout) { + notime = false; + timeout = 1 + Config->get_plugin_scan_timeout (); } - ARDOUR::PluginScanTimeout (timeout); if (timeout > -864000) { --timeout; } + ARDOUR::PluginScanTimeout (timeout); Glib::usleep (100000); if (cancelled () || (!notime && timeout == 0)) { @@ -2247,19 +2261,22 @@ PluginManager::run_vst3_scanner_app (std::string bundle_path, PSLEPtr psle) cons return false; } - int timeout = Config->get_vst_scan_timeout(); // deciseconds + int timeout = _enable_scan_timeout ? 1 + Config->get_plugin_scan_timeout() : 0; /* deciseconds */ bool notime = (timeout <= 0); while (scanner.is_running () && (notime || timeout > 0)) { if (!notime && no_timeout ()) { notime = true; timeout = -1; + } else if (notime && !no_timeout() && _enable_scan_timeout) { + notime = false; + timeout = 1 + Config->get_plugin_scan_timeout (); } - ARDOUR::PluginScanTimeout (timeout); if (timeout > -864000) { --timeout; } + ARDOUR::PluginScanTimeout (timeout); Glib::usleep (100000); if (cancelled () || (!notime && timeout == 0)) {