Remove unnecessary 0 checks before delete; see http://www.parashift.com/c++-faq-lite...
[ardour.git] / libs / ardour / vst_plugin.cc
index 7c161cccf7d0a45d4d84fa455c9f1dd005323a77..11169a74de8f02fd78cbe116ec8fd0d24219e7fd 100644 (file)
 #include <algorithm>
 #include <vector>
 #include <string>
-#include <ctype.h>
+#include <cctype>
 
 #include <cstdlib>
 #include <cstdio> // so libraptor doesn't complain
 #include <cmath>
 #include <dirent.h>
-#include <string.h> // for memmove
+#include <cstring> // for memmove
 #include <sys/stat.h>
 #include <cerrno>
 
+#include <glibmm/ustring.h>
+#include <glibmm/miscutils.h>
+
 #include <lrdf.h>
 #include <fst.h>
 
@@ -40,9 +43,9 @@
 
 #include <vst/aeffectx.h>
 
-#include <ardour/ardour.h>
 #include <ardour/session.h>
 #include <ardour/audioengine.h>
+#include <ardour/filesystem_paths.h>
 #include <ardour/vst_plugin.h>
 #include <ardour/buffer_set.h>
 
@@ -120,7 +123,7 @@ void
 VSTPlugin::set_parameter (uint32_t which, float val)
 {
        _plugin->setParameter (_plugin, which, val);
-       ParameterChanged (which, val); /* EMIT SIGNAL */
+       //ParameterChanged (which, val); /* EMIT SIGNAL */
 }
 
 float
@@ -142,7 +145,7 @@ VSTPlugin::get_state()
 {
        XMLNode *root = new XMLNode (state_node_name());
        LocaleGuard lg (X_("POSIX"));
-       
+
        if (_plugin->flags & effFlagsProgramChunks) {
 
                /* fetch the current chunk */
@@ -156,11 +159,13 @@ VSTPlugin::get_state()
 
                /* save it to a file */
 
-               string path;
+               Glib::ustring path = Glib::build_filename (get_user_ardour_path (), "vst");
                struct stat sbuf;
 
-               path = get_user_ardour_path ();
-               path += "vst";
+               sys::path user_vst_directory(user_config_directory());
+       
+               user_vst_directory /= "vst";
+               path = user_vst_directory.to_string();
 
                if (stat (path.c_str(), &sbuf)) {
                        if (errno == ENOENT) {
@@ -184,7 +189,7 @@ VSTPlugin::get_state()
                        return *root;
                }
                
-               path += "something";
+               path = Glib::build_filename (path, "something");
                
                /* store information */
 
@@ -348,8 +353,12 @@ VSTPlugin::describe_parameter (uint32_t param)
 }
 
 nframes_t
-VSTPlugin::latency () const
+VSTPlugin::signal_latency () const
 {
+       if (_user_latency) {
+               return _user_latency;
+       }
+
        return _plugin->initialDelay;
 }
 
@@ -411,10 +420,12 @@ VSTPlugin::activate ()
        _plugin->dispatcher (_plugin, effMainsChanged, 0, 1, NULL, 0.0f);
 }
 
-uint32_t 
+string
 VSTPlugin::unique_id() const
 {
-       return _plugin->uniqueID;
+       char buf[32];
+       snprintf (buf, sizeof (buf), "%d", _plugin->uniqueID);
+       return string (buf);
 }
 
 
@@ -501,15 +512,3 @@ VSTPluginInfo::load (Session& session)
                return PluginPtr ((Plugin*) 0);
        }
 }
-
-void
-VSTPlugin::store_state (ARDOUR::PluginState& s)
-{
-
-}
-
-void
-VSTPlugin::restore_state (ARDOUR::PluginState& s)
-{
-
-}