Share VSTHandle and VSTInfo between windows/linux VSTs.

git-svn-id: svn://localhost/ardour2/branches/3.0@10758 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-11-22 01:28:34 +00:00
parent d98b2b6039
commit ff98e0490d
13 changed files with 144 additions and 178 deletions

View file

@ -30,9 +30,9 @@
#include "pbd/stateful.h"
#include "ardour/plugin.h"
struct _VSTFXHandle;
struct _VSTHandle;
struct _VSTFX;
typedef struct _VSTFXHandle VSTFXHandle;
typedef struct _VSTHandle VSTHandle;
typedef struct _VSTFX VSTFX;
struct _AEffect;
typedef struct _AEffect AEffect;
@ -44,7 +44,7 @@ class Session;
class LXVSTPlugin : public ARDOUR::Plugin
{
public:
LXVSTPlugin (ARDOUR::AudioEngine&, ARDOUR::Session&, VSTFXHandle* handle);
LXVSTPlugin (ARDOUR::AudioEngine&, ARDOUR::Session&, VSTHandle *);
LXVSTPlugin (const LXVSTPlugin &);
~LXVSTPlugin ();
@ -102,7 +102,7 @@ private:
bool load_plugin_preset (PresetRecord);
void add_state (XMLNode *) const;
VSTFXHandle* handle;
VSTHandle * handle;
VSTFX* _vstfx;
AEffect* _plugin;
bool been_resumed;

View file

@ -20,6 +20,8 @@
#ifndef __ardour_vst_types_h__
#define __ardour_vst_types_h__
#include "ardour/vestige/aeffectx.h"
struct _VSTKey
{
/** virtual-key code, or 0 if this _VSTFXKey is a `character' key */
@ -30,4 +32,41 @@ struct _VSTKey
typedef struct _VSTKey VSTKey;
struct _VSTInfo
{
char *name;
char *creator;
int UniqueID;
char *Category;
int numInputs;
int numOutputs;
int numParams;
int wantMidi;
int wantEvents;
int hasEditor;
int canProcessReplacing;
char** ParamNames;
char** ParamLabels;
};
typedef struct _VSTInfo VSTInfo;
typedef AEffect * (* main_entry_t) (audioMasterCallback);
struct _VSTHandle
{
void* dll;
char* name;
char* nameptr;
main_entry_t main_entry;
int plugincnt;
};
typedef struct _VSTHandle VSTHandle;
#endif

View file

@ -18,54 +18,9 @@ void vstfx_set_error_function (void (*func)(const char *));
void vstfx_error (const char *fmt, ...);
#include <ardour/vestige/aeffectx.h>
#include "ardour/vestige/aeffectx.h"
typedef struct _VSTFX VSTFX;
typedef struct _VSTFXHandle VSTFXHandle;
typedef struct _VSTFXInfo VSTFXInfo;
/*Struct to contain the info about a plugin*/
struct _VSTFXInfo
{
char *name;
char *creator;
int UniqueID;
char *Category;
int numInputs;
int numOutputs;
int numParams;
int wantMidi;
int wantEvents;
int hasEditor;
int canProcessReplacing;
/* i think we should save the parameter Info Stuff soon. */
// struct VstParameterInfo *infos;
char **ParamNames;
char **ParamLabels;
};
/*The AEffect which contains the info about a plugin instance*/
typedef AEffect * (*main_entry_t) (audioMasterCallback);
/*A handle used to identify a plugin to vstfx*/
struct _VSTFXHandle
{
void* dll;
char* name;
char* nameptr; /* ptr returned from strdup() etc. */
main_entry_t main_entry;
int plugincnt;
};
/*Structure used to describe the instance of VSTFX responsible for
a particular plugin instance. These are connected together in a
@ -84,7 +39,7 @@ struct _VSTFX
void* event_callback_thisptr;
void (*eventProc) (void* event);
VSTFXHandle* handle;
VSTHandle* handle;
int width;
int height;
@ -127,9 +82,9 @@ struct _VSTFX
extern int vstfx_launch_editor(VSTFX* vstfx);
extern int vstfx_init (void* possible_hmodule);
extern void vstfx_exit ();
extern VSTFXHandle* vstfx_load (const char*);
extern int vstfx_unload (VSTFXHandle*);
extern VSTFX* vstfx_instantiate (VSTFXHandle*, audioMasterCallback amc, void* userptr);
extern VSTHandle * vstfx_load (const char*);
extern int vstfx_unload (VSTHandle *);
extern VSTFX* vstfx_instantiate (VSTHandle *, audioMasterCallback, void *);
extern void vstfx_close (VSTFX*);
extern int vstfx_create_editor (VSTFX* vstfx);
@ -138,10 +93,10 @@ extern void vstfx_destroy_editor (VSTFX*);
extern int vstfx_get_XID (VSTFX*);
extern void vstfx_move_window_into_view (VSTFX*);
extern VSTFXInfo* vstfx_get_info (char *dllpathname);
extern void vstfx_free_info (VSTFXInfo *info);
extern VSTInfo * vstfx_get_info (char *dllpathname);
extern void vstfx_free_info (VSTInfo *);
extern void vstfx_event_loop_remove_plugin (VSTFX* fst);
extern int vstfx_call_dispatcher(VSTFX *vstfx, int opcode, int index, int val, void *ptr, float opt );
extern int vstfx_call_dispatcher (VSTFX *vstfx, int opcode, int index, int val, void *ptr, float opt);
/** Load a plugin state from a file.**/

View file

@ -30,12 +30,12 @@
#include "pbd/stateful.h"
#include "ardour/plugin.h"
struct _FSTHandle;
typedef struct _FSTHandle FSTHandle;
struct _FST;
typedef struct _FST FST;
struct _AEffect;
typedef struct _AEffect AEffect;
struct _VSTHandle;
typedef struct _VSTHandle VSTHandle;
namespace ARDOUR {
class AudioEngine;
@ -44,7 +44,7 @@ class Session;
class WindowsVSTPlugin : public ARDOUR::Plugin
{
public:
WindowsVSTPlugin (ARDOUR::AudioEngine&, ARDOUR::Session&, FSTHandle* handle);
WindowsVSTPlugin (ARDOUR::AudioEngine&, ARDOUR::Session&, VSTHandle *);
WindowsVSTPlugin (const WindowsVSTPlugin &);
~WindowsVSTPlugin ();
@ -102,7 +102,7 @@ private:
bool load_plugin_preset (PresetRecord);
void add_state (XMLNode *) const;
FSTHandle* handle;
VSTHandle* handle;
FST* _fst;
AEffect* _plugin;
bool been_resumed;

View file

@ -67,7 +67,7 @@ using namespace PBD;
using std::min;
using std::max;
LXVSTPlugin::LXVSTPlugin (AudioEngine& e, Session& session, VSTFXHandle* h)
LXVSTPlugin::LXVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h)
: Plugin (e, session)
{
handle = h;
@ -636,7 +636,7 @@ LXVSTPluginInfo::load (Session& session)
PluginPtr plugin;
if (Config->get_use_lxvst()) {
VSTFXHandle* handle;
VSTHandle* handle;
handle = vstfx_load(path.c_str());

View file

@ -587,7 +587,7 @@ PluginManager::windows_vst_discover_from_path (string path)
int
PluginManager::windows_vst_discover (string path)
{
FSTInfo* finfo;
VSTInfo* finfo;
char buf[32];
if ((finfo = fst_get_info (const_cast<char *> (path.c_str()))) == 0) {
@ -692,7 +692,7 @@ PluginManager::lxvst_discover_from_path (string path)
int
PluginManager::lxvst_discover (string path)
{
VSTFXInfo* finfo;
VSTInfo* finfo;
char buf[32];
if ((finfo = vstfx_get_info (const_cast<char *> (path.c_str()))) == 0) {

View file

@ -44,9 +44,10 @@ void (*vstfx_error_callback)(const char *desc) = &default_vstfx_error_callback;
/*Create and return a pointer to a new VSTFX handle*/
VSTFXHandle* vstfx_handle_new()
VSTHandle *
vstfx_handle_new ()
{
VSTFXHandle* vstfx = (VSTFXHandle*)calloc(1, sizeof (VSTFXHandle));
VSTHandle* vstfx = (VSTHandle *) calloc (1, sizeof (VSTHandle));
return vstfx;
}
@ -156,10 +157,11 @@ void* vstfx_load_vst_library(const char* path)
/*This loads up a plugin, given the path to its .so file and
finds its main entry point etc*/
VSTFXHandle* vstfx_load (const char *path)
VSTHandle *
vstfx_load (const char *path)
{
char* buf = NULL;
VSTFXHandle* fhandle;
VSTHandle* fhandle;
int i;
/*Create a new handle we can use to reference the plugin*/
@ -235,7 +237,8 @@ VSTFXHandle* vstfx_load (const char *path)
/*This unloads a plugin*/
int vstfx_unload (VSTFXHandle* fhandle)
int
vstfx_unload (VSTHandle* fhandle)
{
if (fhandle->plugincnt)
{
@ -267,7 +270,8 @@ int vstfx_unload (VSTFXHandle* fhandle)
/*This instantiates a plugin*/
VSTFX* vstfx_instantiate (VSTFXHandle* fhandle, audioMasterCallback amc, void* userptr)
VSTFX *
vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
{
VSTFX* vstfx = vstfx_new ();

View file

@ -42,12 +42,13 @@ static char* read_string(FILE *fp)
}
}
static VSTFXInfo* load_vstfx_info_file(FILE* fp)
static VSTInfo *
load_vstfx_info_file (FILE* fp)
{
VSTFXInfo *info;
VSTInfo *info;
int i;
if ((info = (VSTFXInfo*) malloc(sizeof(VSTFXInfo))) == 0) {
if ((info = (VSTInfo*) malloc (sizeof (VSTInfo))) == 0) {
return 0;
}
@ -85,7 +86,8 @@ static VSTFXInfo* load_vstfx_info_file(FILE* fp)
return 0;
}
static int save_vstfx_info_file(VSTFXInfo *info, FILE* fp)
static int
save_vstfx_info_file (VSTInfo *info, FILE* fp)
{
int i;
@ -271,10 +273,10 @@ static int vstfx_can_midi(VSTFX *vstfx)
return false;
}
static VSTFXInfo* vstfx_info_from_plugin(VSTFX *vstfx)
static VSTInfo *
vstfx_info_from_plugin (VSTFX *vstfx)
{
VSTFXInfo* info = (VSTFXInfo*) malloc(sizeof(VSTFXInfo));
VSTInfo* info = (VSTInfo*) malloc (sizeof (VSTInfo));
AEffect *plugin;
int i;
@ -359,15 +361,16 @@ simple_master_callback (AEffect *, int32_t opcode, int32_t, intptr_t, void *, fl
data, and if that doesn't exist, load the plugin, get its data and
then cache it for future ref*/
VSTFXInfo *vstfx_get_info(char *dllpath)
VSTInfo *
vstfx_get_info (char* dllpath)
{
FILE* infofile;
VSTFXHandle *h;
VSTHandle *h;
VSTFX *vstfx;
VSTFXInfo *info;
VSTInfo *info;
if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
VSTFXInfo *info;
VSTInfo *info;
info = load_vstfx_info_file (infofile);
fclose (infofile);
return info;
@ -402,20 +405,18 @@ VSTFXInfo *vstfx_get_info(char *dllpath)
return info;
}
void vstfx_free_info(VSTFXInfo *info )
void
vstfx_free_info (VSTInfo *info)
{
int i;
for(i=0; i < info->numParams; i++)
{
free(info->ParamNames[i]);
free(info->ParamLabels[i]);
}
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);
free (info->name);
free (info->creator);
free (info->Category);
free (info);
}

View file

@ -61,7 +61,7 @@ using namespace PBD;
using std::min;
using std::max;
WindowsVSTPlugin::WindowsVSTPlugin (AudioEngine& e, Session& session, FSTHandle* h)
WindowsVSTPlugin::WindowsVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h)
: Plugin (e, session)
{
handle = h;
@ -683,7 +683,7 @@ WindowsVSTPluginInfo::load (Session& session)
PluginPtr plugin;
if (Config->get_use_windows_vst ()) {
FSTHandle* handle;
VSTHandle* handle;
handle = fst_load(path.c_str());

View file

@ -29,50 +29,13 @@ void fst_set_error_function (void (*func)(const char *));
void fst_error (const char *fmt, ...);
typedef struct _FST FST;
typedef struct _FSTHandle FSTHandle;
typedef struct _FSTInfo FSTInfo;
struct _FSTInfo
{
char *name;
char *creator;
int UniqueID;
char *Category;
int numInputs;
int numOutputs;
int numParams;
int wantMidi;
int wantEvents;
int hasEditor;
int canProcessReplacing; // what do we need this for ?
// i think we should save the parameter Info Stuff soon.
// struct VstParameterInfo *infos;
char **ParamNames;
char **ParamLabels;
};
typedef AEffect * (*main_entry_t)(audioMasterCallback);
struct _FSTHandle
{
void* dll;
char* name;
char* nameptr; /* ptr returned from strdup() etc. */
//struct AEffect* (*main_entry)(audioMasterCallback);
main_entry_t main_entry;
int plugincnt;
};
struct _FST
{
AEffect* plugin;
void* window; /* win32 HWND */
int xid; /* X11 XWindow */
FSTHandle* handle;
VSTHandle* handle;
int width;
int height;
int wantIdle;
@ -114,10 +77,10 @@ extern "C" {
extern int fst_init (void* possible_hmodule);
extern void fst_exit ();
extern FSTHandle* fst_load (const char*);
extern int fst_unload (FSTHandle*);
extern VSTHandle* fst_load (const char*);
extern int fst_unload (VSTHandle*);
extern FST* fst_instantiate (FSTHandle*, audioMasterCallback amc, void* userptr);
extern FST* fst_instantiate (VSTHandle*, audioMasterCallback amc, void* userptr);
extern void fst_close (FST*);
extern int fst_create_editor (FST* fst);
@ -126,8 +89,8 @@ extern void fst_destroy_editor (FST*);
extern int fst_get_XID (FST*);
extern void fst_move_window_into_view (FST*);
extern FSTInfo *fst_get_info (char *dllpathname);
extern void fst_free_info (FSTInfo *info);
extern VSTInfo *fst_get_info (char *dllpathname);
extern void fst_free_info (VSTInfo *info);
extern void fst_event_loop_remove_plugin (FST* fst);
extern int fst_call_dispatcher(FST *fst, int opcode, int index, int val, void *ptr, float opt );

View file

@ -31,22 +31,23 @@ static char *read_string( FILE *fp ) {
}
}
static FSTInfo *load_fst_info_file( char *filename ) {
static VSTInfo *
load_fst_info_file (char* filename)
{
VSTInfo *info = (VSTInfo *) malloc (sizeof (VSTInfo));
FILE *fp;
int i;
if (info == NULL) {
return NULL;
}
FSTInfo *info = (FSTInfo *) malloc( sizeof( FSTInfo ) );
FILE *fp;
int i;
if( info == NULL )
return NULL;
fp = fopen( filename, "r" );
if( fp == NULL ) {
free( info );
return NULL;
}
fp = fopen( filename, "r" );
if (fp == NULL) {
free (info);
return NULL;
}
if( (info->name = read_string( fp )) == NULL ) goto error;
if( (info->creator = read_string( fp )) == NULL ) goto error;
@ -78,8 +79,9 @@ error:
return NULL;
}
static int save_fst_info_file( FSTInfo *info, char *filename ) {
static int
save_fst_info_file (VSTInfo* info, char* filename)
{
FILE *fp;
int i;
@ -162,10 +164,10 @@ fst_can_midi (FST *fst)
return FALSE;
}
static FSTInfo *
static VSTInfo *
fst_info_from_plugin (FST* fst)
{
FSTInfo* info = (FSTInfo *) malloc( sizeof( FSTInfo ) );
VSTInfo* info = (VSTInfo *) malloc (sizeof (VSTInfo));
AEffect* plugin;
int i;
char creator[65];
@ -226,21 +228,22 @@ simple_master_callback (AEffect *fx, int32_t opcode, int32_t index, intptr_t val
}
}
FSTInfo *fst_get_info( char *dllpath ) {
if( fst_info_file_is_valid( dllpath ) ) {
FSTInfo *info;
char *fstpath = fst_dllpath_to_infopath( dllpath );
info = load_fst_info_file( fstpath );
free( fstpath );
return info;
VSTInfo *
fst_get_info (char* dllpath)
{
if( fst_info_file_is_valid( dllpath ) ) {
VSTInfo *info;
char *fstpath = fst_dllpath_to_infopath( dllpath );
info = load_fst_info_file( fstpath );
free( fstpath );
return info;
} else {
FSTHandle *h;
VSTHandle *h;
FST *fst;
FSTInfo *info;
VSTInfo *info;
char *fstpath;
if( !(h = fst_load( dllpath )) ) return NULL;
@ -266,8 +269,9 @@ FSTInfo *fst_get_info( char *dllpath ) {
}
}
void fst_free_info( FSTInfo *info ) {
void
fst_free_info (VSTInfo *info)
{
int i;
for( i=0; i<info->numParams; i++ ) {

View file

@ -12,7 +12,7 @@ typedef struct _JackVST JackVST;
struct _JackVST {
jack_client_t *client;
FSTHandle* handle;
VSTHandle* handle;
FST* fst;
float **ins;
float **outs;

View file

@ -84,10 +84,10 @@ fst_new ()
return fst;
}
static FSTHandle*
static VSTHandle*
fst_handle_new ()
{
FSTHandle* fst = (FSTHandle*) calloc (1, sizeof (FSTHandle));
VSTHandle* fst = (VSTHandle*) calloc (1, sizeof (VSTHandle));
return fst;
}
@ -522,11 +522,11 @@ fst_load_vst_library(const char * path)
return dll;
}
FSTHandle*
VSTHandle *
fst_load (const char *path)
{
char* buf;
FSTHandle* fhandle;
VSTHandle* fhandle;
char* period;
fhandle = fst_handle_new ();
@ -581,7 +581,7 @@ fst_load (const char *path)
}
int
fst_unload (FSTHandle* fhandle)
fst_unload (VSTHandle* fhandle)
{
if (fhandle->plugincnt) {
return -1;
@ -602,7 +602,7 @@ fst_unload (FSTHandle* fhandle)
}
FST*
fst_instantiate (FSTHandle* fhandle, audioMasterCallback amc, void* userptr)
fst_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
{
FST* fst = fst_new ();