summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-02-23 05:51:58 +0100
committerRobin Gareus <robin@gareus.org>2014-02-23 05:51:58 +0100
commitbcf6c764625ab4b98e486977ef477deb4f1d64c4 (patch)
tree8a87224ccaa169e9065544e8ab0529fb0722f101 /libs/ardour
parent7f714ca0366acccd1c9e6d3cc67c5573e4ea1d43 (diff)
consolidate lxVST & winVST file-info code into libardour
first step and clennup before adding support for VST shell-plugins (collections) and external scanner app...
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/linux_vst_support.h3
-rw-r--r--libs/ardour/ardour/vst_info_file.h38
-rw-r--r--libs/ardour/plugin_manager.cc8
-rw-r--r--libs/ardour/vst_info_file.cc (renamed from libs/ardour/linux_vst_info_file.cc)207
-rw-r--r--libs/ardour/wscript6
5 files changed, 183 insertions, 79 deletions
diff --git a/libs/ardour/ardour/linux_vst_support.h b/libs/ardour/ardour/linux_vst_support.h
index cb18a0b1d4..8575e2a72a 100644
--- a/libs/ardour/ardour/linux_vst_support.h
+++ b/libs/ardour/ardour/linux_vst_support.h
@@ -53,8 +53,6 @@ LIBARDOUR_API extern int vstfx_create_editor (VSTState *);
LIBARDOUR_API extern int vstfx_run_editor (VSTState *);
LIBARDOUR_API extern void vstfx_destroy_editor (VSTState *);
-LIBARDOUR_API extern VSTInfo * vstfx_get_info (char *);
-LIBARDOUR_API extern void vstfx_free_info (VSTInfo *);
LIBARDOUR_API extern void vstfx_event_loop_remove_plugin (VSTState *);
LIBARDOUR_API extern int vstfx_call_dispatcher (VSTState *, int, int, int, void *, float);
@@ -66,5 +64,4 @@ LIBARDOUR_API extern int vstfx_load_state (VSTState* vstfx, char * filename);
LIBARDOUR_API extern bool vstfx_save_state (VSTState* vstfx, char * filename);
-
#endif /* __vstfx_h__ */
diff --git a/libs/ardour/ardour/vst_info_file.h b/libs/ardour/ardour/vst_info_file.h
new file mode 100644
index 0000000000..2da203a54c
--- /dev/null
+++ b/libs/ardour/ardour/vst_info_file.h
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2012-2014 Paul Davis
+ Author: Robin Gareus <robin@gareus.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __vst_info_file_h__
+#define __vst_info_file_h__
+
+#include "ardour/libardour_visibility.h"
+#include "ardour/vst_types.h"
+
+LIBARDOUR_API extern void vstfx_free_info (VSTInfo *);
+
+#ifdef LXVST_SUPPORT
+LIBARDOUR_API extern VSTInfo * vstfx_get_info_lx (char *);
+#endif
+
+#ifdef WINDOWS_VST_SUPPORT
+LIBARDOUR_API extern VSTInfo * vstfx_get_info_fst (char *);
+#endif
+
+#endif /* __vstfx_h__ */
+
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc
index 6d68df688f..6e9aa4fc18 100644
--- a/libs/ardour/plugin_manager.cc
+++ b/libs/ardour/plugin_manager.cc
@@ -33,12 +33,14 @@
#endif
#ifdef WINDOWS_VST_SUPPORT
+#include "ardour/vst_info_file.h"
#include "fst.h"
#include "pbd/basename.h"
#include <cstring>
#endif // WINDOWS_VST_SUPPORT
#ifdef LXVST_SUPPORT
+#include "ardour/vst_info_file.h"
#include "ardour/linux_vst_support.h"
#include "pbd/basename.h"
#include <cstring>
@@ -558,7 +560,7 @@ PluginManager::windows_vst_discover (string path)
VSTInfo* finfo;
char buf[32];
- if ((finfo = fst_get_info (const_cast<char *> (path.c_str()))) == 0) {
+ if ((finfo = vstfx_get_info_fst (const_cast<char *> (path.c_str()))) == 0) {
warning << "Cannot get Windows VST information from " << path << endmsg;
return -1;
}
@@ -592,7 +594,7 @@ PluginManager::windows_vst_discover (string path)
info->type = ARDOUR::Windows_VST;
_windows_vst_plugin_info->push_back (info);
- fst_free_info (finfo);
+ vstfx_free_info(finfo);
return 0;
}
@@ -672,7 +674,7 @@ PluginManager::lxvst_discover (string path)
DEBUG_TRACE (DEBUG::PluginManager, string_compose ("checking apparent LXVST plugin at %1\n", path));
- if ((finfo = vstfx_get_info (const_cast<char *> (path.c_str()))) == 0) {
+ if ((finfo = vstfx_get_info_lx (const_cast<char *> (path.c_str()))) == 0) {
return -1;
}
diff --git a/libs/ardour/linux_vst_info_file.cc b/libs/ardour/vst_info_file.cc
index 581bcca87f..7d5aaf3795 100644
--- a/libs/ardour/linux_vst_info_file.cc
+++ b/libs/ardour/vst_info_file.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Paul Davis
+ Copyright (C) 2012-2014 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -43,6 +43,7 @@
#include "pbd/error.h"
#include "ardour/linux_vst_support.h"
+#include "ardour/vst_info_file.h"
#define MAX_STRING_LEN 256
@@ -56,7 +57,7 @@ read_string (FILE *fp)
if (!fgets (buf, MAX_STRING_LEN, fp)) {
return 0;
}
-
+
if (strlen(buf) < MAX_STRING_LEN) {
if (strlen (buf)) {
buf[strlen(buf)-1] = 0;
@@ -87,7 +88,7 @@ static VSTInfo *
load_vstfx_info_file (FILE* fp)
{
VSTInfo *info;
-
+
if ((info = (VSTInfo*) malloc (sizeof (VSTInfo))) == 0) {
return 0;
}
@@ -114,14 +115,14 @@ load_vstfx_info_file (FILE* fp)
if ((info->ParamLabels = (char **) malloc(sizeof(char*)*info->numParams)) == 0) {
goto error;
}
-
+
for (int i = 0; i < info->numParams; ++i) {
if ((info->ParamLabels[i] = read_string(fp)) == 0) goto error;
}
-
+
return info;
-
- error:
+
+error:
free (info);
return 0;
}
@@ -131,7 +132,7 @@ save_vstfx_info_file (VSTInfo *info, FILE* fp)
{
assert (info);
assert (fp);
-
+
fprintf (fp, "%s\n", info->name);
fprintf (fp, "%s\n", info->creator);
fprintf (fp, "%d\n", info->UniqueID);
@@ -146,12 +147,12 @@ save_vstfx_info_file (VSTInfo *info, FILE* fp)
for (int i = 0; i < info->numParams; i++) {
fprintf (fp, "%s\n", info->ParamNames[i]);
}
-
+
for (int i = 0; i < info->numParams; i++) {
fprintf (fp, "%s\n", info->ParamLabels[i]);
}
-
- return 0;
+
+ return 0;
}
static string
@@ -167,7 +168,7 @@ vstfx_infofile_path (char* dllpath, int personal)
return 0;
}
}
-
+
} else {
dir = Glib::path_get_dirname (std::string(dllpath));
}
@@ -180,7 +181,7 @@ vstfx_infofile_path (char* dllpath, int personal)
static char *
vstfx_infofile_stat (char *dllpath, struct stat* statbuf, int personal)
{
- if (strstr (dllpath, ".so" ) == 0) {
+ if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
return 0;
}
@@ -194,7 +195,7 @@ vstfx_infofile_stat (char *dllpath, struct stat* statbuf, int personal)
struct stat dllstat;
-
+
if (stat (dllpath, &dllstat) == 0) {
if (stat (path.c_str(), statbuf) == 0) {
if (dllstat.st_mtime <= statbuf->st_mtime) {
@@ -202,7 +203,7 @@ vstfx_infofile_stat (char *dllpath, struct stat* statbuf, int personal)
return strdup (path.c_str ());
}
}
- }
+ }
}
return 0;
@@ -215,7 +216,7 @@ vstfx_infofile_for_read (char* dllpath)
struct stat own_statbuf;
struct stat sys_statbuf;
FILE *rv = NULL;
-
+
char* own_info = vstfx_infofile_stat (dllpath, &own_statbuf, 1);
char* sys_info = vstfx_infofile_stat (dllpath, &sys_statbuf, 0);
@@ -228,6 +229,8 @@ vstfx_infofile_for_read (char* dllpath)
} else {
rv = g_fopen (own_info, "rb");
}
+ } else if (sys_info) {
+ rv = g_fopen (sys_info, "rb");
}
free(own_info);
free(sys_info);
@@ -238,7 +241,7 @@ vstfx_infofile_for_read (char* dllpath)
static FILE *
vstfx_infofile_create (char* dllpath, int personal)
{
- if (strstr (dllpath, ".so" ) == 0) {
+ if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
return 0;
}
@@ -254,7 +257,7 @@ vstfx_infofile_for_write (char* dllpath)
if ((f = vstfx_infofile_create (dllpath, 0)) == 0) {
f = vstfx_infofile_create (dllpath, 1);
}
-
+
return f;
}
@@ -262,17 +265,17 @@ static
int vstfx_can_midi (VSTState* vstfx)
{
AEffect* plugin = vstfx->plugin;
-
+
int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f);
if (vst_version >= 2) {
/* should we send it VST events (i.e. MIDI) */
-
+
if ((plugin->flags & effFlagsIsSynth) || (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "receiveVstEvents", 0.0f) > 0)) {
return -1;
}
}
-
+
return false;
}
@@ -280,43 +283,43 @@ static VSTInfo *
vstfx_info_from_plugin (VSTState* vstfx)
{
assert (vstfx);
-
+
VSTInfo* info = (VSTInfo*) malloc (sizeof (VSTInfo));
if (!info) {
return 0;
}
-
+
/*We need to init the creator because some plugins
fail to implement getVendorString, and so won't stuff the
string with any name*/
-
+
char creator[65] = "Unknown\0";
-
+
AEffect* plugin = vstfx->plugin;
-
- info->name = strdup (vstfx->handle->name);
-
+
+ info->name = strdup (vstfx->handle->name);
+
/*If the plugin doesn't bother to implement GetVendorString we will
have pre-stuffed the string with 'Unkown' */
-
+
plugin->dispatcher (plugin, effGetVendorString, 0, 0, creator, 0);
-
+
/*Some plugins DO implement GetVendorString, but DON'T put a name in it
so if its just a zero length string we replace it with 'Unknown' */
-
+
if (strlen(creator) == 0) {
info->creator = strdup ("Unknown");
} else {
info->creator = strdup (creator);
}
-
+
info->UniqueID = plugin->uniqueID;
-
+
info->Category = strdup("None"); /* XXX */
info->numInputs = plugin->numInputs;
info->numOutputs = plugin->numOutputs;
info->numParams = plugin->numParams;
- info->wantMidi = vstfx_can_midi(vstfx);
+ info->wantMidi = vstfx_can_midi(vstfx);
info->hasEditor = plugin->flags & effFlagsHasEditor ? true : false;
info->canProcessReplacing = plugin->flags & effFlagsCanReplacing ? true : false;
info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams);
@@ -325,15 +328,15 @@ vstfx_info_from_plugin (VSTState* vstfx)
for (int i = 0; i < info->numParams; ++i) {
char name[64];
char label[64];
-
+
/* Not all plugins give parameters labels as well as names */
-
+
strcpy (name, "No Name");
strcpy (label, "No Label");
-
+
plugin->dispatcher (plugin, effGetParamName, i, 0, name, 0);
info->ParamNames[i] = strdup(name);
-
+
//NOTE: 'effGetParamLabel' is no longer defined in vestige headers
//plugin->dispatcher (plugin, effGetParamLabel, i, 0, label, 0);
info->ParamLabels[i] = strdup(label);
@@ -355,73 +358,135 @@ simple_master_callback (AEffect *, int32_t opcode, int32_t, intptr_t, void *, fl
}
}
+static VSTInfo *
+vstfx_get_info_from_file(char* dllpath, bool &found)
+{
+ FILE* infofile;
+ VSTInfo *info = 0;
+ found = false;
+ if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
+ found = true;
+ info = load_vstfx_info_file (infofile);
+ fclose (infofile);
+ if (info == 0) {
+ PBD::warning << "Cannot get LinuxVST information form " << dllpath << ": info file load failed." << endmsg;
+ }
+ }
+ return info;
+}
+
+void
+vstfx_free_info (VSTInfo *info)
+{
+ for (int i = 0; i < info->numParams; i++) {
+ free (info->ParamNames[i]);
+ free (info->ParamLabels[i]);
+ }
+
+ free (info->name);
+ free (info->creator);
+ free (info->Category);
+ free (info->ParamNames);
+ free (info->ParamLabels);
+ free (info);
+}
+
+#ifdef LXVST_SUPPORT
/** Try to get plugin info - first by looking for a .fsi cache of the
data, and if that doesn't exist, load the plugin, get its data and
then cache it for future ref
*/
VSTInfo *
-vstfx_get_info (char* dllpath)
+vstfx_get_info_lx (char* dllpath)
{
FILE* infofile;
VSTHandle* h;
VSTState* vstfx;
- if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
- VSTInfo *info;
- info = load_vstfx_info_file (infofile);
- fclose (infofile);
- if (info == 0) {
- PBD::warning << "Cannot get LinuxVST information form " << dllpath << ": info file load failed." << endmsg;
- }
+ bool used_cache;
+ VSTInfo* info = vstfx_get_info_from_file(dllpath, used_cache);
+ if (used_cache) {
+ PBD::info << "using cache for LinuxVST plugin '" << dllpath << "'" << endmsg;
return info;
- }
-
+ }
+
if (!(h = vstfx_load(dllpath))) {
PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": load failed." << endmsg;
return 0;
}
-
+
if (!(vstfx = vstfx_instantiate(h, simple_master_callback, 0))) {
- vstfx_unload(h);
+ vstfx_unload(h);
PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": instantiation failed." << endmsg;
- return 0;
+ return 0;
}
-
+
infofile = vstfx_infofile_for_write (dllpath);
-
+
if (!infofile) {
vstfx_close(vstfx);
vstfx_unload(h);
PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": cannot create new FST info file." << endmsg;
return 0;
}
-
- VSTInfo* info = vstfx_info_from_plugin (vstfx);
-
+
+ info = vstfx_info_from_plugin (vstfx);
+
save_vstfx_info_file (info, infofile);
fclose (infofile);
-
+
vstfx_close (vstfx);
vstfx_unload (h);
-
+
return info;
}
+#endif
-void
-vstfx_free_info (VSTInfo *info)
+#ifdef WINDOWS_VST_SUPPORT
+#include <fst.h>
+
+VSTInfo *
+vstfx_get_info_fst (char* dllpath)
{
- for (int i = 0; i < info->numParams; i++) {
- free (info->ParamNames[i]);
- free (info->ParamLabels[i]);
+ FILE* infofile;
+ VSTHandle* h;
+ VSTState* vstfx;
+
+ bool used_cache;
+ VSTInfo* info = vstfx_get_info_from_file(dllpath, used_cache);
+ if (used_cache) {
+ PBD::info << "using cache for VST plugin '" << dllpath << "'" << endmsg;
+ return info;
+ }
+
+ if(!(h = fst_load(dllpath))) {
+ PBD::warning << "Cannot get VST information from " << dllpath << ": load failed." << endmsg;
+ return 0;
}
-
- free (info->name);
- free (info->creator);
- free (info->Category);
- free (info->ParamNames);
- free (info->ParamLabels);
- free (info);
-}
+ if(!(vstfx = fst_instantiate(h, simple_master_callback, 0))) {
+ fst_unload(&h);
+ PBD::warning << "Cannot get VST information from " << dllpath << ": instantiation failed." << endmsg;
+ return 0;
+ }
+
+ infofile = vstfx_infofile_for_write (dllpath);
+
+ if (!infofile) {
+ fst_close(vstfx);
+ //fst_unload(&h); // XXX -> fst_close()
+ PBD::warning << "Cannot get VST information from " << dllpath << ": cannot create new FST info file." << endmsg;
+ return 0;
+ }
+
+ info = vstfx_info_from_plugin(vstfx);
+ save_vstfx_info_file (info, infofile);
+ fclose (infofile);
+ fst_close(vstfx);
+ //fst_unload(&h); // XXX -> fst_close()
+
+ return info;
+}
+#endif
diff --git a/libs/ardour/wscript b/libs/ardour/wscript
index 56c864ca50..24a4590d08 100644
--- a/libs/ardour/wscript
+++ b/libs/ardour/wscript
@@ -375,13 +375,15 @@ def build(bld):
obj.source += [ 'windows_vst_plugin.cc']
obj.includes += [ '../fst' ]
obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
+ if bld.env['build_target'] == 'mingw':
+ obj.source += [ '../fst/vstwin.c']
if bld.is_defined('LXVST_SUPPORT'):
- obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc', 'linux_vst_info_file.cc' ]
+ obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc' ]
obj.defines += [ 'LXVST_SUPPORT' ]
if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT'):
- obj.source += [ 'session_vst.cc', 'vst_plugin.cc' ]
+ obj.source += [ 'session_vst.cc', 'vst_plugin.cc', 'vst_info_file.cc' ]
if bld.is_defined('HAVE_COREAUDIO'):
obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]