mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 20:26:30 +01:00
Share main VSTFX / FST struct between windows / linux VSTs.
git-svn-id: svn://localhost/ardour2/branches/3.0@10762 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
51e43ae5a7
commit
16aece1d47
13 changed files with 250 additions and 301 deletions
|
|
@ -226,7 +226,7 @@ LXVSTPluginUI::forward_key_event (GdkEventKey* ev)
|
||||||
void
|
void
|
||||||
LXVSTPluginUI::create_preset_store ()
|
LXVSTPluginUI::create_preset_store ()
|
||||||
{
|
{
|
||||||
VSTFX* vstfx = lxvst->vstfx();
|
VSTState* vstfx = lxvst->vstfx();
|
||||||
|
|
||||||
int vst_version = vstfx->plugin->dispatcher (vstfx->plugin, effGetVstVersion, 0, 0, NULL, 0.0f);
|
int vst_version = vstfx->plugin->dispatcher (vstfx->plugin, effGetVstVersion, 0, 0, NULL, 0.0f);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ struct ERect{
|
||||||
|
|
||||||
static pthread_mutex_t plugin_mutex;
|
static pthread_mutex_t plugin_mutex;
|
||||||
|
|
||||||
static VSTFX* vstfx_first = NULL;
|
static VSTState * vstfx_first = NULL;
|
||||||
|
|
||||||
const char magic[] = "VSTFX Plugin State v002";
|
const char magic[] = "VSTFX Plugin State v002";
|
||||||
|
|
||||||
|
|
@ -160,7 +160,8 @@ long getXWindowProperty(Window window, Atom atom)
|
||||||
/*The event handler - called from within the main GUI thread to
|
/*The event handler - called from within the main GUI thread to
|
||||||
dispatch events to any VST UIs which have callbacks stuck to them*/
|
dispatch events to any VST UIs which have callbacks stuck to them*/
|
||||||
|
|
||||||
static void dispatch_x_events(XEvent* event, VSTFX* vstfx)
|
static void
|
||||||
|
dispatch_x_events (XEvent* event, VSTState* vstfx)
|
||||||
{
|
{
|
||||||
/*Handle some of the Events we might be interested in*/
|
/*Handle some of the Events we might be interested in*/
|
||||||
|
|
||||||
|
|
@ -182,10 +183,8 @@ static void dispatch_x_events(XEvent* event, VSTFX* vstfx)
|
||||||
/*if the size has changed, we flag this so that in lxvst_pluginui.cc we can make the
|
/*if the size has changed, we flag this so that in lxvst_pluginui.cc we can make the
|
||||||
change to the GTK parent window in ardour, from its UI thread*/
|
change to the GTK parent window in ardour, from its UI thread*/
|
||||||
|
|
||||||
if(window == (Window)(vstfx->window))
|
if (window == (Window) (vstfx->linux_window)) {
|
||||||
{
|
if (width != vstfx->width || height!=vstfx->height) {
|
||||||
if((width!=vstfx->width) || (height!=vstfx->height))
|
|
||||||
{
|
|
||||||
vstfx->width = width;
|
vstfx->width = width;
|
||||||
vstfx->height = height;
|
vstfx->height = height;
|
||||||
vstfx->want_resize = 1;
|
vstfx->want_resize = 1;
|
||||||
|
|
@ -194,8 +193,9 @@ static void dispatch_x_events(XEvent* event, VSTFX* vstfx)
|
||||||
position at the same time. We need to re-position the window at the origin of
|
position at the same time. We need to re-position the window at the origin of
|
||||||
the parent window*/
|
the parent window*/
|
||||||
|
|
||||||
if(vstfx->plugin_ui_window)
|
if (vstfx->linux_plugin_ui_window) {
|
||||||
XMoveWindow(LXVST_XDisplay, vstfx->plugin_ui_window, 0, 0);
|
XMoveWindow (LXVST_XDisplay, vstfx->linux_plugin_ui_window, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,18 +220,19 @@ static void dispatch_x_events(XEvent* event, VSTFX* vstfx)
|
||||||
/* present time */
|
/* present time */
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
|
|
||||||
if(ParentWindow == (Window)(vstfx->window))
|
if (ParentWindow == (Window) (vstfx->linux_window)) {
|
||||||
{
|
|
||||||
Window PluginUIWindowID = event->xreparent.window;
|
Window PluginUIWindowID = event->xreparent.window;
|
||||||
|
|
||||||
vstfx->plugin_ui_window = PluginUIWindowID;
|
vstfx->linux_plugin_ui_window = PluginUIWindowID;
|
||||||
#ifdef LXVST_32BIT
|
#ifdef LXVST_32BIT
|
||||||
int result = getXWindowProperty(PluginUIWindowID, XInternAtom(LXVST_XDisplay, "_XEventProc", false));
|
int result = getXWindowProperty(PluginUIWindowID, XInternAtom(LXVST_XDisplay, "_XEventProc", false));
|
||||||
|
|
||||||
if(result == 0)
|
if (result == 0) {
|
||||||
vstfx->eventProc = NULL;
|
vstfx->eventProc = NULL;
|
||||||
else
|
} else {
|
||||||
vstfx->eventProc = (void (*) (void* event))result;
|
vstfx->eventProc = (void (*) (void* event))result;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef LXVST_64BIT
|
#ifdef LXVST_64BIT
|
||||||
long result = getXWindowProperty(PluginUIWindowID, XInternAtom(LXVST_XDisplay, "_XEventProc", false));
|
long result = getXWindowProperty(PluginUIWindowID, XInternAtom(LXVST_XDisplay, "_XEventProc", false));
|
||||||
|
|
@ -254,15 +255,13 @@ static void dispatch_x_events(XEvent* event, VSTFX* vstfx)
|
||||||
that the plugin parent window is now valid and can be passed
|
that the plugin parent window is now valid and can be passed
|
||||||
to effEditOpen when the editor is launched*/
|
to effEditOpen when the editor is launched*/
|
||||||
|
|
||||||
if(window == (Window)(vstfx->window))
|
if (window == (Window) (vstfx->linux_window)) {
|
||||||
{
|
|
||||||
char* message = XGetAtomName(LXVST_XDisplay, message_type);
|
char* message = XGetAtomName(LXVST_XDisplay, message_type);
|
||||||
|
|
||||||
if(strcmp(message,"LaunchEditor") == 0)
|
if (strcmp(message,"LaunchEditor") == 0) {
|
||||||
{
|
if (event->xclient.data.l[0] == 0x0FEEDBAC) {
|
||||||
|
vstfx_launch_editor (vstfx);
|
||||||
if(event->xclient.data.l[0] == 0x0FEEDBAC)
|
}
|
||||||
vstfx_launch_editor(vstfx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(message);
|
XFree(message);
|
||||||
|
|
@ -283,8 +282,9 @@ static void dispatch_x_events(XEvent* event, VSTFX* vstfx)
|
||||||
UI window after they create it. If that is the case, we need to call it
|
UI window after they create it. If that is the case, we need to call it
|
||||||
here, passing the XEvent into it*/
|
here, passing the XEvent into it*/
|
||||||
|
|
||||||
if(vstfx->eventProc == NULL)
|
if (vstfx->eventProc == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vstfx->eventProc((void*)event);
|
vstfx->eventProc((void*)event);
|
||||||
}
|
}
|
||||||
|
|
@ -295,8 +295,7 @@ windows, that is if they don't manage their own UIs **/
|
||||||
|
|
||||||
void* gui_event_loop (void* ptr)
|
void* gui_event_loop (void* ptr)
|
||||||
{
|
{
|
||||||
|
VSTState* vstfx;
|
||||||
VSTFX* vstfx;
|
|
||||||
int LXVST_sched_event_timer = 0;
|
int LXVST_sched_event_timer = 0;
|
||||||
int LXVST_sched_timer_interval = 50; //ms
|
int LXVST_sched_timer_interval = 50; //ms
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|
@ -361,14 +360,13 @@ again:
|
||||||
|
|
||||||
/*Window scheduled for destruction*/
|
/*Window scheduled for destruction*/
|
||||||
|
|
||||||
if (vstfx->destroy)
|
if (vstfx->destroy) {
|
||||||
{
|
if (vstfx->linux_window) {
|
||||||
if (vstfx->window)
|
vstfx->plugin->dispatcher (vstfx->plugin, effEditClose, 0, 0, NULL, 0.0);
|
||||||
{
|
|
||||||
vstfx->plugin->dispatcher( vstfx->plugin, effEditClose, 0, 0, NULL, 0.0 );
|
|
||||||
|
|
||||||
XDestroyWindow (LXVST_XDisplay, vstfx->window);
|
XDestroyWindow (LXVST_XDisplay, vstfx->linux_window);
|
||||||
vstfx->window = 0; //FIXME - probably safe to assume we never have an XID of 0 but not explicitly true
|
/* FIXME - probably safe to assume we never have an XID of 0 but not explicitly true */
|
||||||
|
vstfx->linux_window = 0;
|
||||||
vstfx->destroy = FALSE;
|
vstfx->destroy = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,18 +380,15 @@ again:
|
||||||
|
|
||||||
/*Window does not yet exist - scheduled for creation*/
|
/*Window does not yet exist - scheduled for creation*/
|
||||||
|
|
||||||
if (vstfx->window == 0) //FIXME - probably safe to assume 0 is not a valid XID but not explicitly true
|
/* FIXME - probably safe to assume 0 is not a valid XID but not explicitly true */
|
||||||
{
|
if (vstfx->linux_window == 0) {
|
||||||
if (vstfx_create_editor (vstfx))
|
if (vstfx_create_editor (vstfx)) {
|
||||||
{
|
|
||||||
vstfx_error ("** ERROR ** VSTFX : Cannot create editor for plugin %s", vstfx->handle->name);
|
vstfx_error ("** ERROR ** VSTFX : Cannot create editor for plugin %s", vstfx->handle->name);
|
||||||
vstfx_event_loop_remove_plugin (vstfx);
|
vstfx_event_loop_remove_plugin (vstfx);
|
||||||
pthread_cond_signal (&vstfx->window_status_change);
|
pthread_cond_signal (&vstfx->window_status_change);
|
||||||
pthread_mutex_unlock (&vstfx->lock);
|
pthread_mutex_unlock (&vstfx->lock);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* condition/unlock: it was signalled & unlocked in fst_create_editor() */
|
/* condition/unlock: it was signalled & unlocked in fst_create_editor() */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -527,27 +522,23 @@ void vstfx_exit()
|
||||||
|
|
||||||
/*Adds a new plugin (VSTFX) instance to the linked list*/
|
/*Adds a new plugin (VSTFX) instance to the linked list*/
|
||||||
|
|
||||||
int vstfx_run_editor (VSTFX* vstfx)
|
int vstfx_run_editor (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&plugin_mutex);
|
pthread_mutex_lock (&plugin_mutex);
|
||||||
|
|
||||||
/*Add the new VSTFX instance to the linked list*/
|
/* Add the new VSTFX instance to the linked list */
|
||||||
|
|
||||||
if (vstfx_first == NULL)
|
if (vstfx_first == NULL) {
|
||||||
{
|
|
||||||
vstfx_first = vstfx;
|
vstfx_first = vstfx;
|
||||||
}
|
} else {
|
||||||
else
|
VSTState* p = vstfx_first;
|
||||||
{
|
|
||||||
VSTFX* p = vstfx_first;
|
|
||||||
|
|
||||||
while (p->next)
|
while (p->next) {
|
||||||
{
|
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
p->next = vstfx;
|
p->next = vstfx;
|
||||||
|
|
||||||
/*Mark the new end of the list*/
|
/* Mark the new end of the list */
|
||||||
|
|
||||||
vstfx->next = NULL;
|
vstfx->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -558,15 +549,13 @@ int vstfx_run_editor (VSTFX* vstfx)
|
||||||
|
|
||||||
pthread_mutex_lock (&vstfx->lock);
|
pthread_mutex_lock (&vstfx->lock);
|
||||||
|
|
||||||
if (!vstfx->window)
|
if (!vstfx->linux_window) {
|
||||||
{
|
|
||||||
pthread_cond_wait (&vstfx->window_status_change, &vstfx->lock);
|
pthread_cond_wait (&vstfx->window_status_change, &vstfx->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock (&vstfx->lock);
|
pthread_mutex_unlock (&vstfx->lock);
|
||||||
|
|
||||||
if (!vstfx->window)
|
if (!vstfx->linux_window) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -577,7 +566,7 @@ int vstfx_run_editor (VSTFX* vstfx)
|
||||||
/*Creates an editor for the plugin - normally called from within the gui event loop
|
/*Creates an editor for the plugin - normally called from within the gui event loop
|
||||||
after run_editor has added the plugin (editor) to the linked list*/
|
after run_editor has added the plugin (editor) to the linked list*/
|
||||||
|
|
||||||
int vstfx_create_editor (VSTFX* vstfx)
|
int vstfx_create_editor (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
Window parent_window;
|
Window parent_window;
|
||||||
|
|
||||||
|
|
@ -614,7 +603,7 @@ int vstfx_create_editor (VSTFX* vstfx)
|
||||||
parent_window,
|
parent_window,
|
||||||
SubstructureNotifyMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask);
|
SubstructureNotifyMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask);
|
||||||
|
|
||||||
vstfx->window = parent_window;
|
vstfx->linux_window = parent_window;
|
||||||
|
|
||||||
vstfx->xid = parent_window; //vstfx->xid will be referenced to connect to GTK UI in ardour later
|
vstfx->xid = parent_window; //vstfx->xid will be referenced to connect to GTK UI in ardour later
|
||||||
|
|
||||||
|
|
@ -654,7 +643,8 @@ int vstfx_create_editor (VSTFX* vstfx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vstfx_launch_editor(VSTFX* vstfx)
|
int
|
||||||
|
vstfx_launch_editor (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
/*This is the second stage of launching the editor (see vstfx_create editor)
|
/*This is the second stage of launching the editor (see vstfx_create editor)
|
||||||
we get called here in response to receiving the ClientMessage on our Window,
|
we get called here in response to receiving the ClientMessage on our Window,
|
||||||
|
|
@ -672,7 +662,7 @@ int vstfx_launch_editor(VSTFX* vstfx)
|
||||||
int x_size = 1;
|
int x_size = 1;
|
||||||
int y_size = 1;
|
int y_size = 1;
|
||||||
|
|
||||||
parent_window = vstfx->window;
|
parent_window = vstfx->linux_window;
|
||||||
|
|
||||||
/*Open the editor - Bah! we have to pass the int windowID as a void pointer - yuck
|
/*Open the editor - Bah! we have to pass the int windowID as a void pointer - yuck
|
||||||
it gets cast back to an int as the parent window XID in the plugin - and we have to pass the
|
it gets cast back to an int as the parent window XID in the plugin - and we have to pass the
|
||||||
|
|
@ -726,93 +716,98 @@ int vstfx_launch_editor(VSTFX* vstfx)
|
||||||
|
|
||||||
/*May not be needed in the XLib version*/
|
/*May not be needed in the XLib version*/
|
||||||
|
|
||||||
void vstfx_move_window_into_view (VSTFX* vstfx)
|
void
|
||||||
|
vstfx_move_window_into_view (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
|
/* This is probably the equivalent of Mapping an XWindow
|
||||||
/*This is probably the equivalent of Mapping an XWindow
|
but we most likely don't need it because the window
|
||||||
but we most likely don't need it because the window
|
will be Mapped by XReparentWindow
|
||||||
will be Mapped by XReparentWindow*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Destroy the editor window*/
|
/** Destroy the editor window */
|
||||||
|
void
|
||||||
void vstfx_destroy_editor (VSTFX* vstfx)
|
vstfx_destroy_editor (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&vstfx->lock);
|
pthread_mutex_lock (&vstfx->lock);
|
||||||
if (vstfx->window)
|
if (vstfx->linux_window) {
|
||||||
{
|
|
||||||
vstfx->destroy = TRUE;
|
vstfx->destroy = TRUE;
|
||||||
pthread_cond_wait (&vstfx->window_status_change, &vstfx->lock);
|
pthread_cond_wait (&vstfx->window_status_change, &vstfx->lock);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock (&vstfx->lock);
|
pthread_mutex_unlock (&vstfx->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Remove a vstfx instance from the linked list parsed by the
|
/** Remove a vstfx instance from the linked list parsed by the
|
||||||
event loop*/
|
event loop
|
||||||
|
*/
|
||||||
void vstfx_event_loop_remove_plugin (VSTFX* vstfx)
|
void
|
||||||
|
vstfx_event_loop_remove_plugin (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
/*This only ever gets called from within our GUI thread
|
/* This only ever gets called from within our GUI thread
|
||||||
so we don't need to lock here - if we did there would be
|
so we don't need to lock here - if we did there would be
|
||||||
a deadlock anyway*/
|
a deadlock anyway
|
||||||
|
*/
|
||||||
|
|
||||||
VSTFX* p;
|
VSTState* p;
|
||||||
VSTFX* prev;
|
VSTState* prev;
|
||||||
|
|
||||||
for(p = vstfx_first, prev = NULL; p; prev = p, p = p->next)
|
for (p = vstfx_first, prev = NULL; p; prev = p, p = p->next) {
|
||||||
{
|
if (p == vstfx) {
|
||||||
if(p == vstfx)
|
if (prev) {
|
||||||
{
|
|
||||||
if(prev)
|
|
||||||
{
|
|
||||||
prev->next = p->next;
|
prev->next = p->next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vstfx_first == vstfx)
|
if (vstfx_first == vstfx) {
|
||||||
vstfx_first = vstfx_first->next;
|
vstfx_first = vstfx_first->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Get the XID of the plugin editor window*/
|
/*Get the XID of the plugin editor window*/
|
||||||
|
|
||||||
int vstfx_get_XID (VSTFX* vstfx)
|
int
|
||||||
|
vstfx_get_XID (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
/*Wait for the lock to become free - otherwise
|
/* Wait for the lock to become free - otherwise
|
||||||
the window might be in the process of being
|
the window might be in the process of being
|
||||||
created and we get bad Window errors when trying
|
created and we get bad Window errors when trying
|
||||||
to embed it in the GTK UI*/
|
to embed it in the GTK UI
|
||||||
|
*/
|
||||||
|
|
||||||
pthread_mutex_lock(&vstfx->lock);
|
pthread_mutex_lock(&vstfx->lock);
|
||||||
|
|
||||||
/*The Window may be scheduled for creation
|
/* The Window may be scheduled for creation
|
||||||
but not actually created by the gui_event_loop yet -
|
but not actually created by the gui_event_loop yet -
|
||||||
|
spin here until it has been activated. Possible
|
||||||
|
deadlock if the window never gets activated but
|
||||||
|
should not be called here if the window doesn't
|
||||||
|
exist or will never exist
|
||||||
|
*/
|
||||||
|
|
||||||
spin here until it has been activated. Possible
|
while (!(vstfx->been_activated)) {
|
||||||
deadlock if the window never gets activated but
|
usleep (1000);
|
||||||
should not be called here if the window doesn't
|
}
|
||||||
exist or will never exist*/
|
|
||||||
|
|
||||||
while(!(vstfx->been_activated))
|
|
||||||
usleep(1000);
|
|
||||||
|
|
||||||
id = vstfx->xid;
|
id = vstfx->xid;
|
||||||
|
|
||||||
pthread_mutex_unlock(&vstfx->lock);
|
pthread_mutex_unlock (&vstfx->lock);
|
||||||
|
|
||||||
/*Finally it might be safe to return the ID -
|
/* Finally it might be safe to return the ID -
|
||||||
problems will arise if we return either a zero ID
|
problems will arise if we return either a zero ID
|
||||||
and GTK tries to socket it or if we return an ID
|
and GTK tries to socket it or if we return an ID
|
||||||
which hasn't yet become real to the server*/
|
which hasn't yet become real to the server
|
||||||
|
*/
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
float htonf (float v)
|
float
|
||||||
|
htonf (float v)
|
||||||
{
|
{
|
||||||
float result;
|
float result;
|
||||||
char * fin = (char*)&v;
|
char * fin = (char*)&v;
|
||||||
|
|
@ -830,7 +825,7 @@ float htonf (float v)
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int vstfx_load_state (VSTFX* vstfx, char * filename)
|
int vstfx_load_state (VSTState* vstfx, char * filename)
|
||||||
{
|
{
|
||||||
FILE* f = fopen (filename, "rb");
|
FILE* f = fopen (filename, "rb");
|
||||||
if(f)
|
if(f)
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ WindowsVSTPluginUI::forward_key_event (GdkEventKey* ev)
|
||||||
{
|
{
|
||||||
if (ev->type == GDK_KEY_PRESS) {
|
if (ev->type == GDK_KEY_PRESS) {
|
||||||
|
|
||||||
FST* fst = vst->fst ();
|
VSTState* fst = vst->fst ();
|
||||||
pthread_mutex_lock (&fst->lock);
|
pthread_mutex_lock (&fst->lock);
|
||||||
|
|
||||||
if (fst->n_pending_keys == (sizeof (fst->pending_keys) * sizeof (VSTKey))) {
|
if (fst->n_pending_keys == (sizeof (fst->pending_keys) * sizeof (VSTKey))) {
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class LXVSTPlugin : public ARDOUR::Plugin
|
||||||
int set_state (XMLNode const &, int);
|
int set_state (XMLNode const &, int);
|
||||||
|
|
||||||
AEffect * plugin () const { return _plugin; }
|
AEffect * plugin () const { return _plugin; }
|
||||||
VSTFX * vstfx () const { return _vstfx; }
|
VSTState * vstfx () const { return _vstfx; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
@ -103,8 +103,8 @@ private:
|
||||||
void add_state (XMLNode *) const;
|
void add_state (XMLNode *) const;
|
||||||
|
|
||||||
VSTHandle * handle;
|
VSTHandle * handle;
|
||||||
VSTFX* _vstfx;
|
VSTState * _vstfx;
|
||||||
AEffect* _plugin;
|
AEffect * _plugin;
|
||||||
bool been_resumed;
|
bool been_resumed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,4 +69,63 @@ struct _VSTHandle
|
||||||
|
|
||||||
typedef struct _VSTHandle VSTHandle;
|
typedef struct _VSTHandle VSTHandle;
|
||||||
|
|
||||||
|
struct _VSTState
|
||||||
|
{
|
||||||
|
AEffect* plugin;
|
||||||
|
|
||||||
|
/* Linux */
|
||||||
|
int linux_window; /* The plugin's parent X11 XWindow */
|
||||||
|
int linux_plugin_ui_window; /*The ID of the plugin UI window created by the plugin*/
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
void* windows_window;
|
||||||
|
|
||||||
|
int xid; /* X11 XWindow */
|
||||||
|
|
||||||
|
int want_resize; /*Set to signal the plugin resized its UI*/
|
||||||
|
void* extra_data; /*Pointer to any extra data*/
|
||||||
|
|
||||||
|
void* event_callback_thisptr;
|
||||||
|
void (*eventProc) (void* event);
|
||||||
|
|
||||||
|
VSTHandle* handle;
|
||||||
|
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int wantIdle;
|
||||||
|
int destroy;
|
||||||
|
int vst_version;
|
||||||
|
int has_editor;
|
||||||
|
|
||||||
|
int program_set_without_editor;
|
||||||
|
|
||||||
|
int want_program;
|
||||||
|
int want_chunk;
|
||||||
|
int n_pending_keys;
|
||||||
|
unsigned char* wanted_chunk;
|
||||||
|
int wanted_chunk_size;
|
||||||
|
int current_program;
|
||||||
|
float * want_params;
|
||||||
|
float * set_params;
|
||||||
|
|
||||||
|
VSTKey pending_keys[16];
|
||||||
|
|
||||||
|
int dispatcher_wantcall;
|
||||||
|
int dispatcher_opcode;
|
||||||
|
int dispatcher_index;
|
||||||
|
int dispatcher_val;
|
||||||
|
void * dispatcher_ptr;
|
||||||
|
float dispatcher_opt;
|
||||||
|
int dispatcher_retval;
|
||||||
|
|
||||||
|
struct _VSTState * next;
|
||||||
|
pthread_mutex_t lock;
|
||||||
|
pthread_cond_t window_status_change;
|
||||||
|
pthread_cond_t plugin_dispatcher_called;
|
||||||
|
pthread_cond_t window_created;
|
||||||
|
int been_activated;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _VSTState VSTState;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -18,93 +18,34 @@ void vstfx_set_error_function (void (*func)(const char *));
|
||||||
|
|
||||||
void vstfx_error (const char *fmt, ...);
|
void vstfx_error (const char *fmt, ...);
|
||||||
|
|
||||||
#include "ardour/vestige/aeffectx.h"
|
|
||||||
|
|
||||||
typedef struct _VSTFX VSTFX;
|
|
||||||
|
|
||||||
/*Structure used to describe the instance of VSTFX responsible for
|
|
||||||
a particular plugin instance. These are connected together in a
|
|
||||||
linked list*/
|
|
||||||
|
|
||||||
struct _VSTFX
|
|
||||||
{
|
|
||||||
AEffect* plugin;
|
|
||||||
int window; /* The plugin's parent X11 XWindow */
|
|
||||||
int plugin_ui_window; /*The ID of the plugin UI window created by the plugin*/
|
|
||||||
int xid; /* X11 XWindow */
|
|
||||||
|
|
||||||
int want_resize; /*Set to signal the plugin resized its UI*/
|
|
||||||
void* extra_data; /*Pointer to any extra data*/
|
|
||||||
|
|
||||||
void* event_callback_thisptr;
|
|
||||||
void (*eventProc) (void* event);
|
|
||||||
|
|
||||||
VSTHandle* handle;
|
|
||||||
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int wantIdle;
|
|
||||||
int destroy;
|
|
||||||
int vst_version;
|
|
||||||
int has_editor;
|
|
||||||
|
|
||||||
int program_set_without_editor;
|
|
||||||
|
|
||||||
int want_program;
|
|
||||||
int want_chunk;
|
|
||||||
int n_pending_keys;
|
|
||||||
unsigned char* wanted_chunk;
|
|
||||||
int wanted_chunk_size;
|
|
||||||
int current_program;
|
|
||||||
float *want_params;
|
|
||||||
float *set_params;
|
|
||||||
|
|
||||||
VSTKey pending_keys[16];
|
|
||||||
|
|
||||||
int dispatcher_wantcall;
|
|
||||||
int dispatcher_opcode;
|
|
||||||
int dispatcher_index;
|
|
||||||
int dispatcher_val;
|
|
||||||
void * dispatcher_ptr;
|
|
||||||
float dispatcher_opt;
|
|
||||||
int dispatcher_retval;
|
|
||||||
|
|
||||||
struct _VSTFX* next;
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
pthread_cond_t window_status_change;
|
|
||||||
pthread_cond_t plugin_dispatcher_called;
|
|
||||||
pthread_cond_t window_created;
|
|
||||||
int been_activated;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*API to vstfx*/
|
/*API to vstfx*/
|
||||||
|
|
||||||
extern int vstfx_launch_editor(VSTFX* vstfx);
|
extern int vstfx_launch_editor (VSTState *);
|
||||||
extern int vstfx_init (void* possible_hmodule);
|
extern int vstfx_init (void *);
|
||||||
extern void vstfx_exit ();
|
extern void vstfx_exit ();
|
||||||
extern VSTHandle * vstfx_load (const char*);
|
extern VSTHandle * vstfx_load (const char*);
|
||||||
extern int vstfx_unload (VSTHandle *);
|
extern int vstfx_unload (VSTHandle *);
|
||||||
extern VSTFX* vstfx_instantiate (VSTHandle *, audioMasterCallback, void *);
|
extern VSTState * vstfx_instantiate (VSTHandle *, audioMasterCallback, void *);
|
||||||
extern void vstfx_close (VSTFX*);
|
extern void vstfx_close (VSTState*);
|
||||||
|
|
||||||
extern int vstfx_create_editor (VSTFX* vstfx);
|
extern int vstfx_create_editor (VSTState *);
|
||||||
extern int vstfx_run_editor (VSTFX*);
|
extern int vstfx_run_editor (VSTState *);
|
||||||
extern void vstfx_destroy_editor (VSTFX*);
|
extern void vstfx_destroy_editor (VSTState *);
|
||||||
extern int vstfx_get_XID (VSTFX*);
|
extern int vstfx_get_XID (VSTState *);
|
||||||
extern void vstfx_move_window_into_view (VSTFX*);
|
extern void vstfx_move_window_into_view (VSTState *);
|
||||||
|
|
||||||
extern VSTInfo * vstfx_get_info (char *dllpathname);
|
extern VSTInfo * vstfx_get_info (char *);
|
||||||
extern void vstfx_free_info (VSTInfo *);
|
extern void vstfx_free_info (VSTInfo *);
|
||||||
extern void vstfx_event_loop_remove_plugin (VSTFX* fst);
|
extern void vstfx_event_loop_remove_plugin (VSTState *);
|
||||||
extern int vstfx_call_dispatcher (VSTFX *vstfx, int opcode, int index, int val, void *ptr, float opt);
|
extern int vstfx_call_dispatcher (VSTState *, int, int, int, void *, float);
|
||||||
|
|
||||||
/** Load a plugin state from a file.**/
|
/** Load a plugin state from a file.**/
|
||||||
|
|
||||||
extern int vstfx_load_state (VSTFX* vstfx, char * filename);
|
extern int vstfx_load_state (VSTState* vstfx, char * filename);
|
||||||
|
|
||||||
/** Save a plugin state to a file.**/
|
/** Save a plugin state to a file.**/
|
||||||
|
|
||||||
extern bool vstfx_save_state (VSTFX* vstfx, char * filename);
|
extern bool vstfx_save_state (VSTState* vstfx, char * filename);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __vstfx_h__ */
|
#endif /* __vstfx_h__ */
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
#include "pbd/stateful.h"
|
#include "pbd/stateful.h"
|
||||||
#include "ardour/plugin.h"
|
#include "ardour/plugin.h"
|
||||||
|
|
||||||
struct _FST;
|
struct _VSTState;
|
||||||
typedef struct _FST FST;
|
typedef struct _VSTState VSTState;
|
||||||
struct _AEffect;
|
struct _AEffect;
|
||||||
typedef struct _AEffect AEffect;
|
typedef struct _AEffect AEffect;
|
||||||
struct _VSTHandle;
|
struct _VSTHandle;
|
||||||
|
|
@ -87,7 +87,7 @@ class WindowsVSTPlugin : public ARDOUR::Plugin
|
||||||
int set_state (XMLNode const &, int);
|
int set_state (XMLNode const &, int);
|
||||||
|
|
||||||
AEffect * plugin () const { return _plugin; }
|
AEffect * plugin () const { return _plugin; }
|
||||||
FST * fst () const { return _fst; }
|
VSTState * fst () const { return _fst; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ private:
|
||||||
void add_state (XMLNode *) const;
|
void add_state (XMLNode *) const;
|
||||||
|
|
||||||
VSTHandle* handle;
|
VSTHandle* handle;
|
||||||
FST* _fst;
|
VSTState* _fst;
|
||||||
AEffect* _plugin;
|
AEffect* _plugin;
|
||||||
bool been_resumed;
|
bool been_resumed;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,10 @@ vstfx_handle_new ()
|
||||||
|
|
||||||
/*Create and return a pointer to a new vstfx instance*/
|
/*Create and return a pointer to a new vstfx instance*/
|
||||||
|
|
||||||
VSTFX* vstfx_new ()
|
VSTState *
|
||||||
|
vstfx_new ()
|
||||||
{
|
{
|
||||||
VSTFX* vstfx = (VSTFX*) calloc (1, sizeof (VSTFX));
|
VSTState* vstfx = (VSTState *) calloc (1, sizeof (VSTState));
|
||||||
|
|
||||||
/*Mutexes*/
|
/*Mutexes*/
|
||||||
|
|
||||||
|
|
@ -72,8 +73,8 @@ VSTFX* vstfx_new ()
|
||||||
vstfx->n_pending_keys = 0;
|
vstfx->n_pending_keys = 0;
|
||||||
vstfx->has_editor = 0;
|
vstfx->has_editor = 0;
|
||||||
vstfx->program_set_without_editor = 0;
|
vstfx->program_set_without_editor = 0;
|
||||||
vstfx->window = 0;
|
vstfx->linux_window = 0;
|
||||||
vstfx->plugin_ui_window = 0;
|
vstfx->linux_plugin_ui_window = 0;
|
||||||
vstfx->eventProc = NULL;
|
vstfx->eventProc = NULL;
|
||||||
vstfx->extra_data = NULL;
|
vstfx->extra_data = NULL;
|
||||||
vstfx->want_resize = 0;
|
vstfx->want_resize = 0;
|
||||||
|
|
@ -270,10 +271,10 @@ vstfx_unload (VSTHandle* fhandle)
|
||||||
|
|
||||||
/*This instantiates a plugin*/
|
/*This instantiates a plugin*/
|
||||||
|
|
||||||
VSTFX *
|
VSTState *
|
||||||
vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
|
vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
|
||||||
{
|
{
|
||||||
VSTFX* vstfx = vstfx_new ();
|
VSTState* vstfx = vstfx_new ();
|
||||||
|
|
||||||
if(fhandle == NULL)
|
if(fhandle == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -315,7 +316,7 @@ vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
|
||||||
|
|
||||||
/*Close a vstfx instance*/
|
/*Close a vstfx instance*/
|
||||||
|
|
||||||
void vstfx_close (VSTFX* vstfx)
|
void vstfx_close (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
vstfx_destroy_editor(vstfx);
|
vstfx_destroy_editor(vstfx);
|
||||||
|
|
||||||
|
|
@ -358,7 +359,7 @@ void vstfx_close (VSTFX* vstfx)
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
vstfx_save_state (VSTFX* vstfx, char * filename)
|
vstfx_save_state (VSTState* vstfx, char * filename)
|
||||||
{
|
{
|
||||||
FILE* f = fopen (filename, "wb");
|
FILE* f = fopen (filename, "wb");
|
||||||
if (f)
|
if (f)
|
||||||
|
|
@ -460,7 +461,7 @@ vstfx_save_state (VSTFX* vstfx, char * filename)
|
||||||
|
|
||||||
/*Set up a call to the plugins 'dispatcher' function*/
|
/*Set up a call to the plugins 'dispatcher' function*/
|
||||||
|
|
||||||
int vstfx_call_dispatcher (VSTFX *vstfx, int opcode, int index, int val, void *ptr, float opt)
|
int vstfx_call_dispatcher (VSTState* vstfx, int opcode, int index, int val, void *ptr, float opt)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&vstfx->lock);
|
pthread_mutex_lock (&vstfx->lock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,8 @@ static FILE* vstfx_infofile_for_write (char* dllpath)
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vstfx_can_midi(VSTFX *vstfx)
|
static
|
||||||
|
int vstfx_can_midi (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
AEffect *plugin = vstfx->plugin;
|
AEffect *plugin = vstfx->plugin;
|
||||||
|
|
||||||
|
|
@ -274,7 +275,7 @@ static int vstfx_can_midi(VSTFX *vstfx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VSTInfo *
|
static VSTInfo *
|
||||||
vstfx_info_from_plugin (VSTFX *vstfx)
|
vstfx_info_from_plugin (VSTState* vstfx)
|
||||||
{
|
{
|
||||||
VSTInfo* info = (VSTInfo*) malloc (sizeof (VSTInfo));
|
VSTInfo* info = (VSTInfo*) malloc (sizeof (VSTInfo));
|
||||||
|
|
||||||
|
|
@ -365,9 +366,9 @@ VSTInfo *
|
||||||
vstfx_get_info (char* dllpath)
|
vstfx_get_info (char* dllpath)
|
||||||
{
|
{
|
||||||
FILE* infofile;
|
FILE* infofile;
|
||||||
VSTHandle *h;
|
VSTHandle* h;
|
||||||
VSTFX *vstfx;
|
VSTState* vstfx;
|
||||||
VSTInfo *info;
|
VSTInfo* info;
|
||||||
|
|
||||||
if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
|
if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
|
||||||
VSTInfo *info;
|
VSTInfo *info;
|
||||||
|
|
|
||||||
|
|
@ -28,48 +28,6 @@ void fst_set_error_function (void (*func)(const char *));
|
||||||
|
|
||||||
void fst_error (const char *fmt, ...);
|
void fst_error (const char *fmt, ...);
|
||||||
|
|
||||||
typedef struct _FST FST;
|
|
||||||
|
|
||||||
struct _FST
|
|
||||||
{
|
|
||||||
AEffect* plugin;
|
|
||||||
void* window; /* win32 HWND */
|
|
||||||
int xid; /* X11 XWindow */
|
|
||||||
VSTHandle* handle;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int wantIdle;
|
|
||||||
int destroy;
|
|
||||||
int vst_version;
|
|
||||||
int has_editor;
|
|
||||||
|
|
||||||
int program_set_without_editor;
|
|
||||||
int want_program;
|
|
||||||
int want_chunk;
|
|
||||||
unsigned char *wanted_chunk;
|
|
||||||
int wanted_chunk_size;
|
|
||||||
int current_program;
|
|
||||||
float *want_params;
|
|
||||||
float *set_params;
|
|
||||||
|
|
||||||
VSTKey pending_keys[16];
|
|
||||||
int n_pending_keys;
|
|
||||||
|
|
||||||
int dispatcher_wantcall;
|
|
||||||
int dispatcher_opcode;
|
|
||||||
int dispatcher_index;
|
|
||||||
int dispatcher_val;
|
|
||||||
void * dispatcher_ptr;
|
|
||||||
float dispatcher_opt;
|
|
||||||
int dispatcher_retval;
|
|
||||||
|
|
||||||
struct _FST* next;
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
pthread_cond_t window_status_change;
|
|
||||||
pthread_cond_t plugin_dispatcher_called;
|
|
||||||
int been_activated;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -80,29 +38,29 @@ extern void fst_exit ();
|
||||||
extern VSTHandle* fst_load (const char*);
|
extern VSTHandle* fst_load (const char*);
|
||||||
extern int fst_unload (VSTHandle*);
|
extern int fst_unload (VSTHandle*);
|
||||||
|
|
||||||
extern FST* fst_instantiate (VSTHandle*, audioMasterCallback amc, void* userptr);
|
extern VSTState * fst_instantiate (VSTHandle *, audioMasterCallback amc, void* userptr);
|
||||||
extern void fst_close (FST*);
|
extern void fst_close (VSTState *);
|
||||||
|
|
||||||
extern int fst_create_editor (FST* fst);
|
extern int fst_create_editor (VSTState* fst);
|
||||||
extern int fst_run_editor (FST*);
|
extern int fst_run_editor (VSTState *);
|
||||||
extern void fst_destroy_editor (FST*);
|
extern void fst_destroy_editor (VSTState *);
|
||||||
extern int fst_get_XID (FST*);
|
extern int fst_get_XID (VSTState *);
|
||||||
extern void fst_move_window_into_view (FST*);
|
extern void fst_move_window_into_view (VSTState *);
|
||||||
|
|
||||||
extern VSTInfo *fst_get_info (char *dllpathname);
|
extern VSTInfo *fst_get_info (char *dllpathname);
|
||||||
extern void fst_free_info (VSTInfo *info);
|
extern void fst_free_info (VSTInfo *info);
|
||||||
extern void fst_event_loop_remove_plugin (FST* fst);
|
extern void fst_event_loop_remove_plugin (VSTState* fst);
|
||||||
extern int fst_call_dispatcher(FST *fst, int opcode, int index, int val, void *ptr, float opt );
|
extern int fst_call_dispatcher (VSTState *, int, int, int, void *, float);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a plugin state from a file.
|
* Load a plugin state from a file.
|
||||||
*/
|
*/
|
||||||
extern int fst_load_state (FST * fst, char * filename);
|
extern int fst_load_state (VSTState *, char *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a plugin state to a file.
|
* Save a plugin state to a file.
|
||||||
*/
|
*/
|
||||||
extern int fst_save_state (FST * fst, char * filename);
|
extern int fst_save_state (VSTState *, char *);
|
||||||
|
|
||||||
extern int wine_pthread_create (pthread_t* thread_id, const pthread_attr_t* attr, void *(*function)(void*), void* arg);
|
extern int wine_pthread_create (pthread_t* thread_id, const pthread_attr_t* attr, void *(*function)(void*), void* arg);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ static int fst_info_file_is_valid( char *dllpath ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fst_can_midi (FST *fst)
|
fst_can_midi (VSTState* fst)
|
||||||
{
|
{
|
||||||
AEffect* plugin = fst->plugin;
|
AEffect* plugin = fst->plugin;
|
||||||
int vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0.0f);
|
int vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0.0f);
|
||||||
|
|
@ -165,7 +165,7 @@ fst_can_midi (FST *fst)
|
||||||
|
|
||||||
}
|
}
|
||||||
static VSTInfo *
|
static VSTInfo *
|
||||||
fst_info_from_plugin (FST* fst)
|
fst_info_from_plugin (VSTState* fst)
|
||||||
{
|
{
|
||||||
VSTInfo* info = (VSTInfo *) malloc (sizeof (VSTInfo));
|
VSTInfo* info = (VSTInfo *) malloc (sizeof (VSTInfo));
|
||||||
AEffect* plugin;
|
AEffect* plugin;
|
||||||
|
|
@ -241,10 +241,10 @@ fst_get_info (char* dllpath)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
VSTHandle *h;
|
VSTHandle* h;
|
||||||
FST *fst;
|
VSTState* fst;
|
||||||
VSTInfo *info;
|
VSTInfo* info;
|
||||||
char *fstpath;
|
char* fstpath;
|
||||||
|
|
||||||
if( !(h = fst_load( dllpath )) ) return NULL;
|
if( !(h = fst_load( dllpath )) ) return NULL;
|
||||||
if( !(fst = fst_instantiate( h, simple_master_callback, NULL )) ) {
|
if( !(fst = fst_instantiate( h, simple_master_callback, NULL )) ) {
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ typedef struct _JackVST JackVST;
|
||||||
|
|
||||||
struct _JackVST {
|
struct _JackVST {
|
||||||
jack_client_t *client;
|
jack_client_t *client;
|
||||||
VSTHandle* handle;
|
VSTHandle * handle;
|
||||||
FST* fst;
|
VSTState * fst;
|
||||||
float **ins;
|
float **ins;
|
||||||
float **outs;
|
float **outs;
|
||||||
jack_port_t *midi_port;
|
jack_port_t *midi_port;
|
||||||
|
|
@ -24,13 +24,6 @@ struct _JackVST {
|
||||||
int muted;
|
int muted;
|
||||||
int current_program;
|
int current_program;
|
||||||
|
|
||||||
int midi_map[128];
|
|
||||||
volatile int midi_learn;
|
|
||||||
volatile int midi_learn_CC;
|
|
||||||
volatile int midi_learn_PARAM;
|
|
||||||
|
|
||||||
int resume_called;
|
|
||||||
|
|
||||||
/* For VST/i support */
|
/* For VST/i support */
|
||||||
|
|
||||||
int want_midi;
|
int want_midi;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ struct ERect{
|
||||||
static pthread_mutex_t plugin_mutex;
|
static pthread_mutex_t plugin_mutex;
|
||||||
|
|
||||||
/** Head of linked list of all FSTs */
|
/** Head of linked list of all FSTs */
|
||||||
static FST* fst_first = NULL;
|
static VSTState* fst_first = NULL;
|
||||||
|
|
||||||
const char magic[] = "FST Plugin State v002";
|
const char magic[] = "FST Plugin State v002";
|
||||||
|
|
||||||
|
|
@ -68,10 +68,10 @@ my_window_proc (HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
return DefWindowProcA (w, msg, wp, lp );
|
return DefWindowProcA (w, msg, wp, lp );
|
||||||
}
|
}
|
||||||
|
|
||||||
static FST*
|
static VSTState *
|
||||||
fst_new ()
|
fst_new ()
|
||||||
{
|
{
|
||||||
FST* fst = (FST*) calloc (1, sizeof (FST));
|
VSTState* fst = (VSTState *) calloc (1, sizeof (VSTState));
|
||||||
pthread_mutex_init (&fst->lock, NULL);
|
pthread_mutex_init (&fst->lock, NULL);
|
||||||
pthread_cond_init (&fst->window_status_change, NULL);
|
pthread_cond_init (&fst->window_status_change, NULL);
|
||||||
pthread_cond_init (&fst->plugin_dispatcher_called, NULL);
|
pthread_cond_init (&fst->plugin_dispatcher_called, NULL);
|
||||||
|
|
@ -92,7 +92,7 @@ fst_handle_new ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
maybe_set_program (FST* fst)
|
maybe_set_program (VSTState* fst)
|
||||||
{
|
{
|
||||||
if (fst->want_program != -1) {
|
if (fst->want_program != -1) {
|
||||||
if (fst->vst_version >= 2) {
|
if (fst->vst_version >= 2) {
|
||||||
|
|
@ -118,7 +118,7 @@ maybe_set_program (FST* fst)
|
||||||
DWORD WINAPI gui_event_loop (LPVOID param)
|
DWORD WINAPI gui_event_loop (LPVOID param)
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
FST* fst;
|
VSTState* fst;
|
||||||
HMODULE hInst;
|
HMODULE hInst;
|
||||||
HWND window;
|
HWND window;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -180,10 +180,10 @@ again:
|
||||||
|
|
||||||
if (fst->destroy) {
|
if (fst->destroy) {
|
||||||
fprintf (stderr, "%s scheduled for destroy\n", fst->handle->name);
|
fprintf (stderr, "%s scheduled for destroy\n", fst->handle->name);
|
||||||
if (fst->window) {
|
if (fst->windows_window) {
|
||||||
fst->plugin->dispatcher( fst->plugin, effEditClose, 0, 0, NULL, 0.0 );
|
fst->plugin->dispatcher( fst->plugin, effEditClose, 0, 0, NULL, 0.0 );
|
||||||
CloseWindow (fst->window);
|
CloseWindow (fst->windows_window);
|
||||||
fst->window = NULL;
|
fst->windows_window = NULL;
|
||||||
fst->destroy = FALSE;
|
fst->destroy = FALSE;
|
||||||
}
|
}
|
||||||
fst_event_loop_remove_plugin (fst);
|
fst_event_loop_remove_plugin (fst);
|
||||||
|
|
@ -193,7 +193,7 @@ again:
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fst->window == NULL) {
|
if (fst->windows_window == NULL) {
|
||||||
if (fst_create_editor (fst)) {
|
if (fst_create_editor (fst)) {
|
||||||
fst_error ("cannot create editor for plugin %s", fst->handle->name);
|
fst_error ("cannot create editor for plugin %s", fst->handle->name);
|
||||||
fst_event_loop_remove_plugin (fst);
|
fst_event_loop_remove_plugin (fst);
|
||||||
|
|
@ -326,7 +326,7 @@ fst_exit ()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fst_run_editor (FST* fst)
|
fst_run_editor (VSTState* fst)
|
||||||
{
|
{
|
||||||
/* wait for the plugin editor window to be created (or not) */
|
/* wait for the plugin editor window to be created (or not) */
|
||||||
|
|
||||||
|
|
@ -334,12 +334,12 @@ fst_run_editor (FST* fst)
|
||||||
|
|
||||||
fst->has_editor = 1;
|
fst->has_editor = 1;
|
||||||
|
|
||||||
if (!fst->window) {
|
if (!fst->windows_window) {
|
||||||
pthread_cond_wait (&fst->window_status_change, &fst->lock);
|
pthread_cond_wait (&fst->window_status_change, &fst->lock);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock (&fst->lock);
|
pthread_mutex_unlock (&fst->lock);
|
||||||
|
|
||||||
if (!fst->window) {
|
if (!fst->windows_window) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -347,7 +347,7 @@ fst_run_editor (FST* fst)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fst_call_dispatcher (FST *fst, int opcode, int index, int val, void *ptr, float opt)
|
fst_call_dispatcher (VSTState* fst, int opcode, int index, int val, void *ptr, float opt)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&fst->lock);
|
pthread_mutex_lock (&fst->lock);
|
||||||
fst->dispatcher_opcode = opcode;
|
fst->dispatcher_opcode = opcode;
|
||||||
|
|
@ -364,7 +364,7 @@ fst_call_dispatcher (FST *fst, int opcode, int index, int val, void *ptr, float
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fst_create_editor (FST* fst)
|
fst_create_editor (VSTState * fst)
|
||||||
{
|
{
|
||||||
HMODULE hInst;
|
HMODULE hInst;
|
||||||
HWND window;
|
HWND window;
|
||||||
|
|
@ -401,12 +401,12 @@ fst_create_editor (FST* fst)
|
||||||
fst_error ("cannot set fst_ptr on window");
|
fst_error ("cannot set fst_ptr on window");
|
||||||
}
|
}
|
||||||
|
|
||||||
fst->window = window;
|
fst->windows_window = window;
|
||||||
// fst->xid = (int) GetPropA (window, "__wine_x11_whole_window");
|
// fst->xid = (int) GetPropA (window, "__wine_x11_whole_window");
|
||||||
|
|
||||||
|
|
||||||
//printf( "effEditOpen......\n" );
|
//printf( "effEditOpen......\n" );
|
||||||
fst->plugin->dispatcher (fst->plugin, effEditOpen, 0, 0, fst->window, 0 );
|
fst->plugin->dispatcher (fst->plugin, effEditOpen, 0, 0, fst->windows_window, 0);
|
||||||
fst->plugin->dispatcher (fst->plugin, effEditGetRect, 0, 0, &er, 0 );
|
fst->plugin->dispatcher (fst->plugin, effEditGetRect, 0, 0, &er, 0 );
|
||||||
|
|
||||||
fst->width = er->right-er->left;
|
fst->width = er->right-er->left;
|
||||||
|
|
@ -414,8 +414,8 @@ fst_create_editor (FST* fst)
|
||||||
//printf( "get rect ses... %d,%d\n", fst->width, fst->height );
|
//printf( "get rect ses... %d,%d\n", fst->width, fst->height );
|
||||||
|
|
||||||
//SetWindowPos (fst->window, 0, 9999, 9999, er->right-er->left+8, er->bottom-er->top+26, 0);
|
//SetWindowPos (fst->window, 0, 9999, 9999, er->right-er->left+8, er->bottom-er->top+26, 0);
|
||||||
SetWindowPos (fst->window, 0, 9999, 9999, 2, 2, 0);
|
SetWindowPos (fst->windows_window, 0, 9999, 9999, 2, 2, 0);
|
||||||
ShowWindow (fst->window, SW_SHOWNA);
|
ShowWindow (fst->windows_window, SW_SHOWNA);
|
||||||
//SetWindowPos (fst->window, 0, 0, 0, er->right-er->left+8, er->bottom-er->top+26, SWP_NOMOVE|SWP_NOZORDER);
|
//SetWindowPos (fst->window, 0, 0, 0, er->right-er->left+8, er->bottom-er->top+26, SWP_NOMOVE|SWP_NOZORDER);
|
||||||
|
|
||||||
fst->xid = (int) GetPropA (window, "__wine_x11_whole_window");
|
fst->xid = (int) GetPropA (window, "__wine_x11_whole_window");
|
||||||
|
|
@ -427,19 +427,19 @@ fst_create_editor (FST* fst)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fst_move_window_into_view (FST* fst)
|
fst_move_window_into_view (VSTState* fst)
|
||||||
{
|
{
|
||||||
if (fst->window) {
|
if (fst->windows_window) {
|
||||||
SetWindowPos (fst->window, 0, 0, 0, fst->width, fst->height+24, 0);
|
SetWindowPos (fst->windows_window, 0, 0, 0, fst->width, fst->height + 24, 0);
|
||||||
ShowWindow (fst->window, SW_SHOWNA);
|
ShowWindow (fst->windows_window, SW_SHOWNA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fst_destroy_editor (FST* fst)
|
fst_destroy_editor (VSTState* fst)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&fst->lock);
|
pthread_mutex_lock (&fst->lock);
|
||||||
if (fst->window) {
|
if (fst->windows_window) {
|
||||||
fprintf (stderr, "mark %s for destroy\n", fst->handle->name);
|
fprintf (stderr, "mark %s for destroy\n", fst->handle->name);
|
||||||
fst->destroy = TRUE;
|
fst->destroy = TRUE;
|
||||||
//if (!PostThreadMessageA (gui_thread_id, WM_USER, 0, 0)) {
|
//if (!PostThreadMessageA (gui_thread_id, WM_USER, 0, 0)) {
|
||||||
|
|
@ -454,10 +454,10 @@ fst_destroy_editor (FST* fst)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fst_event_loop_remove_plugin (FST* fst)
|
fst_event_loop_remove_plugin (VSTState* fst)
|
||||||
{
|
{
|
||||||
FST* p;
|
VSTState* p;
|
||||||
FST* prev;
|
VSTState* prev;
|
||||||
|
|
||||||
for (p = fst_first, prev = NULL; p->next; prev = p, p = p->next) {
|
for (p = fst_first, prev = NULL; p->next; prev = p, p = p->next) {
|
||||||
if (p == fst) {
|
if (p == fst) {
|
||||||
|
|
@ -601,17 +601,17 @@ fst_unload (VSTHandle* fhandle)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FST*
|
VSTState*
|
||||||
fst_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
|
fst_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
|
||||||
{
|
{
|
||||||
FST* fst = fst_new ();
|
VSTState* fst = fst_new ();
|
||||||
|
|
||||||
pthread_mutex_lock (&plugin_mutex);
|
pthread_mutex_lock (&plugin_mutex);
|
||||||
|
|
||||||
if (fst_first == NULL) {
|
if (fst_first == NULL) {
|
||||||
fst_first = fst;
|
fst_first = fst;
|
||||||
} else {
|
} else {
|
||||||
FST* p = fst_first;
|
VSTState* p = fst_first;
|
||||||
while (p->next) {
|
while (p->next) {
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
|
@ -652,7 +652,7 @@ fst_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fst_close (FST* fst)
|
fst_close (VSTState* fst)
|
||||||
{
|
{
|
||||||
fst_destroy_editor (fst);
|
fst_destroy_editor (fst);
|
||||||
|
|
||||||
|
|
@ -665,7 +665,7 @@ fst_close (FST* fst)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fst_get_XID (FST* fst)
|
fst_get_XID (VSTState* fst)
|
||||||
{
|
{
|
||||||
return fst->xid;
|
return fst->xid;
|
||||||
}
|
}
|
||||||
|
|
@ -791,7 +791,8 @@ int fst_load_state (FST * fst, char * filename)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int fst_save_state (FST * fst, char * filename)
|
int
|
||||||
|
fst_save_state (VSTState * fst, char * filename)
|
||||||
{
|
{
|
||||||
FILE * f = fopen (filename, "wb");
|
FILE * f = fopen (filename, "wb");
|
||||||
int j;
|
int j;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue