add signal for VST state load
[ardour.git] / libs / ardour / vst_plugin.cc
index cf083e87f1f7c834698448e90d3369ce3a44d4db..a3dca8b3fa2e3d1cfe2e6ba58b899e44b2cfb17e 100644 (file)
@@ -172,8 +172,9 @@ VSTPlugin::set_chunk (gchar const * data, bool single)
        int r = 0;
        guchar* raw_data = g_base64_decode (data, &size);
        {
-               Glib::Threads::Mutex::Lock lm (_lock);
+               pthread_mutex_lock (&_state->state_lock);
                r = _plugin->dispatcher (_plugin, 24 /* effSetChunk */, single ? 1 : 0, size, raw_data, 0);
+               pthread_mutex_unlock (&_state->state_lock);
        }
        g_free (raw_data);
        return r;
@@ -344,7 +345,9 @@ VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc)
        }
 
        desc.normal = get_parameter (which);
-       _parameter_defaults[which] = desc.normal;
+       if (_parameter_defaults.find (which) == _parameter_defaults.end ()) {
+               _parameter_defaults[which] = desc.normal;
+       }
 
        return 0;
 }
@@ -384,6 +387,7 @@ VSTPlugin::load_plugin_preset (PresetRecord r)
        sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index);
 #endif
        _state->want_program = index;
+       LoadPresetProgram (); /* EMIT SIGNAL */ /* used for macvst */
        return true;
 }
 
@@ -426,6 +430,7 @@ VSTPlugin::load_user_preset (PresetRecord r)
                                        _state->wanted_chunk = raw_data;
                                        _state->wanted_chunk_size = size;
                                        _state->want_chunk = 1;
+                                       LoadPresetProgram (); /* EMIT SIGNAL */ /* used for macvst */
                                        return true;
                                }
                        }
@@ -564,8 +569,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
 {
        Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset);
 
-       Glib::Threads::Mutex::Lock lm (_state_lock, Glib::Threads::TRY_LOCK);
-       if (!lm.locked()) {
+       if (pthread_mutex_trylock (&_state->state_lock)) {
                /* by convention 'effSetChunk' should not be called while processing
                 * http://www.reaper.fm/sdk/vst/vst_ext.php
                 *
@@ -643,6 +647,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
        _plugin->processReplacing (_plugin, &ins[0], &outs[0], nframes);
        _midi_out_buf = 0;
 
+       pthread_mutex_unlock (&_state->state_lock);
        return 0;
 }