correct comment
[ardour.git] / libs / ardour / lv2_plugin.cc
index 46c80d56580c1210e5fa1a2e334046eef807ab47..6f8dad939689e4728dcb470eb7e37089492d34e3 100644 (file)
 #include "pbd/windows_special_dirs.h"
 #endif
 
+#ifdef WAF_BUILD
 #include "libardour-config.h"
+#endif
 
 #include "ardour/audio_buffer.h"
 #include "ardour/audioengine.h"
+#include "ardour/directory_names.h"
 #include "ardour/debug.h"
 #include "ardour/lv2_plugin.h"
 #include "ardour/midi_patch_manager.h"
@@ -414,7 +417,9 @@ LV2Plugin::init(const void* c_plugin, samplecnt_t rate)
        _was_activated          = false;
        _has_state_interface    = false;
        _can_write_automation   = false;
+#ifdef LV2_EXTENDED
        _inline_display_in_gui  = false;
+#endif
        _max_latency            = 0;
        _current_latency        = 0;
        _impl->block_length     = _session.get_block_size();
@@ -1376,13 +1381,20 @@ LV2Plugin::add_state(XMLNode* root) const
                unsigned int saved_state = _state_version;;
                g_mkdir_with_parents(new_dir.c_str(), 0744);
 
+               std::string xternal_dir = _session.externals_dir ();
+
+               if (!_plugin_state_dir.empty()) {
+                       xternal_dir = Glib::build_filename (_plugin_state_dir, externals_dir_name);
+                       g_mkdir_with_parents(xternal_dir.c_str(), 0744);
+               }
+
                LilvState* state = lilv_state_new_from_instance(
                        _impl->plugin,
                        _impl->instance,
                        _uri_map.urid_map(),
                        scratch_dir().c_str(),
                        file_dir().c_str(),
-                       _session.externals_dir().c_str(),
+                       xternal_dir.c_str(),
                        new_dir.c_str(),
                        NULL,
                        const_cast<LV2Plugin*>(this),
@@ -1412,6 +1424,7 @@ LV2Plugin::add_state(XMLNode* root) const
                        } else {
                                // template save (dedicated state-dir)
                                lilv_state_free(state);
+                               g_rmdir (xternal_dir.c_str()); // try remove unused dir
                                --_state_version;
                        }
                } else {
@@ -2321,18 +2334,22 @@ LV2Plugin::describe_parameter(Evoral::Parameter which)
 {
        if (( which.type() == PluginAutomation) && ( which.id() < parameter_count()) ) {
 
-               if (lilv_port_has_property(_impl->plugin,
-                                       lilv_plugin_get_port_by_index(_impl->plugin, which.id()), _world.ext_notOnGUI)) {
+               const LilvPort* port = lilv_plugin_get_port_by_index(_impl->plugin, which.id());
+
+               if (lilv_port_has_property(_impl->plugin, port, _world.ext_notOnGUI)) {
                        return X_("hidden");
                }
 
-               if (lilv_port_has_property(_impl->plugin,
-                                       lilv_plugin_get_port_by_index(_impl->plugin, which.id()), _world.lv2_freewheeling)) {
+               const LilvPort* fwport = lilv_plugin_get_port_by_designation(_impl->plugin, _world.lv2_InputPort, _world.lv2_freewheeling);
+               if (fwport && fwport == port) {
                        return X_("hidden");
                }
 
-               if (lilv_port_has_property(_impl->plugin,
-                                       lilv_plugin_get_port_by_index(_impl->plugin, which.id()), _world.lv2_reportsLatency)) {
+               if (lilv_port_has_property(_impl->plugin, port, _world.lv2_freewheeling)) {
+                       return X_("hidden");
+               }
+
+               if (lilv_port_has_property(_impl->plugin, port, _world.lv2_reportsLatency)) {
                        return X_("latency");
                }
 
@@ -3409,31 +3426,6 @@ LV2PluginInfo::get_presets (bool /*user_only*/) const
        return p;
 }
 
-bool
-LV2PluginInfo::in_category (const std::string &c) const
-{
-       // TODO use untranslated lilv_plugin_get_class()
-       // match gtk2_ardour/plugin_selector.cc
-       return category == c;
-}
-
-bool
-LV2PluginInfo::is_instrument () const
-{
-       if (category == "Instrument") {
-               return true;
-       }
-#if 1
-       /* until we make sure that category remains untranslated in the lv2.ttl spec
-        * and until most instruments also classify themselves as such, there's a 2nd check:
-        */
-       if (n_inputs.n_midi() > 0 && n_inputs.n_audio() == 0 && n_outputs.n_audio() > 0) {
-               return true;
-       }
-#endif
-       return false;
-}
-
 PluginInfoList*
 LV2PluginInfo::discover()
 {