Merge branch 'windows+cc' into cairocanvas
[ardour.git] / libs / surfaces / mackie / surface.cc
index 0c45a293783fa19e440ff9907a18ef9cb1478028..694c73b1bcb638f49bb3772bceeb6a55159f33cb 100644 (file)
@@ -24,7 +24,6 @@
 #include <cmath>
 
 #include "midi++/port.h"
-#include "midi++/manager.h"
 
 #include "ardour/automation_control.h"
 #include "ardour/debug.h"
@@ -87,7 +86,11 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
 {
        DEBUG_TRACE (DEBUG::MackieControl, "Surface::Surface init\n");
        
-       _port = new SurfacePort (*this);
+       try {
+               _port = new SurfacePort (*this);
+       } catch (...) {
+               throw failed_constructor ();
+       }
 
        /* only the first Surface object has global controls */
 
@@ -138,6 +141,39 @@ Surface::~Surface ()
        DEBUG_TRACE (DEBUG::MackieControl, "Surface::~Surface done\n");
 }
 
+XMLNode&
+Surface::get_state()
+{
+       char buf[64];
+       snprintf (buf, sizeof (buf), X_("surface-%u"), _number);
+       XMLNode* node = new XMLNode (buf);
+
+       node->add_child_nocopy (_port->get_state());
+
+       return *node;
+}
+
+int
+Surface::set_state (const XMLNode& node, int version)
+{
+       char buf[64];
+       snprintf (buf, sizeof (buf), X_("surface-%u"), _number);
+       XMLNode* mynode = node.child (buf);
+
+       if (!mynode) {
+               return 0;
+       }
+
+       XMLNode* portnode = mynode->child (X_("Port"));
+       if (portnode) {
+               if (_port->set_state (*portnode, version)) {
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
 const MidiByteArray& 
 Surface::sysex_hdr() const
 {
@@ -585,12 +621,6 @@ Surface::turn_it_on ()
        }
 }
 
-void 
-Surface::handle_port_inactive (SurfacePort*)
-{
-       _active = false;
-}
-
 void 
 Surface::write_sysex (const MidiByteArray & mba)
 {