add latency callback to dummy backend
[ardour.git] / libs / ardour / vst_info_file.cc
index 90076815b37a75ca36585e7d3fbee7e3712ae5e1..da49d1b8eb79fd18ca30ff9f02a7cd14999e16da 100644 (file)
@@ -34,7 +34,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
-#include <libgen.h>
 
 #include <glib.h>
 #include <glib/gstdio.h>
@@ -43,8 +42,9 @@
 #include "pbd/error.h"
 
 #ifndef VST_SCANNER_APP
-#include "pbd/system_exec.h"
 #include "ardour/plugin_manager.h" // scanner_bin_path
+#include "ardour/rc_configuration.h"
+#include "ardour/system_exec.h"
 #endif
 
 #include "ardour/filesystem_paths.h"
@@ -53,7 +53,7 @@
 #include "ardour/vst_info_file.h"
 
 #define MAX_STRING_LEN 256
-#define PLUGIN_SCAN_TIMEOUT (600) // in deciseconds
+#define PLUGIN_SCAN_TIMEOUT (Config->get_vst_scan_timeout()) // in deciseconds
 
 
 /* CACHE FILE PATHS */
@@ -118,12 +118,13 @@ vstfx_infofile_path (const char* dllpath, int personal)
        return vstfx_cache_file(dllpath, personal, EXT_INFOFILE);
 }
 
+#ifndef VST_SCANNER_APP
 static string
 vstfx_errorfile_path (const char* dllpath, int personal)
 {
        return vstfx_cache_file(dllpath, personal, EXT_ERRORFILE);
 }
-
+#endif
 
 
 /* *** MEMORY MANAGEMENT *** */
@@ -609,14 +610,26 @@ vstfx_parse_vst_state (VSTState* vstfx)
          fail to implement getVendorString, and so won't stuff the
          string with any name*/
 
-       char creator[65] = "Unknown\0";
+       char creator[65] = "Unknown";
+       char name[65] = "";
 
        AEffect* plugin = vstfx->plugin;
 
-       info->name = strdup (vstfx->handle->name);
+
+       plugin->dispatcher (plugin, effGetEffectName, 0, 0, name, 0);
+
+       if (strlen(name) == 0) {
+               plugin->dispatcher (plugin, effGetProductString, 0, 0, name, 0);
+       }
+
+       if (strlen(name) == 0) {
+               info->name = strdup (vstfx->handle->name);
+       } else {
+               info->name = strdup (name);
+       }
 
        /*If the plugin doesn't bother to implement GetVendorString we will
-         have pre-stuffed the string with 'Unkown' */
+         have pre-stuffed the string with 'Unknown' */
 
        plugin->dispatcher (plugin, effGetVendorString, 0, 0, creator, 0);
 
@@ -702,7 +715,7 @@ vstfx_info_from_plugin (const char *dllpath, VSTState* vstfx, vector<VSTInfo *>
                string path = vstfx->handle->path;
 
                do {
-                       char name[65] = "Unknown\0";
+                       char name[65] = "Unknown";
                        id = plugin->dispatcher (plugin, effShellGetNextPlugin, 0, 0, name, 0);
                        ids.push_back(std::make_pair(id, name));
                } while ( id != 0 );
@@ -906,7 +919,7 @@ vstfx_get_info (const char* dllpath, enum ARDOUR::PluginType type, enum VSTScanM
                argp[2] = 0;
 
                set_error_log(dllpath);
-               PBD::SystemExec scanner (scanner_bin_path, argp);
+               ARDOUR::SystemExec scanner (scanner_bin_path, argp);
                PBD::ScopedConnectionList cons;
                scanner.ReadStdout.connect_same_thread (cons, boost::bind (&parse_scanner_output, _1 ,_2));
                if (scanner.start (2 /* send stderr&stdout via signal */)) {
@@ -915,7 +928,15 @@ vstfx_get_info (const char* dllpath, enum ARDOUR::PluginType type, enum VSTScanM
                        return infos;
                } else {
                        int timeout = PLUGIN_SCAN_TIMEOUT;
-                       while (scanner.is_running() && --timeout) {
+                       bool no_timeout = (timeout <= 0);
+                       ARDOUR::PluginScanTimeout(timeout);
+                       while (scanner.is_running() && (no_timeout || timeout > 0)) {
+                               if (!no_timeout && !ARDOUR::PluginManager::instance().no_timeout()) {
+                                       if (timeout%5 == 0) {
+                                               ARDOUR::PluginScanTimeout(timeout);
+                                       }
+                                       --timeout;
+                               }
                                ARDOUR::GUIIdle();
                                Glib::usleep (100000);