LV2 support.
[ardour.git] / libs / ardour / redirect.cc
index ba812525118b40e79c2a2077b1b24efdac4c5d7a..b1e631015fc3fcedacb01d287ec69349bf21c4aa 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <fstream>
@@ -28,6 +27,7 @@
 #include <sigc++/bind.h>
 
 #include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
 
 #include <ardour/redirect.h>
 #include <ardour/session.h>
@@ -97,18 +97,6 @@ Redirect::set_placement (Placement p, void *src)
        }
 }
 
-void
-Redirect::set_placement (const string& str, void *src)
-{
-       if (str == _("pre")) {
-               set_placement (PreFader, this);
-       } else if (str == _("post")) {
-               set_placement (PostFader, this);
-       } else {
-               error << string_compose(_("Redirect: unknown placement string \"%1\" (ignored)"), str) << endmsg;
-       }
-}
-
 /* NODE STRUCTURE 
    
     <Automation [optionally with visible="...." ]>
@@ -195,7 +183,7 @@ Redirect::state (bool full_state)
        stringstream sstr;
 
        node->add_property("active", active() ? "yes" : "no");  
-       node->add_property("placement", placement_as_string (placement()));
+       node->add_property("placement", enum_2_string (_placement));
        node->add_child_nocopy (IO::state (full_state));
 
        if (_extra_xml){
@@ -286,8 +274,11 @@ Redirect::set_state (const XMLNode& node)
        }
 
        if (_active != (prop->value() == "yes")) {
-               _active = !_active;
-               active_changed (this, this); /* EMIT_SIGNAL */
+               if (!(_session.state_of_the_state() & Session::Loading) || 
+                   !Session::get_disable_all_loaded_plugins()) {
+                       _active = !_active;
+                       active_changed (this, this); /* EMIT_SIGNAL */
+               }
        }
        
        if ((prop = node.property ("placement")) == 0) {
@@ -295,7 +286,20 @@ Redirect::set_state (const XMLNode& node)
                return -1;
        }
 
-       set_placement (prop->value(), this);
+       /* hack to handle older sessions before we only used EnumWriter */
+
+       string pstr;
+
+       if (prop->value() == "pre") {
+               pstr = "PreFader";
+       } else if (prop->value() == "post") {
+               pstr = "PostFader";
+       } else {
+               pstr = prop->value();
+       }
+
+       Placement p = Placement (string_2_enum (pstr, p));
+       set_placement (p, this);
 
        return 0;
 }