From ff98e0490d240e1010da92460601b0e7fb5ee848 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 22 Nov 2011 01:28:34 +0000 Subject: Share VSTHandle and VSTInfo between windows/linux VSTs. git-svn-id: svn://localhost/ardour2/branches/3.0@10758 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/fst/fst.h | 49 +++++------------------------------- libs/fst/fstinfofile.c | 68 ++++++++++++++++++++++++++------------------------ libs/fst/jackvst.h | 2 +- libs/fst/vstwin.c | 12 ++++----- 4 files changed, 49 insertions(+), 82 deletions(-) (limited to 'libs/fst') diff --git a/libs/fst/fst.h b/libs/fst/fst.h index f4482ec377..545bfaf165 100644 --- a/libs/fst/fst.h +++ b/libs/fst/fst.h @@ -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 ); diff --git a/libs/fst/fstinfofile.c b/libs/fst/fstinfofile.c index d848d3ae34..dec6db760a 100644 --- a/libs/fst/fstinfofile.c +++ b/libs/fst/fstinfofile.c @@ -31,22 +31,23 @@ static char *read_string( FILE *fp ) { } } -static FSTInfo *load_fst_info_file( char *filename ) { - - FSTInfo *info = (FSTInfo *) malloc( sizeof( FSTInfo ) ); - FILE *fp; - int i; - - - if( info == NULL ) - return NULL; +static VSTInfo * +load_fst_info_file (char* filename) +{ + VSTInfo *info = (VSTInfo *) malloc (sizeof (VSTInfo)); + 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; inumParams; i++ ) { diff --git a/libs/fst/jackvst.h b/libs/fst/jackvst.h index 31e34f55b9..28c6f05852 100644 --- a/libs/fst/jackvst.h +++ b/libs/fst/jackvst.h @@ -12,7 +12,7 @@ typedef struct _JackVST JackVST; struct _JackVST { jack_client_t *client; - FSTHandle* handle; + VSTHandle* handle; FST* fst; float **ins; float **outs; diff --git a/libs/fst/vstwin.c b/libs/fst/vstwin.c index cdc9e3af07..91a25e5852 100644 --- a/libs/fst/vstwin.c +++ b/libs/fst/vstwin.c @@ -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 (); -- cgit v1.2.3