2 Copyright (C) 2012-2014 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file libs/ardour/vst_info_file.cc
21 * @brief Code to manage info files containing cached information about a plugin.
22 * e.g. its name, creator etc.
27 #include <sys/types.h>
38 #include "pbd/gstdio_compat.h"
41 #include "pbd/error.h"
42 #include "pbd/compose.h"
44 #ifndef VST_SCANNER_APP
45 #include "ardour/plugin_manager.h" // scanner_bin_path
46 #include "ardour/rc_configuration.h"
47 #include "ardour/system_exec.h"
50 #include "ardour/filesystem_paths.h"
51 #include "ardour/linux_vst_support.h"
52 #include "ardour/plugin_types.h"
53 #include "ardour/vst_info_file.h"
58 #define MAX_STRING_LEN 256
59 #define PLUGIN_SCAN_TIMEOUT (Config->get_vst_scan_timeout()) // in deciseconds
62 #ifndef VST_SCANNER_APP
67 #ifdef WINDOWS_VST_SUPPORT
70 vstfx_instantiate_and_get_info_fst (const char* dllpath, vector<VSTInfo*> *infos, int uniqueID);
74 static bool vstfx_instantiate_and_get_info_lx (const char* dllpath, vector<VSTInfo*> *infos, int uniqueID);
77 /* ID for shell plugins */
78 static int vstfx_current_loading_id = 0;
80 /* *** CACHE FILE PATHS *** */
83 get_vst_info_cache_dir () {
84 string dir = Glib::build_filename (ARDOUR::user_cache_directory (), "vst");
85 /* if the directory doesn't exist, try to create it */
86 if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
87 if (g_mkdir (dir.c_str (), 0700)) {
88 PBD::fatal << "Cannot create VST info folder '" << dir << "'" << endmsg;
95 vstfx_infofile_path (const char* dllpath)
100 sha1_write (&s, (const uint8_t *) dllpath, strlen (dllpath));
101 sha1_result_hash (&s, hash);
102 return Glib::build_filename (get_vst_info_cache_dir (), std::string (hash) + std::string (VST_EXT_INFOFILE));
106 /* *** VST Blacklist *** */
108 static void vstfx_read_blacklist (std::string &bl) {
109 FILE * blacklist_fd = NULL;
112 string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST_BLACKLIST);
114 if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) {
118 if (! (blacklist_fd = g_fopen (fn.c_str (), "rb"))) {
122 while (!feof (blacklist_fd)) {
124 size_t s = fread (buf, sizeof(char), 1024, blacklist_fd);
125 if (ferror (blacklist_fd)) {
126 PBD::error << string_compose (_("error reading VST Blacklist file %1 (%2)"), fn, strerror (errno)) << endmsg;
135 ::fclose (blacklist_fd);
138 /** mark plugin as blacklisted */
139 static void vstfx_blacklist (const char *id)
141 string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST_BLACKLIST);
142 FILE * blacklist_fd = NULL;
143 if (! (blacklist_fd = g_fopen (fn.c_str (), "a"))) {
144 PBD::error << string_compose (_("Cannot append to VST blacklist for '%1'"), id) << endmsg;
147 assert (NULL == strchr (id, '\n'));
148 fprintf (blacklist_fd, "%s\n", id);
149 ::fclose (blacklist_fd);
152 /** mark plugin as not blacklisted */
153 static void vstfx_un_blacklist (const char *idcs)
156 string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST_BLACKLIST);
157 if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) {
158 PBD::warning << _("Expected VST Blacklist file does not exist.") << endmsg;
163 vstfx_read_blacklist (bl);
165 ::g_unlink (fn.c_str ());
167 assert (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS));
168 assert (id.find ("\n") == string::npos);
170 id += "\n"; // add separator
171 const size_t rpl = bl.find (id);
172 if (rpl != string::npos) {
173 bl.replace (rpl, id.size (), "");
179 FILE * blacklist_fd = NULL;
180 if (! (blacklist_fd = g_fopen (fn.c_str (), "w"))) {
181 PBD::error << _("Cannot open VST blacklist.") << endmsg;;
184 fprintf (blacklist_fd, "%s", bl.c_str ());
185 ::fclose (blacklist_fd);
188 /* return true if plugin is blacklisted */
189 static bool vst_is_blacklisted (const char *idcs)
191 // TODO ideally we'd also check if the VST has been updated since blacklisting
193 string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST_BLACKLIST);
194 if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) {
199 vstfx_read_blacklist (bl);
201 assert (id.find ("\n") == string::npos);
203 id += "\n"; // add separator
204 const size_t rpl = bl.find (id);
205 if (rpl != string::npos) {
213 /* *** MEMORY MANAGEMENT *** */
215 /** cleanup single allocated VSTInfo */
217 vstfx_free_info (VSTInfo *info)
219 for (int i = 0; i < info->numParams; i++) {
220 free (info->ParamNames[i]);
221 free (info->ParamLabels[i]);
225 free (info->creator);
226 free (info->Category);
227 free (info->ParamNames);
228 free (info->ParamLabels);
234 vstfx_clear_info_list (vector<VSTInfo *> *infos)
236 for (vector<VSTInfo *>::iterator i = infos->begin (); i != infos->end (); ++i) {
237 vstfx_free_info (*i);
243 /* *** CACHE FILE I/O *** */
245 /** Helper function to read a line from the cache file
246 * @return newly allocated string of NULL
249 read_string (FILE *fp)
251 char buf[MAX_STRING_LEN];
253 if (!fgets (buf, MAX_STRING_LEN, fp)) {
257 if (strlen (buf) < MAX_STRING_LEN) {
259 buf[strlen (buf)-1] = 0;
267 /** Read an integer value from a line in fp into n,
268 * @return true on failure, false on success.
271 read_int (FILE* fp, int* n)
273 char buf[MAX_STRING_LEN];
275 char* p = fgets (buf, MAX_STRING_LEN, fp);
280 return (sscanf (p, "%d", n) != 1);
283 /** parse a plugin-block from the cache info file */
285 vstfx_load_info_block (FILE* fp, VSTInfo *info)
287 if ((info->name = read_string (fp)) == 0) return false;
288 if ((info->creator = read_string (fp)) == 0) return false;
289 if (read_int (fp, &info->UniqueID)) return false;
290 if ((info->Category = read_string (fp)) == 0) return false;
291 if (read_int (fp, &info->numInputs)) return false;
292 if (read_int (fp, &info->numOutputs)) return false;
293 if (read_int (fp, &info->numParams)) return false;
294 if (read_int (fp, &info->wantMidi)) return false;
295 if (read_int (fp, &info->hasEditor)) return false;
296 if (read_int (fp, &info->canProcessReplacing)) return false;
298 /* backwards compatibility with old .fsi files */
299 if (info->wantMidi == -1) {
303 if ((info->numParams) == 0) {
304 info->ParamNames = NULL;
305 info->ParamLabels = NULL;
309 if ((info->ParamNames = (char **) malloc (sizeof (char*) * info->numParams)) == 0) {
313 for (int i = 0; i < info->numParams; ++i) {
314 if ((info->ParamNames[i] = read_string (fp)) == 0) return false;
317 if ((info->ParamLabels = (char **) malloc (sizeof (char*) * info->numParams)) == 0) {
321 for (int i = 0; i < info->numParams; ++i) {
322 if ((info->ParamLabels[i] = read_string (fp)) == 0) {
329 /** parse all blocks in a cache info file */
331 vstfx_load_info_file (FILE* fp, vector<VSTInfo*> *infos)
334 if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
337 if (vstfx_load_info_block (fp, info)) {
338 if (strncmp (info->Category, "Shell", 5)) {
339 infos->push_back (info);
342 vstfx_free_info (info);
343 if (!read_int (fp, &plugin_cnt)) {
344 for (int i = 0; i < plugin_cnt; i++) {
345 if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
346 vstfx_clear_info_list (infos);
349 if (vstfx_load_info_block (fp, info)) {
350 infos->push_back (info);
352 vstfx_free_info (info);
353 vstfx_clear_info_list (infos);
358 return false; /* Bad file */
363 vstfx_free_info (info);
364 vstfx_clear_info_list (infos);
369 vstfx_write_info_block (FILE* fp, VSTInfo *info)
374 fprintf (fp, "%s\n", info->name);
375 fprintf (fp, "%s\n", info->creator);
376 fprintf (fp, "%d\n", info->UniqueID);
377 fprintf (fp, "%s\n", info->Category);
378 fprintf (fp, "%d\n", info->numInputs);
379 fprintf (fp, "%d\n", info->numOutputs);
380 fprintf (fp, "%d\n", info->numParams);
381 fprintf (fp, "%d\n", info->wantMidi);
382 fprintf (fp, "%d\n", info->hasEditor);
383 fprintf (fp, "%d\n", info->canProcessReplacing);
385 for (int i = 0; i < info->numParams; i++) {
386 fprintf (fp, "%s\n", info->ParamNames[i]);
389 for (int i = 0; i < info->numParams; i++) {
390 fprintf (fp, "%s\n", info->ParamLabels[i]);
395 vstfx_write_info_file (FILE* fp, vector<VSTInfo *> *infos)
400 if (infos->size () > 1) {
401 vector<VSTInfo *>::iterator x = infos->begin ();
402 /* write out the shell info first along with count of the number of
403 * plugins contained in this shell
405 vstfx_write_info_block (fp, *x);
406 fprintf (fp, "%d\n", (int)infos->size () - 1 );
408 /* Now write out the info for each plugin */
409 for (; x != infos->end (); ++x) {
410 vstfx_write_info_block (fp, *x);
412 } else if (infos->size () == 1) {
413 vstfx_write_info_block (fp, infos->front ());
415 PBD::warning << _("VST object file contains no plugins.") << endmsg;
420 /* *** CACHE MANAGEMENT *** */
422 /** remove info file from cache */
424 vstfx_remove_infofile (const char *dllpath)
426 ::g_unlink (vstfx_infofile_path (dllpath).c_str ());
429 /** cache file for given plugin
430 * @return FILE of the .fsi cache if found and up-to-date*/
432 vstfx_infofile_for_read (const char* dllpath)
434 const size_t slen = strlen (dllpath);
436 (slen <= 3 || g_ascii_strcasecmp (&dllpath[slen-3], ".so"))
438 (slen <= 4 || g_ascii_strcasecmp (&dllpath[slen-4], ".dll"))
443 string const path = vstfx_infofile_path (dllpath);
445 if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
449 if (g_stat (dllpath, &dllstat) == 0) {
450 if (g_stat (path.c_str (), &fsistat) == 0) {
451 if (dllstat.st_mtime <= fsistat.st_mtime) {
452 /* plugin is older than info file */
453 return g_fopen (path.c_str (), "rb");
457 PBD::warning << string_compose (_("Ignored VST plugin which is newer than cache: '%1' (cache: '%2')"), dllpath, path) << endmsg;
458 PBD::info << _("Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.") << endmsg;
463 /** newly created cache file for given plugin
464 * @return FILE for the .fsi cache or NULL on error
467 vstfx_infofile_for_write (const char* dllpath)
469 const size_t slen = strlen (dllpath);
471 (slen <= 3 || g_ascii_strcasecmp (&dllpath[slen-3], ".so"))
473 (slen <= 4 || g_ascii_strcasecmp (&dllpath[slen-4], ".dll"))
478 string const path = vstfx_infofile_path (dllpath);
479 return g_fopen (path.c_str (), "wb");
482 /** check if cache-file exists, is up-to-date and parse cache file
483 * @param infos [return] loaded plugin info
484 * @return true if .fsi cache was read successfully, false otherwise
487 vstfx_get_info_from_file (const char* dllpath, vector<VSTInfo*> *infos)
491 if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
492 rv = vstfx_load_info_file (infofile, infos);
495 PBD::warning << string_compose (_("Cannot get VST information for '%1': failed to load cache file."), dllpath) << endmsg;
503 /* *** VST system-under-test methods *** */
506 bool vstfx_midi_input (VSTState* vstfx)
508 AEffect* plugin = vstfx->plugin;
510 int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f);
512 if (vst_version >= 2) {
513 /* should we send it VST events (i.e. MIDI) */
515 if ((plugin->flags & effFlagsIsSynth) || (plugin->dispatcher (plugin, effCanDo, 0, 0, const_cast<char*> ("receiveVstEvents"), 0.0f) > 0)) {
524 bool vstfx_midi_output (VSTState* vstfx)
526 AEffect* plugin = vstfx->plugin;
528 int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f);
530 if (vst_version >= 2) {
531 /* should we send it VST events (i.e. MIDI) */
533 if ( (plugin->dispatcher (plugin, effCanDo, 0, 0, const_cast<char*> ("sendVstEvents"), 0.0f) > 0)
534 || (plugin->dispatcher (plugin, effCanDo, 0, 0, const_cast<char*> ("sendVstMidiEvent"), 0.0f) > 0)
543 /** simple 'dummy' audiomaster callback to instantiate the plugin
544 * and query information
547 simple_master_callback (AEffect *, int32_t opcode, int32_t, intptr_t, void *ptr, float)
549 const char* vstfx_can_do_strings[] = {
555 "receiveVstMidiEvent",
560 const int vstfx_can_do_string_count = 9;
562 if (opcode == audioMasterVersion) {
565 else if (opcode == audioMasterCanDo) {
566 for (int i = 0; i < vstfx_can_do_string_count; i++) {
567 if (! strcmp (vstfx_can_do_strings[i], (const char*)ptr)) {
573 else if (opcode == audioMasterCurrentId) {
574 return vstfx_current_loading_id;
582 /** main plugin query and test function */
584 vstfx_parse_vst_state (VSTState* vstfx)
588 VSTInfo* info = (VSTInfo*) malloc (sizeof (VSTInfo));
593 /* We need to init the creator because some plugins
594 * fail to implement getVendorString, and so won't stuff the
595 * string with any name */
597 char creator[65] = "Unknown";
600 AEffect* plugin = vstfx->plugin;
603 plugin->dispatcher (plugin, effGetEffectName, 0, 0, name, 0);
605 if (strlen (name) == 0) {
606 plugin->dispatcher (plugin, effGetProductString, 0, 0, name, 0);
609 if (strlen (name) == 0) {
610 info->name = strdup (vstfx->handle->name);
612 info->name = strdup (name);
615 /*If the plugin doesn't bother to implement GetVendorString we will
616 * have pre-stuffed the string with 'Unknown' */
618 plugin->dispatcher (plugin, effGetVendorString, 0, 0, creator, 0);
620 /* Some plugins DO implement GetVendorString, but DON'T put a name in it
621 * so if its just a zero length string we replace it with 'Unknown' */
623 if (strlen (creator) == 0) {
624 info->creator = strdup ("Unknown");
626 info->creator = strdup (creator);
630 switch (plugin->dispatcher (plugin, effGetPlugCategory, 0, 0, 0, 0))
632 case kPlugCategEffect: info->Category = strdup ("Effect"); break;
633 case kPlugCategSynth: info->Category = strdup ("Synth"); break;
634 case kPlugCategAnalysis: info->Category = strdup ("Anaylsis"); break;
635 case kPlugCategMastering: info->Category = strdup ("Mastering"); break;
636 case kPlugCategSpacializer: info->Category = strdup ("Spacializer"); break;
637 case kPlugCategRoomFx: info->Category = strdup ("RoomFx"); break;
638 case kPlugSurroundFx: info->Category = strdup ("SurroundFx"); break;
639 case kPlugCategRestoration: info->Category = strdup ("Restoration"); break;
640 case kPlugCategOfflineProcess: info->Category = strdup ("Offline"); break;
641 case kPlugCategShell: info->Category = strdup ("Shell"); break;
642 case kPlugCategGenerator: info->Category = strdup ("Generator"); break;
643 default: info->Category = strdup ("Unknown"); break;
646 info->UniqueID = plugin->uniqueID;
648 info->numInputs = plugin->numInputs;
649 info->numOutputs = plugin->numOutputs;
650 info->numParams = plugin->numParams;
651 info->wantMidi = (vstfx_midi_input (vstfx) ? 1 : 0) | (vstfx_midi_output (vstfx) ? 2 : 0);
652 info->hasEditor = plugin->flags & effFlagsHasEditor ? true : false;
653 info->canProcessReplacing = plugin->flags & effFlagsCanReplacing ? true : false;
654 info->ParamNames = (char **) malloc (sizeof (char*)*info->numParams);
655 info->ParamLabels = (char **) malloc (sizeof (char*)*info->numParams);
657 for (int i = 0; i < info->numParams; ++i) {
661 /* Not all plugins give parameters labels as well as names */
663 strcpy (name, "No Name");
664 strcpy (label, "No Label");
666 plugin->dispatcher (plugin, effGetParamName, i, 0, name, 0);
667 info->ParamNames[i] = strdup (name);
669 //NOTE: 'effGetParamLabel' is no longer defined in vestige headers
670 //plugin->dispatcher (plugin, effGetParamLabel, i, 0, label, 0);
671 info->ParamLabels[i] = strdup (label);
676 /** wrapper around \ref vstfx_parse_vst_state,
677 * iterate over plugins in shell, translate VST-info into ardour VSTState
680 vstfx_info_from_plugin (const char *dllpath, VSTState* vstfx, vector<VSTInfo *> *infos, enum ARDOUR::PluginType type)
685 if (!(info = vstfx_parse_vst_state (vstfx))) {
689 infos->push_back (info);
690 #if 1 // shell-plugin support
691 /* If this plugin is a Shell and we are not already inside a shell plugin
692 * read the info for all of the plugins contained in this shell.
694 if (!strncmp (info->Category, "Shell", 5)
695 && vstfx->handle->plugincnt == 1) {
697 vector< pair<int, string> > ids;
698 AEffect *plugin = vstfx->plugin;
701 char name[65] = "Unknown";
702 id = plugin->dispatcher (plugin, effShellGetNextPlugin, 0, 0, name, 0);
703 ids.push_back (std::make_pair (id, name));
707 #ifdef WINDOWS_VST_SUPPORT
708 case ARDOUR::Windows_VST:
722 for (vector< pair<int, string> >::iterator x = ids.begin (); x != ids.end (); ++x) {
724 if (id == 0) continue;
725 /* recurse vstfx_get_info() */
729 #ifdef WINDOWS_VST_SUPPORT
730 case ARDOUR::Windows_VST:
731 ok = vstfx_instantiate_and_get_info_fst (dllpath, infos, id);
736 ok = vstfx_instantiate_and_get_info_lx (dllpath, infos, id);
744 // One shell (some?, all?) does not report the actual plugin name
745 // even after the shelled plugin has been instantiated.
746 // Replace the name of the shell with the real name.
747 info = infos->back ();
750 if ((*x).second.length () == 0) {
751 info->name = strdup ("Unknown");
754 info->name = strdup ((*x).second.c_str ());
760 #ifdef WINDOWS_VST_SUPPORT
761 case ARDOUR::Windows_VST:
780 /* *** TOP-LEVEL PLUGIN INSTANTIATION FUNCTIONS *** */
784 vstfx_instantiate_and_get_info_lx (
785 const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
789 if (!(h = vstfx_load (dllpath))) {
790 PBD::warning << string_compose (_("Cannot get LinuxVST information from '%1': load failed."), dllpath) << endmsg;
794 vstfx_current_loading_id = uniqueID;
796 if (!(vstfx = vstfx_instantiate (h, simple_master_callback, 0))) {
798 PBD::warning << string_compose (_("Cannot get LinuxVST information from '%1': instantiation failed."), dllpath) << endmsg;
802 vstfx_current_loading_id = 0;
804 vstfx_info_from_plugin (dllpath, vstfx, infos, ARDOUR::LXVST);
811 #ifdef WINDOWS_VST_SUPPORT
813 vstfx_instantiate_and_get_info_fst (
814 const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
818 if (!(h = fst_load (dllpath))) {
819 PBD::warning << string_compose (_("Cannot get Windows VST information from '%1': load failed."), dllpath) << endmsg;
823 vstfx_current_loading_id = uniqueID;
825 if (!(vstfx = fst_instantiate (h, simple_master_callback, 0))) {
827 vstfx_current_loading_id = 0;
828 PBD::warning << string_compose (_("Cannot get Windows VST information from '%1': instantiation failed."), dllpath) << endmsg;
831 vstfx_current_loading_id = 0;
833 vstfx_info_from_plugin (dllpath, vstfx, infos, ARDOUR::Windows_VST);
841 /* *** ERROR LOGGING *** */
842 #ifndef VST_SCANNER_APP
844 static FILE * _errorlog_fd = 0;
845 static char * _errorlog_dll = 0;
847 static void parse_scanner_output (std::string msg, size_t /*len*/)
849 if (!_errorlog_fd && !_errorlog_dll) {
850 PBD::error << "VST scanner: " << msg;
856 if (!(_errorlog_fd = g_fopen (vstfx_errorfile_path (_errorlog_dll).c_str (), "w"))) {
857 PBD::error << "Cannot create plugin error-log for plugin " << _errorlog_dll;
858 free (_errorlog_dll);
859 _errorlog_dll = NULL;
865 fprintf (_errorlog_fd, "%s\n", msg.c_str ());
866 } else if (_errorlog_dll) {
867 PBD::error << "VST '" << _errorlog_dll << "': " << msg;
869 PBD::error << "VST scanner: " << msg;
874 set_error_log (const char* dllpath) {
875 assert (!_errorlog_fd);
876 assert (!_errorlog_dll);
877 _errorlog_dll = strdup (dllpath);
883 fclose (_errorlog_fd);
886 free (_errorlog_dll);
893 /* *** the main function that uses all of the above *** */
895 static vector<VSTInfo *> *
896 vstfx_get_info (const char* dllpath, enum ARDOUR::PluginType type, enum VSTScanMode mode)
899 vector<VSTInfo*> *infos = new vector<VSTInfo*>;
901 if (vst_is_blacklisted (dllpath)) {
905 if (vstfx_get_info_from_file (dllpath, infos)) {
909 #ifndef VST_SCANNER_APP
910 std::string scanner_bin_path = ARDOUR::PluginManager::scanner_bin_path;
912 if (mode == VST_SCAN_CACHE_ONLY) {
913 /* never scan explicitly, use cache only */
916 else if (mode == VST_SCAN_USE_APP && scanner_bin_path != "") {
917 /* use external scanner app */
919 char **argp= (char**) calloc (3,sizeof (char*));
920 argp[0] = strdup (scanner_bin_path.c_str ());
921 argp[1] = strdup (dllpath);
924 set_error_log (dllpath);
925 ARDOUR::SystemExec scanner (scanner_bin_path, argp);
926 PBD::ScopedConnectionList cons;
927 scanner.ReadStdout.connect_same_thread (cons, boost::bind (&parse_scanner_output, _1 ,_2));
928 if (scanner.start (2 /* send stderr&stdout via signal */)) {
929 PBD::error << string_compose (_("Cannot launch VST scanner app '%1': %2"), scanner_bin_path, strerror (errno)) << endmsg;
933 int timeout = PLUGIN_SCAN_TIMEOUT;
934 bool no_timeout = (timeout <= 0);
935 ARDOUR::PluginScanTimeout (timeout);
936 while (scanner.is_running () && (no_timeout || timeout > 0)) {
937 if (!no_timeout && !ARDOUR::PluginManager::instance ().no_timeout ()) {
938 if (timeout%5 == 0) {
939 ARDOUR::PluginScanTimeout (timeout);
944 Glib::usleep (100000);
946 if (ARDOUR::PluginManager::instance ().cancelled ()) {
947 // remove info file (might be incomplete)
948 vstfx_remove_infofile (dllpath);
949 // remove temporary blacklist file (scan incomplete)
950 vstfx_un_blacklist (dllpath);
951 scanner.terminate ();
956 scanner.terminate ();
959 /* re-read index (generated by external scanner) */
960 vstfx_clear_info_list (infos);
961 if (!vst_is_blacklisted (dllpath)) {
962 vstfx_get_info_from_file (dllpath, infos);
966 /* else .. instantiate and check in in ardour process itself */
968 (void) mode; // unused parameter
972 /* blacklist in case instantiation fails */
973 vstfx_blacklist (dllpath);
976 #ifdef WINDOWS_VST_SUPPORT
977 case ARDOUR::Windows_VST:
978 ok = vstfx_instantiate_and_get_info_fst (dllpath, infos, 0);
983 ok = vstfx_instantiate_and_get_info_lx (dllpath, infos, 0);
995 /* remove from blacklist */
996 vstfx_un_blacklist (dllpath);
998 /* crate cache/whitelist */
999 infofile = vstfx_infofile_for_write (dllpath);
1001 PBD::warning << string_compose (_("Cannot cache VST information for '%1': cannot create cache file."), dllpath) << endmsg;
1004 vstfx_write_info_file (infofile, infos);
1011 /* *** public API *** */
1014 vstfx_free_info_list (vector<VSTInfo *> *infos)
1016 for (vector<VSTInfo *>::iterator i = infos->begin (); i != infos->end (); ++i) {
1017 vstfx_free_info (*i);
1022 #ifdef LXVST_SUPPORT
1024 vstfx_get_info_lx (char* dllpath, enum VSTScanMode mode)
1026 return vstfx_get_info (dllpath, ARDOUR::LXVST, mode);
1030 #ifdef WINDOWS_VST_SUPPORT
1032 vstfx_get_info_fst (char* dllpath, enum VSTScanMode mode)
1034 return vstfx_get_info (dllpath, ARDOUR::Windows_VST, mode);
1038 #ifndef VST_SCANNER_APP