2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "ardour/vst_types.h"
23 vststate_init (VSTState* state) {
24 memset (state, 0, sizeof (VSTState));
25 pthread_mutex_init (&state->lock, 0);
26 pthread_mutex_init (&state->state_lock, 0);
27 pthread_cond_init (&state->window_status_change, 0);
28 pthread_cond_init (&state->plugin_dispatcher_called, 0);
29 pthread_cond_init (&state->window_created, 0);
30 state->want_program = -1;
33 /* This is to be called while handling VST UI events.
35 * Many plugins expect program dispatch from the GUI event-loop
36 * only (VSTPlugin::load_plugin_preset/set_chunk is invoked by
37 * the user in ardour's main GUI thread, which on Windows and Linux
38 * may *not* the VST event loop).
41 vststate_maybe_set_program (VSTState* state)
43 if (state->want_program != -1) {
44 if (state->vst_version >= 2) {
45 state->plugin->dispatcher (state->plugin, effBeginSetProgram, 0, 0, NULL, 0);
48 state->plugin->dispatcher (state->plugin, effSetProgram, 0, state->want_program, NULL, 0);
50 if (state->vst_version >= 2) {
51 state->plugin->dispatcher (state->plugin, effEndSetProgram, 0, 0, NULL, 0);
53 state->want_program = -1;
56 if (state->want_chunk == 1) {
57 pthread_mutex_lock (&state->state_lock);
58 state->plugin->dispatcher (state->plugin, 24 /* effSetChunk */, 1, state->wanted_chunk_size, state->wanted_chunk, 0);
59 state->want_chunk = 0;
60 pthread_mutex_unlock (&state->state_lock);