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_info_cache_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)
114 dir = get_personal_vst_blacklist_dir();
116 dir = Glib::path_get_dirname (std::string(dllpath));
120 s << PFX_DOTFILE << Glib::path_get_basename (dllpath) << EXT_BLACKLIST;
121 return Glib::build_filename (dir, s.str ());
125 vstfx_infofile_path (const char* dllpath, int personal)
127 return vstfx_cache_file(dllpath, personal, EXT_INFOFILE);
130 #ifndef VST_SCANNER_APP
132 vstfx_errorfile_path (const char* dllpath, int personal)
134 return vstfx_cache_file(dllpath, personal, EXT_ERRORFILE);
139 /* *** MEMORY MANAGEMENT *** */
141 /** cleanup single allocated VSTInfo */
143 vstfx_free_info (VSTInfo *info)
145 for (int i = 0; i < info->numParams; i++) {
146 free (info->ParamNames[i]);
147 free (info->ParamLabels[i]);
151 free (info->creator);
152 free (info->Category);
153 free (info->ParamNames);
154 free (info->ParamLabels);
160 vstfx_clear_info_list (vector<VSTInfo *> *infos)
162 for (vector<VSTInfo *>::iterator i = infos->begin(); i != infos->end(); ++i) {
170 /* *** CACHE FILE I/O *** */
172 /** Helper function to read a line from the cache file
173 * @return newly allocated string of NULL
176 read_string (FILE *fp)
178 char buf[MAX_STRING_LEN];
180 if (!fgets (buf, MAX_STRING_LEN, fp)) {
184 if (strlen(buf) < MAX_STRING_LEN) {
186 buf[strlen(buf)-1] = 0;
194 /** Read an integer value from a line in fp into n,
195 * @return true on failure, false on success.
198 read_int (FILE* fp, int* n)
200 char buf[MAX_STRING_LEN];
202 char* p = fgets (buf, MAX_STRING_LEN, fp);
207 return (sscanf (p, "%d", n) != 1);
210 /** parse a plugin-block from the cache info file */
212 vstfx_load_info_block(FILE* fp, VSTInfo *info)
214 if ((info->name = read_string(fp)) == 0) return false;
215 if ((info->creator = read_string(fp)) == 0) return false;
216 if (read_int (fp, &info->UniqueID)) return false;
217 if ((info->Category = read_string(fp)) == 0) return false;
218 if (read_int (fp, &info->numInputs)) return false;
219 if (read_int (fp, &info->numOutputs)) return false;
220 if (read_int (fp, &info->numParams)) return false;
221 if (read_int (fp, &info->wantMidi)) return false;
222 if (read_int (fp, &info->hasEditor)) return false;
223 if (read_int (fp, &info->canProcessReplacing)) return false;
225 /* backwards compatibility with old .fsi files */
226 if (info->wantMidi == -1) {
230 if ((info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams)) == 0) {
234 for (int i = 0; i < info->numParams; ++i) {
235 if ((info->ParamNames[i] = read_string(fp)) == 0) return false;
238 if ((info->ParamLabels = (char **) malloc(sizeof(char*)*info->numParams)) == 0) {
242 for (int i = 0; i < info->numParams; ++i) {
243 if ((info->ParamLabels[i] = read_string(fp)) == 0) {
250 /** parse all blocks in a cache info file */
252 vstfx_load_info_file (FILE* fp, vector<VSTInfo*> *infos)
255 if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
258 if (vstfx_load_info_block(fp, info)) {
259 if (strncmp (info->Category, "Shell", 5)) {
260 infos->push_back(info);
263 vstfx_free_info(info);
264 if (!read_int (fp, &plugin_cnt)) {
265 for (int i = 0; i < plugin_cnt; i++) {
266 if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
267 vstfx_clear_info_list(infos);
270 if (vstfx_load_info_block(fp, info)) {
271 infos->push_back(info);
273 vstfx_free_info(info);
274 vstfx_clear_info_list(infos);
279 return false; /* Bad file */
284 vstfx_free_info(info);
285 vstfx_clear_info_list(infos);
290 vstfx_write_info_block (FILE* fp, VSTInfo *info)
295 fprintf (fp, "%s\n", info->name);
296 fprintf (fp, "%s\n", info->creator);
297 fprintf (fp, "%d\n", info->UniqueID);
298 fprintf (fp, "%s\n", info->Category);
299 fprintf (fp, "%d\n", info->numInputs);
300 fprintf (fp, "%d\n", info->numOutputs);
301 fprintf (fp, "%d\n", info->numParams);
302 fprintf (fp, "%d\n", info->wantMidi);
303 fprintf (fp, "%d\n", info->hasEditor);
304 fprintf (fp, "%d\n", info->canProcessReplacing);
306 for (int i = 0; i < info->numParams; i++) {
307 fprintf (fp, "%s\n", info->ParamNames[i]);
310 for (int i = 0; i < info->numParams; i++) {
311 fprintf (fp, "%s\n", info->ParamLabels[i]);
316 vstfx_write_info_file (FILE* fp, vector<VSTInfo *> *infos)
321 if (infos->size() > 1) {
322 vector<VSTInfo *>::iterator x = infos->begin();
323 /* write out the shell info first along with count of the number of
324 * plugins contained in this shell
326 vstfx_write_info_block(fp, *x);
327 fprintf( fp, "%d\n", (int)infos->size() - 1 );
329 /* Now write out the info for each plugin */
330 for (; x != infos->end(); ++x) {
331 vstfx_write_info_block(fp, *x);
333 } else if (infos->size() == 1) {
334 vstfx_write_info_block(fp, infos->front());
336 PBD::error << "Zero plugins in VST." << endmsg; // XXX here? rather make this impossible before if it ain't already.
341 /* *** CACHE AND BLACKLIST MANAGEMENT *** */
343 /* return true if plugin is blacklisted or has an invalid file extension */
345 vstfx_blacklist_stat (const char *dllpath, int personal)
347 if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
350 string const path = vstfx_blacklist_path (dllpath, personal);
352 if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
356 if (stat (dllpath, &dllstat) == 0 && stat (path.c_str(), &fsbstat) == 0) {
357 if (dllstat.st_mtime > fsbstat.st_mtime) {
358 /* plugin is newer than blacklist file */
362 /* stat failed or plugin is older than blacklist file */
365 /* blacklist file does not exist */
369 /* return true if plugin is blacklisted, checks both personal
370 * and global folder */
372 vstfx_check_blacklist (const char *dllpath)
374 if (vstfx_blacklist_stat(dllpath, 0)) return true;
375 if (vstfx_blacklist_stat(dllpath, 1)) return true;
379 /* create blacklist file, preferably in same folder as the
380 * plugin, fall back to personal folder in $HOME
383 vstfx_blacklist_file (const char *dllpath)
386 if ((f = fopen (vstfx_blacklist_path (dllpath, 0).c_str(), "wb"))) {
389 return fopen (vstfx_blacklist_path (dllpath, 1).c_str(), "wb");
392 /** mark plugin as blacklisted */
394 vstfx_blacklist (const char *dllpath)
396 FILE *f = vstfx_blacklist_file(dllpath);
404 /** mark plugin as not blacklisted */
406 vstfx_un_blacklist (const char *dllpath)
408 ::g_unlink(vstfx_blacklist_path (dllpath, 0).c_str());
409 ::g_unlink(vstfx_blacklist_path (dllpath, 1).c_str());
412 /** remove info file from cache */
414 vstfx_remove_infofile (const char *dllpath)
416 ::g_unlink(vstfx_infofile_path (dllpath, 0).c_str());
417 ::g_unlink(vstfx_infofile_path (dllpath, 1).c_str());
420 /** helper function, check if cache is newer than plugin
421 * @return path to cache file */
423 vstfx_infofile_stat (const char *dllpath, struct stat* statbuf, int personal)
425 if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
429 string const path = vstfx_infofile_path (dllpath, personal);
431 if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
435 if (stat (dllpath, &dllstat) == 0) {
436 if (stat (path.c_str(), statbuf) == 0) {
437 if (dllstat.st_mtime <= statbuf->st_mtime) {
438 /* plugin is older than info file */
439 return strdup (path.c_str ());
448 /** cache file for given plugin
449 * @return FILE of the .fsi cache if found and up-to-date*/
451 vstfx_infofile_for_read (const char* dllpath)
453 struct stat own_statbuf;
454 struct stat sys_statbuf;
457 char* own_info = vstfx_infofile_stat (dllpath, &own_statbuf, 1);
458 char* sys_info = vstfx_infofile_stat (dllpath, &sys_statbuf, 0);
462 if (own_statbuf.st_mtime <= sys_statbuf.st_mtime) {
463 /* system info file is newer, use it */
464 rv = g_fopen (sys_info, "rb");
467 rv = g_fopen (own_info, "rb");
469 } else if (sys_info) {
470 rv = g_fopen (sys_info, "rb");
478 /** helper function for \ref vstfx_infofile_for_write
479 * abstract global and personal cache folders
482 vstfx_infofile_create (const char* dllpath, int personal)
484 if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
488 string const path = vstfx_infofile_path (dllpath, personal);
489 return fopen (path.c_str(), "wb");
492 /** newly created cache file for given plugin
493 * @return FILE for the .fsi cache, NULL if neither personal,
494 * nor global cache folder is writable */
496 vstfx_infofile_for_write (const char* dllpath)
500 if ((f = vstfx_infofile_create (dllpath, 0)) == 0) {
501 f = vstfx_infofile_create (dllpath, 1);
507 /** check if cache-file exists, is up-to-date and parse cache file
508 * @param infos [return] loaded plugin info
509 * @return true if .fsi cache was read successfully, false otherwise
512 vstfx_get_info_from_file(const char* dllpath, vector<VSTInfo*> *infos)
516 if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
517 rv = vstfx_load_info_file(infofile, infos);
520 PBD::warning << "Cannot get VST information form " << dllpath << ": info file load failed." << endmsg;
528 /* *** VST system-under-test methods *** */
531 bool vstfx_midi_input (VSTState* vstfx)
533 AEffect* plugin = vstfx->plugin;
535 int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f);
537 if (vst_version >= 2) {
538 /* should we send it VST events (i.e. MIDI) */
540 if ((plugin->flags & effFlagsIsSynth) || (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "receiveVstEvents", 0.0f) > 0)) {
549 bool vstfx_midi_output (VSTState* vstfx)
551 AEffect* plugin = vstfx->plugin;
553 int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f);
555 if (vst_version >= 2) {
556 /* should we send it VST events (i.e. MIDI) */
558 if ( (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "sendVstEvents", 0.0f) > 0)
559 || (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "sendVstMidiEvent", 0.0f) > 0)
568 /** simple 'dummy' audiomaster callback to instantiate the plugin
569 * and query information
572 simple_master_callback (AEffect *, int32_t opcode, int32_t, intptr_t, void *ptr, float)
574 const char* vstfx_can_do_strings[] = {
580 "receiveVstMidiEvent",
585 const int vstfx_can_do_string_count = 9;
587 if (opcode == audioMasterVersion) {
590 else if (opcode == audioMasterCanDo) {
591 for (int i = 0; i < vstfx_can_do_string_count; i++) {
592 if (! strcmp(vstfx_can_do_strings[i], (const char*)ptr)) {
598 else if (opcode == audioMasterCurrentId) {
599 return vstfx_current_loading_id;
607 /** main plugin query and test function */
609 vstfx_parse_vst_state (VSTState* vstfx)
613 VSTInfo* info = (VSTInfo*) malloc (sizeof (VSTInfo));
618 /*We need to init the creator because some plugins
619 fail to implement getVendorString, and so won't stuff the
620 string with any name*/
622 char creator[65] = "Unknown";
625 AEffect* plugin = vstfx->plugin;
628 plugin->dispatcher (plugin, effGetEffectName, 0, 0, name, 0);
630 if (strlen(name) == 0) {
631 plugin->dispatcher (plugin, effGetProductString, 0, 0, name, 0);
634 if (strlen(name) == 0) {
635 info->name = strdup (vstfx->handle->name);
637 info->name = strdup (name);
640 /*If the plugin doesn't bother to implement GetVendorString we will
641 have pre-stuffed the string with 'Unknown' */
643 plugin->dispatcher (plugin, effGetVendorString, 0, 0, creator, 0);
645 /*Some plugins DO implement GetVendorString, but DON'T put a name in it
646 so if its just a zero length string we replace it with 'Unknown' */
648 if (strlen(creator) == 0) {
649 info->creator = strdup ("Unknown");
651 info->creator = strdup (creator);
655 switch (plugin->dispatcher (plugin, effGetPlugCategory, 0, 0, 0, 0))
657 case kPlugCategEffect: info->Category = strdup ("Effect"); break;
658 case kPlugCategSynth: info->Category = strdup ("Synth"); break;
659 case kPlugCategAnalysis: info->Category = strdup ("Anaylsis"); break;
660 case kPlugCategMastering: info->Category = strdup ("Mastering"); break;
661 case kPlugCategSpacializer: info->Category = strdup ("Spacializer"); break;
662 case kPlugCategRoomFx: info->Category = strdup ("RoomFx"); break;
663 case kPlugSurroundFx: info->Category = strdup ("SurroundFx"); break;
664 case kPlugCategRestoration: info->Category = strdup ("Restoration"); break;
665 case kPlugCategOfflineProcess: info->Category = strdup ("Offline"); break;
666 case kPlugCategShell: info->Category = strdup ("Shell"); break;
667 case kPlugCategGenerator: info->Category = strdup ("Generator"); break;
668 default: info->Category = strdup ("Unknown"); break;
671 info->UniqueID = plugin->uniqueID;
673 info->numInputs = plugin->numInputs;
674 info->numOutputs = plugin->numOutputs;
675 info->numParams = plugin->numParams;
676 info->wantMidi = (vstfx_midi_input(vstfx) ? 1 : 0) | (vstfx_midi_output(vstfx) ? 2 : 0);
677 info->hasEditor = plugin->flags & effFlagsHasEditor ? true : false;
678 info->canProcessReplacing = plugin->flags & effFlagsCanReplacing ? true : false;
679 info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams);
680 info->ParamLabels = (char **) malloc(sizeof(char*)*info->numParams);
682 for (int i = 0; i < info->numParams; ++i) {
686 /* Not all plugins give parameters labels as well as names */
688 strcpy (name, "No Name");
689 strcpy (label, "No Label");
691 plugin->dispatcher (plugin, effGetParamName, i, 0, name, 0);
692 info->ParamNames[i] = strdup(name);
694 //NOTE: 'effGetParamLabel' is no longer defined in vestige headers
695 //plugin->dispatcher (plugin, effGetParamLabel, i, 0, label, 0);
696 info->ParamLabels[i] = strdup(label);
701 /** wrapper around \ref vstfx_parse_vst_state,
702 * iterate over plugins in shell, translate VST-info into ardour VSTState
705 vstfx_info_from_plugin (const char *dllpath, VSTState* vstfx, vector<VSTInfo *> *infos, enum ARDOUR::PluginType type)
710 if (!(info = vstfx_parse_vst_state(vstfx))) {
714 infos->push_back(info);
715 #if 1 // shell-plugin support
716 /* If this plugin is a Shell and we are not already inside a shell plugin
717 * read the info for all of the plugins contained in this shell.
719 if (!strncmp (info->Category, "Shell", 5)
720 && vstfx->handle->plugincnt == 1) {
722 vector< pair<int, string> > ids;
723 AEffect *plugin = vstfx->plugin;
724 string path = vstfx->handle->path;
727 char name[65] = "Unknown";
728 id = plugin->dispatcher (plugin, effShellGetNextPlugin, 0, 0, name, 0);
729 ids.push_back(std::make_pair(id, name));
733 #ifdef WINDOWS_VST_SUPPORT
734 case ARDOUR::Windows_VST: fst_close(vstfx); break;
737 case ARDOUR::LXVST: vstfx_close (vstfx); break;
739 default: assert(0); break;
742 for (vector< pair<int, string> >::iterator x = ids.begin(); x != ids.end(); ++x) {
744 if (id == 0) continue;
745 /* recurse vstfx_get_info() */
749 #ifdef WINDOWS_VST_SUPPORT
750 case ARDOUR::Windows_VST: ok = vstfx_instantiate_and_get_info_fst(dllpath, infos, id); break;
753 case ARDOUR::LXVST: ok = vstfx_instantiate_and_get_info_lx(dllpath, infos, id); break;
758 // One shell (some?, all?) does not report the actual plugin name
759 // even after the shelled plugin has been instantiated.
760 // Replace the name of the shell with the real name.
761 info = infos->back();
764 if ((*x).second.length() == 0) {
765 info->name = strdup("Unknown");
768 info->name = strdup ((*x).second.c_str());
774 #ifdef WINDOWS_VST_SUPPORT
775 case ARDOUR::Windows_VST: fst_close(vstfx); break;
778 case ARDOUR::LXVST: vstfx_close (vstfx); break;
780 default: assert(0); break;
788 /* *** TOP-LEVEL PLUGIN INSTANTIATION FUNCTIONS *** */
792 vstfx_instantiate_and_get_info_lx (
793 const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
797 if (!(h = vstfx_load(dllpath))) {
798 PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": load failed." << endmsg;
802 vstfx_current_loading_id = uniqueID;
804 if (!(vstfx = vstfx_instantiate(h, simple_master_callback, 0))) {
806 PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": instantiation failed." << endmsg;
810 vstfx_current_loading_id = 0;
812 vstfx_info_from_plugin(dllpath, vstfx, infos, ARDOUR::LXVST);
819 #ifdef WINDOWS_VST_SUPPORT
821 vstfx_instantiate_and_get_info_fst (
822 const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
826 if(!(h = fst_load(dllpath))) {
827 PBD::warning << "Cannot get Windows VST information from " << dllpath << ": load failed." << endmsg;
831 vstfx_current_loading_id = uniqueID;
833 if(!(vstfx = fst_instantiate(h, simple_master_callback, 0))) {
835 vstfx_current_loading_id = 0;
836 PBD::warning << "Cannot get Windows VST information from " << dllpath << ": instantiation failed." << endmsg;
839 vstfx_current_loading_id = 0;
841 vstfx_info_from_plugin(dllpath, vstfx, infos, ARDOUR::Windows_VST);
849 /* *** ERROR LOGGING *** */
850 #ifndef VST_SCANNER_APP
852 static FILE * _errorlog_fd = 0;
853 static char * _errorlog_dll = 0;
855 static void parse_scanner_output (std::string msg, size_t /*len*/)
857 if (!_errorlog_fd && !_errorlog_dll) {
858 PBD::error << "VST scanner: " << msg;
863 if (!(_errorlog_fd = fopen(vstfx_errorfile_path(_errorlog_dll, 0).c_str(), "w"))) {
864 if (!(_errorlog_fd = fopen(vstfx_errorfile_path(_errorlog_dll, 1).c_str(), "w"))) {
865 PBD::error << "Cannot create plugin error-log for plugin " << _errorlog_dll;
867 _errorlog_dll = NULL;
873 fprintf (_errorlog_fd, "%s\n", msg.c_str());
875 PBD::error << "VST scanner: " << msg;
880 set_error_log (const char* dllpath) {
881 assert(!_errorlog_fd);
882 assert(!_errorlog_dll);
883 _errorlog_dll = strdup(dllpath);
889 fclose(_errorlog_fd);
899 /* *** THE MAIN FUNCTION THAT USES ALL OF THE ABOVE :) *** */
901 static vector<VSTInfo *> *
902 vstfx_get_info (const char* dllpath, enum ARDOUR::PluginType type, enum VSTScanMode mode)
905 vector<VSTInfo*> *infos = new vector<VSTInfo*>;
907 if (vstfx_check_blacklist(dllpath)) {
911 if (vstfx_get_info_from_file(dllpath, infos)) {
915 #ifndef VST_SCANNER_APP
916 std::string scanner_bin_path = ARDOUR::PluginManager::scanner_bin_path;
918 if (mode == VST_SCAN_CACHE_ONLY) {
919 /* never scan explicitly, use cache only */
922 else if (mode == VST_SCAN_USE_APP && scanner_bin_path != "") {
923 /* use external scanner app */
925 char **argp= (char**) calloc(3,sizeof(char*));
926 argp[0] = strdup(scanner_bin_path.c_str());
927 argp[1] = strdup(dllpath);
930 set_error_log(dllpath);
931 ARDOUR::SystemExec scanner (scanner_bin_path, argp);
932 PBD::ScopedConnectionList cons;
933 scanner.ReadStdout.connect_same_thread (cons, boost::bind (&parse_scanner_output, _1 ,_2));
934 if (scanner.start (2 /* send stderr&stdout via signal */)) {
935 PBD::error << "Cannot launch VST scanner app '" << scanner_bin_path << "': "<< strerror(errno) << endmsg;
939 int timeout = PLUGIN_SCAN_TIMEOUT;
940 bool no_timeout = (timeout <= 0);
941 ARDOUR::PluginScanTimeout(timeout);
942 while (scanner.is_running() && (no_timeout || timeout > 0)) {
943 if (!no_timeout && !ARDOUR::PluginManager::instance().no_timeout()) {
944 if (timeout%5 == 0) {
945 ARDOUR::PluginScanTimeout(timeout);
950 Glib::usleep (100000);
952 if (ARDOUR::PluginManager::instance().cancelled()) {
953 // remove info file (might be incomplete)
954 vstfx_remove_infofile(dllpath);
955 // remove temporary blacklist file (scan incomplete)
956 vstfx_un_blacklist(dllpath);
965 /* re-read index (generated by external scanner) */
966 vstfx_clear_info_list(infos);
967 if (!vstfx_check_blacklist(dllpath)) {
968 vstfx_get_info_from_file(dllpath, infos);
972 /* else .. instantiate and check in in ardour process itself */
974 (void) mode; // unused parameter
978 /* blacklist in case instantiation fails */
979 vstfx_blacklist(dllpath);
982 #ifdef WINDOWS_VST_SUPPORT
983 case ARDOUR::Windows_VST: ok = vstfx_instantiate_and_get_info_fst(dllpath, infos, 0); break;
986 case ARDOUR::LXVST: ok = vstfx_instantiate_and_get_info_lx(dllpath, infos, 0); break;
995 /* remove from blacklist */
996 vstfx_un_blacklist(dllpath);
998 /* crate cache/whitelist */
999 infofile = vstfx_infofile_for_write (dllpath);
1001 PBD::warning << "Cannot cache VST information for " << dllpath << ": cannot create new FST info file." << endmsg;
1004 vstfx_write_info_file (infofile, infos);
1012 /* *** public API *** */
1015 vstfx_free_info_list (vector<VSTInfo *> *infos)
1017 for (vector<VSTInfo *>::iterator i = infos->begin(); i != infos->end(); ++i) {
1018 vstfx_free_info(*i);
1024 get_personal_vst_blacklist_dir() {
1025 string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_blacklist");
1026 /* if the directory doesn't exist, try to create it */
1027 if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
1028 if (g_mkdir (dir.c_str (), 0700)) {
1029 PBD::error << "Cannot create VST blacklist folder '" << dir << "'" << endmsg;
1037 get_personal_vst_info_cache_dir() {
1038 string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_info");
1039 /* if the directory doesn't exist, try to create it */
1040 if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
1041 if (g_mkdir (dir.c_str (), 0700)) {
1042 PBD::error << "Cannot create VST info folder '" << dir << "'" << endmsg;
1049 #ifdef LXVST_SUPPORT
1051 vstfx_get_info_lx (char* dllpath, enum VSTScanMode mode)
1053 return vstfx_get_info(dllpath, ARDOUR::LXVST, mode);
1057 #ifdef WINDOWS_VST_SUPPORT
1059 vstfx_get_info_fst (char* dllpath, enum VSTScanMode mode)
1061 return vstfx_get_info(dllpath, ARDOUR::Windows_VST, mode);
1065 #ifndef VST_SCANNER_APP