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.
28 #include <sys/types.h>
39 #include <glib/gstdio.h>
42 #include "pbd/error.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"
55 #define MAX_STRING_LEN 256
56 #define PLUGIN_SCAN_TIMEOUT (Config->get_vst_scan_timeout()) // in deciseconds
59 /* CACHE FILE PATHS */
60 #define EXT_BLACKLIST ".fsb"
61 #define EXT_ERRORFILE ".err"
62 #define EXT_INFOFILE ".fsi"
64 #ifdef PLATFORM_WINDOWS
65 #define PFX_DOTFILE ""
67 #define PFX_DOTFILE "."
72 #ifndef VST_SCANNER_APP
77 #ifdef WINDOWS_VST_SUPPORT
80 vstfx_instantiate_and_get_info_fst (const char* dllpath, vector<VSTInfo*> *infos, int uniqueID);
84 static bool vstfx_instantiate_and_get_info_lx (const char* dllpath, vector<VSTInfo*> *infos, int uniqueID);
87 /* ID for shell plugins */
88 static int vstfx_current_loading_id = 0;
92 /* *** CACHE FILE PATHS *** */
95 vstfx_cache_file (const char* dllpath, int personal, const char *ext)
99 dir = get_personal_vst_blacklist_dir();
101 dir = Glib::path_get_dirname (std::string(dllpath));
105 s << PFX_DOTFILE << Glib::path_get_basename (dllpath) << ext;
106 return Glib::build_filename (dir, s.str ());
110 vstfx_blacklist_path (const char* dllpath, int personal)
112 return vstfx_cache_file(dllpath, personal, EXT_BLACKLIST);
116 vstfx_infofile_path (const char* dllpath, int personal)
118 return vstfx_cache_file(dllpath, personal, EXT_INFOFILE);
121 #ifndef VST_SCANNER_APP
123 vstfx_errorfile_path (const char* dllpath, int personal)
125 return vstfx_cache_file(dllpath, personal, EXT_ERRORFILE);
130 /* *** MEMORY MANAGEMENT *** */
132 /** cleanup single allocated VSTInfo */
134 vstfx_free_info (VSTInfo *info)
136 for (int i = 0; i < info->numParams; i++) {
137 free (info->ParamNames[i]);
138 free (info->ParamLabels[i]);
142 free (info->creator);
143 free (info->Category);
144 free (info->ParamNames);
145 free (info->ParamLabels);
151 vstfx_clear_info_list (vector<VSTInfo *> *infos)
153 for (vector<VSTInfo *>::iterator i = infos->begin(); i != infos->end(); ++i) {
161 /* *** CACHE FILE I/O *** */
163 /** Helper function to read a line from the cache file
164 * @return newly allocated string of NULL
167 read_string (FILE *fp)
169 char buf[MAX_STRING_LEN];
171 if (!fgets (buf, MAX_STRING_LEN, fp)) {
175 if (strlen(buf) < MAX_STRING_LEN) {
177 buf[strlen(buf)-1] = 0;
185 /** Read an integer value from a line in fp into n,
186 * @return true on failure, false on success.
189 read_int (FILE* fp, int* n)
191 char buf[MAX_STRING_LEN];
193 char* p = fgets (buf, MAX_STRING_LEN, fp);
198 return (sscanf (p, "%d", n) != 1);
201 /** parse a plugin-block from the cache info file */
203 vstfx_load_info_block(FILE* fp, VSTInfo *info)
205 if ((info->name = read_string(fp)) == 0) return false;
206 if ((info->creator = read_string(fp)) == 0) return false;
207 if (read_int (fp, &info->UniqueID)) return false;
208 if ((info->Category = read_string(fp)) == 0) return false;
209 if (read_int (fp, &info->numInputs)) return false;
210 if (read_int (fp, &info->numOutputs)) return false;
211 if (read_int (fp, &info->numParams)) return false;
212 if (read_int (fp, &info->wantMidi)) return false;
213 if (read_int (fp, &info->hasEditor)) return false;
214 if (read_int (fp, &info->canProcessReplacing)) return false;
216 /* backwards compatibility with old .fsi files */
217 if (info->wantMidi == -1) {
221 if ((info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams)) == 0) {
225 for (int i = 0; i < info->numParams; ++i) {
226 if ((info->ParamNames[i] = read_string(fp)) == 0) return false;
229 if ((info->ParamLabels = (char **) malloc(sizeof(char*)*info->numParams)) == 0) {
233 for (int i = 0; i < info->numParams; ++i) {
234 if ((info->ParamLabels[i] = read_string(fp)) == 0) {
241 /** parse all blocks in a cache info file */
243 vstfx_load_info_file (FILE* fp, vector<VSTInfo*> *infos)
246 if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
249 if (vstfx_load_info_block(fp, info)) {
250 if (strncmp (info->Category, "Shell", 5)) {
251 infos->push_back(info);
254 vstfx_free_info(info);
255 if (!read_int (fp, &plugin_cnt)) {
256 for (int i = 0; i < plugin_cnt; i++) {
257 if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
258 vstfx_clear_info_list(infos);
261 if (vstfx_load_info_block(fp, info)) {
262 infos->push_back(info);
264 vstfx_free_info(info);
265 vstfx_clear_info_list(infos);
270 return false; /* Bad file */
275 vstfx_free_info(info);
276 vstfx_clear_info_list(infos);
281 vstfx_write_info_block (FILE* fp, VSTInfo *info)
286 fprintf (fp, "%s\n", info->name);
287 fprintf (fp, "%s\n", info->creator);
288 fprintf (fp, "%d\n", info->UniqueID);
289 fprintf (fp, "%s\n", info->Category);
290 fprintf (fp, "%d\n", info->numInputs);
291 fprintf (fp, "%d\n", info->numOutputs);
292 fprintf (fp, "%d\n", info->numParams);
293 fprintf (fp, "%d\n", info->wantMidi);
294 fprintf (fp, "%d\n", info->hasEditor);
295 fprintf (fp, "%d\n", info->canProcessReplacing);
297 for (int i = 0; i < info->numParams; i++) {
298 fprintf (fp, "%s\n", info->ParamNames[i]);
301 for (int i = 0; i < info->numParams; i++) {
302 fprintf (fp, "%s\n", info->ParamLabels[i]);
307 vstfx_write_info_file (FILE* fp, vector<VSTInfo *> *infos)
312 if (infos->size() > 1) {
313 vector<VSTInfo *>::iterator x = infos->begin();
314 /* write out the shell info first along with count of the number of
315 * plugins contained in this shell
317 vstfx_write_info_block(fp, *x);
318 fprintf( fp, "%d\n", (int)infos->size() - 1 );
320 /* Now write out the info for each plugin */
321 for (; x != infos->end(); ++x) {
322 vstfx_write_info_block(fp, *x);
324 } else if (infos->size() == 1) {
325 vstfx_write_info_block(fp, infos->front());
327 PBD::error << "Zero plugins in VST." << endmsg; // XXX here? rather make this impossible before if it ain't already.
332 /* *** CACHE AND BLACKLIST MANAGEMENT *** */
334 /* return true if plugin is blacklisted or has an invalid file extension */
336 vstfx_blacklist_stat (const char *dllpath, int personal)
338 if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
341 string const path = vstfx_blacklist_path (dllpath, personal);
343 if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
347 if (stat (dllpath, &dllstat) == 0 && stat (path.c_str(), &fsbstat) == 0) {
348 if (dllstat.st_mtime > fsbstat.st_mtime) {
349 /* plugin is newer than blacklist file */
353 /* stat failed or plugin is older than blacklist file */
356 /* blacklist file does not exist */
360 /* return true if plugin is blacklisted, checks both personal
361 * and global folder */
363 vstfx_check_blacklist (const char *dllpath)
365 if (vstfx_blacklist_stat(dllpath, 0)) return true;
366 if (vstfx_blacklist_stat(dllpath, 1)) return true;
370 /* create blacklist file, preferably in same folder as the
371 * plugin, fall back to personal folder in $HOME
374 vstfx_blacklist_file (const char *dllpath)
377 if ((f = fopen (vstfx_blacklist_path (dllpath, 0).c_str(), "w"))) {
380 return fopen (vstfx_blacklist_path (dllpath, 1).c_str(), "w");
383 /** mark plugin as blacklisted */
385 vstfx_blacklist (const char *dllpath)
387 FILE *f = vstfx_blacklist_file(dllpath);
395 /** mark plugin as not blacklisted */
397 vstfx_un_blacklist (const char *dllpath)
399 ::g_unlink(vstfx_blacklist_path (dllpath, 0).c_str());
400 ::g_unlink(vstfx_blacklist_path (dllpath, 1).c_str());
403 /** remove info file from cache */
405 vstfx_remove_infofile (const char *dllpath)
407 ::g_unlink(vstfx_infofile_path (dllpath, 0).c_str());
408 ::g_unlink(vstfx_infofile_path (dllpath, 1).c_str());
411 /** helper function, check if cache is newer than plugin
412 * @return path to cache file */
414 vstfx_infofile_stat (const char *dllpath, struct stat* statbuf, int personal)
416 if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
420 string const path = vstfx_infofile_path (dllpath, personal);
422 if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
426 if (stat (dllpath, &dllstat) == 0) {
427 if (stat (path.c_str(), statbuf) == 0) {
428 if (dllstat.st_mtime <= statbuf->st_mtime) {
429 /* plugin is older than info file */
430 return strdup (path.c_str ());
439 /** cache file for given plugin
440 * @return FILE of the .fsi cache if found and up-to-date*/
442 vstfx_infofile_for_read (const char* dllpath)
444 struct stat own_statbuf;
445 struct stat sys_statbuf;
448 char* own_info = vstfx_infofile_stat (dllpath, &own_statbuf, 1);
449 char* sys_info = vstfx_infofile_stat (dllpath, &sys_statbuf, 0);
453 if (own_statbuf.st_mtime <= sys_statbuf.st_mtime) {
454 /* system info file is newer, use it */
455 rv = g_fopen (sys_info, "rb");
458 rv = g_fopen (own_info, "rb");
460 } else if (sys_info) {
461 rv = g_fopen (sys_info, "rb");
469 /** helper function for \ref vstfx_infofile_for_write
470 * abstract global and personal cache folders
473 vstfx_infofile_create (const char* dllpath, int personal)
475 if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
479 string const path = vstfx_infofile_path (dllpath, personal);
480 return fopen (path.c_str(), "w");
483 /** newly created cache file for given plugin
484 * @return FILE for the .fsi cache, NULL if neither personal,
485 * nor global cache folder is writable */
487 vstfx_infofile_for_write (const char* dllpath)
491 if ((f = vstfx_infofile_create (dllpath, 0)) == 0) {
492 f = vstfx_infofile_create (dllpath, 1);
498 /** check if cache-file exists, is up-to-date and parse cache file
499 * @param infos [return] loaded plugin info
500 * @return true if .fsi cache was read successfully, false otherwise
503 vstfx_get_info_from_file(const char* dllpath, vector<VSTInfo*> *infos)
507 if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
508 rv = vstfx_load_info_file(infofile, infos);
511 PBD::warning << "Cannot get VST information form " << dllpath << ": info file load failed." << endmsg;
519 /* *** VST system-under-test methods *** */
522 bool vstfx_midi_input (VSTState* vstfx)
524 AEffect* plugin = vstfx->plugin;
526 int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f);
528 if (vst_version >= 2) {
529 /* should we send it VST events (i.e. MIDI) */
531 if ((plugin->flags & effFlagsIsSynth) || (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "receiveVstEvents", 0.0f) > 0)) {
540 bool vstfx_midi_output (VSTState* vstfx)
542 AEffect* plugin = vstfx->plugin;
544 int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f);
546 if (vst_version >= 2) {
547 /* should we send it VST events (i.e. MIDI) */
549 if ( (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "sendVstEvents", 0.0f) > 0)
550 || (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "sendVstMidiEvent", 0.0f) > 0)
559 /** simple 'dummy' audiomaster callback to instantiate the plugin
560 * and query information
563 simple_master_callback (AEffect *, int32_t opcode, int32_t, intptr_t, void *ptr, float)
565 const char* vstfx_can_do_strings[] = {
571 "receiveVstMidiEvent",
576 const int vstfx_can_do_string_count = 9;
578 if (opcode == audioMasterVersion) {
581 else if (opcode == audioMasterCanDo) {
582 for (int i = 0; i < vstfx_can_do_string_count; i++) {
583 if (! strcmp(vstfx_can_do_strings[i], (const char*)ptr)) {
589 else if (opcode == audioMasterCurrentId) {
590 return vstfx_current_loading_id;
598 /** main plugin query and test function */
600 vstfx_parse_vst_state (VSTState* vstfx)
604 VSTInfo* info = (VSTInfo*) malloc (sizeof (VSTInfo));
609 /*We need to init the creator because some plugins
610 fail to implement getVendorString, and so won't stuff the
611 string with any name*/
613 char creator[65] = "Unknown";
616 AEffect* plugin = vstfx->plugin;
619 plugin->dispatcher (plugin, effGetEffectName, 0, 0, name, 0);
621 if (strlen(name) == 0) {
622 plugin->dispatcher (plugin, effGetProductString, 0, 0, name, 0);
625 if (strlen(name) == 0) {
626 info->name = strdup (vstfx->handle->name);
628 info->name = strdup (name);
631 /*If the plugin doesn't bother to implement GetVendorString we will
632 have pre-stuffed the string with 'Unknown' */
634 plugin->dispatcher (plugin, effGetVendorString, 0, 0, creator, 0);
636 /*Some plugins DO implement GetVendorString, but DON'T put a name in it
637 so if its just a zero length string we replace it with 'Unknown' */
639 if (strlen(creator) == 0) {
640 info->creator = strdup ("Unknown");
642 info->creator = strdup (creator);
646 switch (plugin->dispatcher (plugin, effGetPlugCategory, 0, 0, 0, 0))
648 case kPlugCategEffect: info->Category = strdup ("Effect"); break;
649 case kPlugCategSynth: info->Category = strdup ("Synth"); break;
650 case kPlugCategAnalysis: info->Category = strdup ("Anaylsis"); break;
651 case kPlugCategMastering: info->Category = strdup ("Mastering"); break;
652 case kPlugCategSpacializer: info->Category = strdup ("Spacializer"); break;
653 case kPlugCategRoomFx: info->Category = strdup ("RoomFx"); break;
654 case kPlugSurroundFx: info->Category = strdup ("SurroundFx"); break;
655 case kPlugCategRestoration: info->Category = strdup ("Restoration"); break;
656 case kPlugCategOfflineProcess: info->Category = strdup ("Offline"); break;
657 case kPlugCategShell: info->Category = strdup ("Shell"); break;
658 case kPlugCategGenerator: info->Category = strdup ("Generator"); break;
659 default: info->Category = strdup ("Unknown"); break;
662 info->UniqueID = plugin->uniqueID;
664 info->numInputs = plugin->numInputs;
665 info->numOutputs = plugin->numOutputs;
666 info->numParams = plugin->numParams;
667 info->wantMidi = (vstfx_midi_input(vstfx) ? 1 : 0) | (vstfx_midi_output(vstfx) ? 2 : 0);
668 info->hasEditor = plugin->flags & effFlagsHasEditor ? true : false;
669 info->canProcessReplacing = plugin->flags & effFlagsCanReplacing ? true : false;
670 info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams);
671 info->ParamLabels = (char **) malloc(sizeof(char*)*info->numParams);
673 for (int i = 0; i < info->numParams; ++i) {
677 /* Not all plugins give parameters labels as well as names */
679 strcpy (name, "No Name");
680 strcpy (label, "No Label");
682 plugin->dispatcher (plugin, effGetParamName, i, 0, name, 0);
683 info->ParamNames[i] = strdup(name);
685 //NOTE: 'effGetParamLabel' is no longer defined in vestige headers
686 //plugin->dispatcher (plugin, effGetParamLabel, i, 0, label, 0);
687 info->ParamLabels[i] = strdup(label);
692 /** wrapper around \ref vstfx_parse_vst_state,
693 * iterate over plugins in shell, translate VST-info into ardour VSTState
696 vstfx_info_from_plugin (const char *dllpath, VSTState* vstfx, vector<VSTInfo *> *infos, enum ARDOUR::PluginType type)
701 if (!(info = vstfx_parse_vst_state(vstfx))) {
705 infos->push_back(info);
706 #if 1 // shell-plugin support
707 /* If this plugin is a Shell and we are not already inside a shell plugin
708 * read the info for all of the plugins contained in this shell.
710 if (!strncmp (info->Category, "Shell", 5)
711 && vstfx->handle->plugincnt == 1) {
713 vector< pair<int, string> > ids;
714 AEffect *plugin = vstfx->plugin;
715 string path = vstfx->handle->path;
718 char name[65] = "Unknown";
719 id = plugin->dispatcher (plugin, effShellGetNextPlugin, 0, 0, name, 0);
720 ids.push_back(std::make_pair(id, name));
724 #ifdef WINDOWS_VST_SUPPORT
725 case ARDOUR::Windows_VST: fst_close(vstfx); break;
728 case ARDOUR::LXVST: vstfx_close (vstfx); break;
730 default: assert(0); break;
733 for (vector< pair<int, string> >::iterator x = ids.begin(); x != ids.end(); ++x) {
735 if (id == 0) continue;
736 /* recurse vstfx_get_info() */
740 #ifdef WINDOWS_VST_SUPPORT
741 case ARDOUR::Windows_VST: ok = vstfx_instantiate_and_get_info_fst(dllpath, infos, id); break;
744 case ARDOUR::LXVST: ok = vstfx_instantiate_and_get_info_lx(dllpath, infos, id); break;
749 // One shell (some?, all?) does not report the actual plugin name
750 // even after the shelled plugin has been instantiated.
751 // Replace the name of the shell with the real name.
752 info = infos->back();
755 if ((*x).second.length() == 0) {
756 info->name = strdup("Unknown");
759 info->name = strdup ((*x).second.c_str());
765 #ifdef WINDOWS_VST_SUPPORT
766 case ARDOUR::Windows_VST: fst_close(vstfx); break;
769 case ARDOUR::LXVST: vstfx_close (vstfx); break;
771 default: assert(0); break;
779 /* *** TOP-LEVEL PLUGIN INSTANTIATION FUNCTIONS *** */
783 vstfx_instantiate_and_get_info_lx (
784 const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
788 if (!(h = vstfx_load(dllpath))) {
789 PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": load failed." << endmsg;
793 vstfx_current_loading_id = uniqueID;
795 if (!(vstfx = vstfx_instantiate(h, simple_master_callback, 0))) {
797 PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": instantiation failed." << endmsg;
801 vstfx_current_loading_id = 0;
803 vstfx_info_from_plugin(dllpath, vstfx, infos, ARDOUR::LXVST);
810 #ifdef WINDOWS_VST_SUPPORT
812 vstfx_instantiate_and_get_info_fst (
813 const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
817 if(!(h = fst_load(dllpath))) {
818 PBD::warning << "Cannot get Windows VST information from " << dllpath << ": load failed." << endmsg;
822 vstfx_current_loading_id = uniqueID;
824 if(!(vstfx = fst_instantiate(h, simple_master_callback, 0))) {
826 vstfx_current_loading_id = 0;
827 PBD::warning << "Cannot get Windows VST information from " << dllpath << ": instantiation failed." << endmsg;
830 vstfx_current_loading_id = 0;
832 vstfx_info_from_plugin(dllpath, vstfx, infos, ARDOUR::Windows_VST);
840 /* *** ERROR LOGGING *** */
841 #ifndef VST_SCANNER_APP
843 static FILE * _errorlog_fd = 0;
844 static char * _errorlog_dll = 0;
846 static void parse_scanner_output (std::string msg, size_t /*len*/)
848 if (!_errorlog_fd && !_errorlog_dll) {
849 PBD::error << "VST scanner: " << msg;
854 if (!(_errorlog_fd = fopen(vstfx_errorfile_path(_errorlog_dll, 0).c_str(), "w"))) {
855 if (!(_errorlog_fd = fopen(vstfx_errorfile_path(_errorlog_dll, 1).c_str(), "w"))) {
856 PBD::error << "Cannot create plugin error-log for plugin " << _errorlog_dll;
858 _errorlog_dll = NULL;
864 fprintf (_errorlog_fd, "%s\n", msg.c_str());
866 PBD::error << "VST scanner: " << msg;
871 set_error_log (const char* dllpath) {
872 assert(!_errorlog_fd);
873 assert(!_errorlog_dll);
874 _errorlog_dll = strdup(dllpath);
880 fclose(_errorlog_fd);
890 /* *** THE MAIN FUNCTION THAT USES ALL OF THE ABOVE :) *** */
892 static vector<VSTInfo *> *
893 vstfx_get_info (const char* dllpath, enum ARDOUR::PluginType type, enum VSTScanMode mode)
896 vector<VSTInfo*> *infos = new vector<VSTInfo*>;
898 if (vstfx_check_blacklist(dllpath)) {
902 if (vstfx_get_info_from_file(dllpath, infos)) {
906 #ifndef VST_SCANNER_APP
907 std::string scanner_bin_path = ARDOUR::PluginManager::scanner_bin_path;
909 if (mode == VST_SCAN_CACHE_ONLY) {
910 /* never scan explicitly, use cache only */
913 else if (mode == VST_SCAN_USE_APP && scanner_bin_path != "") {
914 /* use external scanner app */
916 char **argp= (char**) calloc(3,sizeof(char*));
917 argp[0] = strdup(scanner_bin_path.c_str());
918 argp[1] = strdup(dllpath);
921 set_error_log(dllpath);
922 ARDOUR::SystemExec scanner (scanner_bin_path, argp);
923 PBD::ScopedConnectionList cons;
924 scanner.ReadStdout.connect_same_thread (cons, boost::bind (&parse_scanner_output, _1 ,_2));
925 if (scanner.start (2 /* send stderr&stdout via signal */)) {
926 PBD::error << "Cannot launch VST scanner app '" << scanner_bin_path << "': "<< strerror(errno) << endmsg;
930 int timeout = PLUGIN_SCAN_TIMEOUT;
931 bool no_timeout = (timeout <= 0);
932 ARDOUR::PluginScanTimeout(timeout);
933 while (scanner.is_running() && (no_timeout || timeout > 0)) {
934 if (!no_timeout && !ARDOUR::PluginManager::instance().no_timeout()) {
935 if (timeout%5 == 0) {
936 ARDOUR::PluginScanTimeout(timeout);
941 Glib::usleep (100000);
943 if (ARDOUR::PluginManager::instance().cancelled()) {
944 // remove info file (might be incomplete)
945 vstfx_remove_infofile(dllpath);
946 // remove temporary blacklist file (scan incomplete)
947 vstfx_un_blacklist(dllpath);
956 /* re-read index (generated by external scanner) */
957 vstfx_clear_info_list(infos);
958 if (!vstfx_check_blacklist(dllpath)) {
959 vstfx_get_info_from_file(dllpath, infos);
963 /* else .. instantiate and check in in ardour process itself */
965 (void) mode; // unused parameter
969 /* blacklist in case instantiation fails */
970 vstfx_blacklist(dllpath);
973 #ifdef WINDOWS_VST_SUPPORT
974 case ARDOUR::Windows_VST: ok = vstfx_instantiate_and_get_info_fst(dllpath, infos, 0); break;
977 case ARDOUR::LXVST: ok = vstfx_instantiate_and_get_info_lx(dllpath, infos, 0); break;
986 /* remove from blacklist */
987 vstfx_un_blacklist(dllpath);
989 /* crate cache/whitelist */
990 infofile = vstfx_infofile_for_write (dllpath);
992 PBD::warning << "Cannot cache VST information for " << dllpath << ": cannot create new FST info file." << endmsg;
995 vstfx_write_info_file (infofile, infos);
1003 /* *** public API *** */
1006 vstfx_free_info_list (vector<VSTInfo *> *infos)
1008 for (vector<VSTInfo *>::iterator i = infos->begin(); i != infos->end(); ++i) {
1009 vstfx_free_info(*i);
1015 get_personal_vst_blacklist_dir() {
1016 string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_blacklist");
1017 /* if the directory doesn't exist, try to create it */
1018 if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
1019 if (g_mkdir (dir.c_str (), 0700)) {
1020 PBD::error << "Cannot create VST blacklist folder '" << dir << "'" << endmsg;
1028 get_personal_vst_info_cache_dir() {
1029 string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_info");
1030 /* if the directory doesn't exist, try to create it */
1031 if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
1032 if (g_mkdir (dir.c_str (), 0700)) {
1033 PBD::error << "Cannot create VST info folder '" << dir << "'" << endmsg;
1040 #ifdef LXVST_SUPPORT
1042 vstfx_get_info_lx (char* dllpath, enum VSTScanMode mode)
1044 return vstfx_get_info(dllpath, ARDOUR::LXVST, mode);
1048 #ifdef WINDOWS_VST_SUPPORT
1050 vstfx_get_info_fst (char* dllpath, enum VSTScanMode mode)
1052 return vstfx_get_info(dllpath, ARDOUR::Windows_VST, mode);
1056 #ifndef VST_SCANNER_APP