summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-02-25 13:11:07 +0100
committerRobin Gareus <robin@gareus.org>2014-02-25 14:57:59 +0100
commit0708721b4f9fca3967a6f1c436717ff2aca0baec (patch)
tree6b9bb5051d10b5c1728a9643bda229bc38be9fee /libs
parent30de04a58ccab82d00ff87ebdd2cece6c0aa388b (diff)
scan VSTs in background, allow to cancel & timeout
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/plugin_manager.h2
-rw-r--r--libs/ardour/plugin_manager.cc6
-rw-r--r--libs/ardour/vst_info_file.cc10
3 files changed, 15 insertions, 3 deletions
diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h
index 0806935a26..d8e6b4c5ec 100644
--- a/libs/ardour/ardour/plugin_manager.h
+++ b/libs/ardour/ardour/plugin_manager.h
@@ -56,6 +56,8 @@ class LIBARDOUR_API PluginManager : public boost::noncopyable {
void clear_vst_cache ();
void clear_vst_blacklist ();
+ bool cancelled () { return cancel_scan; }
+
int add_windows_vst_directory (std::string dirpath);
int add_lxvst_directory (std::string dirpath);
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc
index 070936add1..c145fd3aa4 100644
--- a/libs/ardour/plugin_manager.cc
+++ b/libs/ardour/plugin_manager.cc
@@ -187,6 +187,7 @@ PluginManager::refresh (bool cache_only)
{
DEBUG_TRACE (DEBUG::PluginManager, "PluginManager::refresh\n");
BootMessage (_("Discovering Plugins"));
+ cancel_scan = false;
ladspa_refresh ();
#ifdef LV2_SUPPORT
@@ -210,12 +211,13 @@ PluginManager::refresh (bool cache_only)
PluginListChanged (); /* EMIT SIGNAL */
PluginScanMessage(X_("closeme"), "");
+ cancel_scan = false;
}
void
PluginManager::cancel_plugin_scan ()
{
- // TODO
+ cancel_scan = true;
}
void
@@ -661,6 +663,7 @@ PluginManager::windows_vst_discover_from_path (string path, bool cache_only)
if (plugin_objects) {
for (x = plugin_objects->begin(); x != plugin_objects->end (); ++x) {
+ if (cancelled()) break;
ARDOUR::PluginScanMessage(_("VST"), **x);
windows_vst_discover (**x, cache_only);
}
@@ -800,6 +803,7 @@ PluginManager::lxvst_discover_from_path (string path, bool cache_only)
if (plugin_objects) {
for (x = plugin_objects->begin(); x != plugin_objects->end (); ++x) {
+ if (cancelled()) break;
ARDOUR::PluginScanMessage(_("LXVST"), **x);
lxvst_discover (**x, cache_only);
}
diff --git a/libs/ardour/vst_info_file.cc b/libs/ardour/vst_info_file.cc
index 8bb3f4aa7a..fac3f199bc 100644
--- a/libs/ardour/vst_info_file.cc
+++ b/libs/ardour/vst_info_file.cc
@@ -52,6 +52,7 @@
#include "ardour/vst_info_file.h"
#define MAX_STRING_LEN 256
+#define PLUGIN_SCAN_TIMEOUT (600) // in deciseconds
using namespace std;
@@ -746,8 +747,13 @@ vstfx_get_info (const char* dllpath, int type, enum VSTScanMode mode)
PBD::error << "Cannot launch VST scanner app '" << scanner_bin_path << "': "<< strerror(errno) << endmsg;
return infos;
} else {
- // TODO idle loop (emit signal to GUI to call gtk_main_iteration()) check cancel.
- scanner.wait();
+ int timeout = PLUGIN_SCAN_TIMEOUT;
+ while (scanner.is_running() && --timeout) {
+ ARDOUR::GUIIdle();
+ Glib::usleep (100000);
+ if (ARDOUR::PluginManager::instance().cancelled()) break;
+ }
+ scanner.terminate();
}
/* re-read index */
vstfx_clear_info_list(infos);