consolidate VSTState functions
This commit is contained in:
parent
f944c24c4b
commit
cf1651e6d7
@ -138,6 +138,13 @@ struct LIBARDOUR_API _VSTState
|
||||
|
||||
typedef struct _VSTState VSTState;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
LIBARDOUR_API extern void vststate_init (VSTState* state);
|
||||
LIBARDOUR_API extern void vststate_maybe_set_program (VSTState* state);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Robin Gareus <robin@gareus.org>
|
||||
* Copyright (C) 2010 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
|
||||
* the Free Software Foundation; either version 2, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ardour/vst_types.h"
|
||||
|
||||
void vststate_init (VSTState* state) {
|
||||
pthread_mutex_init (&state->lock, 0);
|
||||
pthread_mutex_init (&state->state_lock, 0);
|
||||
pthread_cond_init (&state->window_status_change, 0);
|
||||
pthread_cond_init (&state->plugin_dispatcher_called, 0);
|
||||
pthread_cond_init (&state->window_created, 0);
|
||||
state->want_program = -1;
|
||||
state->want_chunk = 0;
|
||||
state->n_pending_keys = 0;
|
||||
state->has_editor = 0;
|
||||
state->program_set_without_editor = 0;
|
||||
state->linux_window = 0;
|
||||
state->linux_plugin_ui_window = 0;
|
||||
state->eventProc = 0;
|
||||
state->extra_data = 0;
|
||||
state->want_resize = 0;
|
||||
}
|
63
libs/ardour/vst_state.cc
Normal file
63
libs/ardour/vst_state.cc
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Robin Gareus <robin@gareus.org>
|
||||
* Copyright (C) 2010 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
|
||||
* the Free Software Foundation; either version 2, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "ardour/vst_types.h"
|
||||
|
||||
void
|
||||
vststate_init (VSTState* state) {
|
||||
memset (state, 0, sizeof (VSTState));
|
||||
pthread_mutex_init (&state->lock, 0);
|
||||
pthread_mutex_init (&state->state_lock, 0);
|
||||
pthread_cond_init (&state->window_status_change, 0);
|
||||
pthread_cond_init (&state->plugin_dispatcher_called, 0);
|
||||
pthread_cond_init (&state->window_created, 0);
|
||||
state->want_program = -1;
|
||||
}
|
||||
|
||||
/* This is to be called while handling VST UI events.
|
||||
*
|
||||
* Many plugins expect program dispatch from the GUI event-loop
|
||||
* only (VSTPlugin::load_plugin_preset/set_chunk is invoked by
|
||||
* the user in ardour's main GUI thread, which on Windows and Linux
|
||||
* may *not* the VST event loop).
|
||||
*/
|
||||
void
|
||||
vststate_maybe_set_program (VSTState* state)
|
||||
{
|
||||
if (state->want_program != -1) {
|
||||
if (state->vst_version >= 2) {
|
||||
state->plugin->dispatcher (state->plugin, effBeginSetProgram, 0, 0, NULL, 0);
|
||||
}
|
||||
|
||||
state->plugin->dispatcher (state->plugin, effSetProgram, 0, state->want_program, NULL, 0);
|
||||
|
||||
if (state->vst_version >= 2) {
|
||||
state->plugin->dispatcher (state->plugin, effEndSetProgram, 0, 0, NULL, 0);
|
||||
}
|
||||
state->want_program = -1;
|
||||
}
|
||||
|
||||
if (state->want_chunk == 1) {
|
||||
pthread_mutex_lock (&state->state_lock);
|
||||
state->plugin->dispatcher (state->plugin, 24 /* effSetChunk */, 1, state->wanted_chunk_size, state->wanted_chunk, 0);
|
||||
state->want_chunk = 0;
|
||||
pthread_mutex_unlock (&state->state_lock);
|
||||
}
|
||||
}
|
@ -436,7 +436,7 @@ def build(bld):
|
||||
obj.defines += [ 'LXVST_SUPPORT' ]
|
||||
|
||||
if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT') or bld.is_defined('MACVST_SUPPORT'):
|
||||
obj.source += [ 'session_vst.cc', 'vst_plugin.cc', 'vst_info_file.cc', 'vst_helper.cc' ]
|
||||
obj.source += [ 'session_vst.cc', 'vst_plugin.cc', 'vst_info_file.cc', 'vst_state.cc' ]
|
||||
|
||||
if bld.is_defined('MACVST_SUPPORT'):
|
||||
obj.source += [ 'mac_vst_plugin.cc', 'mac_vst_support.cc' ]
|
||||
|
@ -36,8 +36,8 @@
|
||||
#endif
|
||||
#include "../ardour/filesystem_paths.cc"
|
||||
#include "../ardour/directory_names.cc"
|
||||
#include "../ardour/vst_helper.cc"
|
||||
|
||||
#include "../ardour/vst_state.cc"
|
||||
|
||||
#ifdef LXVST_SUPPORT
|
||||
void
|
||||
|
@ -72,33 +72,6 @@ vstedit_wndproc (HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
maybe_set_program (VSTState* fst)
|
||||
{
|
||||
if (fst->want_program != -1) {
|
||||
if (fst->vst_version >= 2) {
|
||||
fst->plugin->dispatcher (fst->plugin, effBeginSetProgram, 0, 0, NULL, 0);
|
||||
}
|
||||
|
||||
fst->plugin->dispatcher (fst->plugin, effSetProgram, 0, fst->want_program, NULL, 0);
|
||||
|
||||
if (fst->vst_version >= 2) {
|
||||
fst->plugin->dispatcher (fst->plugin, effEndSetProgram, 0, 0, NULL, 0);
|
||||
}
|
||||
fst->want_program = -1;
|
||||
}
|
||||
|
||||
if (fst->want_chunk == 1) {
|
||||
// XXX check
|
||||
// 24 == audioMasterGetAutomationState,
|
||||
// 48 == audioMasterGetChunkFile
|
||||
pthread_mutex_lock (&fst->state_lock);
|
||||
fst->plugin->dispatcher (fst->plugin, 24 /* effSetChunk */, 1, fst->wanted_chunk_size, fst->wanted_chunk, 0);
|
||||
fst->want_chunk = 0;
|
||||
pthread_mutex_unlock (&fst->state_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID CALLBACK
|
||||
idle_hands(
|
||||
HWND hwnd, // handle to window for timer messages
|
||||
@ -148,8 +121,8 @@ idle_hands(
|
||||
fst->n_pending_keys = 0;
|
||||
#endif
|
||||
|
||||
/* See comment for maybe_set_program call below */
|
||||
maybe_set_program (fst);
|
||||
/* See comment for call below */
|
||||
vststate_maybe_set_program (fst);
|
||||
fst->want_program = -1;
|
||||
fst->want_chunk = 0;
|
||||
/* If we don't have an editor window yet, we still need to
|
||||
@ -161,7 +134,7 @@ idle_hands(
|
||||
* and so it will be done again if and when the GUI arrives.
|
||||
*/
|
||||
if (fst->program_set_without_editor == 0) {
|
||||
maybe_set_program (fst);
|
||||
vststate_maybe_set_program (fst);
|
||||
fst->program_set_without_editor = 1;
|
||||
}
|
||||
|
||||
@ -220,15 +193,7 @@ static VSTState*
|
||||
fst_new (void)
|
||||
{
|
||||
VSTState* fst = (VSTState*) calloc (1, sizeof (VSTState));
|
||||
|
||||
//vststate_init (fst);
|
||||
pthread_mutex_init (&fst->lock, 0);
|
||||
pthread_mutex_init (&fst->state_lock, 0);
|
||||
pthread_cond_init (&fst->window_status_change, 0);
|
||||
pthread_cond_init (&fst->plugin_dispatcher_called, 0);
|
||||
pthread_cond_init (&fst->window_created, 0);
|
||||
fst->want_program = -1;
|
||||
//
|
||||
vststate_init (fst);
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
fst->voffset = 50;
|
||||
|
Loading…
Reference in New Issue
Block a user