properly clean up meter-pattern cache
[ardour.git] / libs / surfaces / control_protocol / control_protocol.cc
index e2bc1673d800789bd2fe630b116d8511088c634b..6ac673925a52d347f7fe1700197e20135cc52dde 100644 (file)
@@ -47,37 +47,32 @@ PBD::Signal0<void> ControlProtocol::VerticalZoomOutSelected;
 PBD::Signal1<void,RouteNotificationListPtr> ControlProtocol::TrackSelectionChanged;
 PBD::Signal1<void,uint32_t> ControlProtocol::AddRouteToSelection;
 PBD::Signal1<void,uint32_t> ControlProtocol::SetRouteSelection;
+PBD::Signal1<void,uint32_t> ControlProtocol::ToggleRouteSelection;
 PBD::Signal1<void,uint32_t> ControlProtocol::RemoveRouteFromSelection;
 PBD::Signal0<void>          ControlProtocol::ClearRouteSelection;
+PBD::Signal0<void>          ControlProtocol::StepTracksDown;
+PBD::Signal0<void>          ControlProtocol::StepTracksUp;
 
-ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop)
-       : BasicUI (s),
-         _name (str)
-{
-       if (evloop) {
-               _own_event_loop = false;
-               _event_loop = evloop;
-       } else {
-               _own_event_loop = true;
-               fatal << "programming error: cannot create control protocols without an existing event loop (yet)" << endmsg;
-               /*NOTREACHED*/
-       }
+const std::string ControlProtocol::state_node_name ("Protocol");
 
-       _active = false;
-       
-       session->RouteAdded.connect (*this, MISSING_INVALIDATOR, boost::protect (boost::bind (&ControlProtocol::add_strip, this, _1)), _event_loop);
+ControlProtocol::ControlProtocol (Session& s, string str)
+       : BasicUI (s)
+       , _name (str)
+       , _active (false)
+{
 }
 
 ControlProtocol::~ControlProtocol ()
 {
 }
 
-void
-ControlProtocol::add_strip (ARDOUR::RouteList&)
+int
+ControlProtocol::set_active (bool yn)
 {
-       route_list_changed();
+       _active = yn;
+       return 0;
 }
-       
+
 void
 ControlProtocol::next_track (uint32_t initial_id)
 {
@@ -286,7 +281,7 @@ ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t whic
                return 0.0f;
        }
 
-       return r->peak_meter().peak_power (which_input);
+       return r->peak_meter().meter_level (which_input, MeterPeak);
 }
 
 
@@ -370,5 +365,28 @@ ControlProtocol:: route_get_name (uint32_t table_index)
 list<boost::shared_ptr<Bundle> >
 ControlProtocol::bundles ()
 {
-       return list<boost::shared_ptr<Bundle> > ();
+       return list<boost::shared_ptr<Bundle> > ();
+}
+
+XMLNode&
+ControlProtocol::get_state ()
+{
+       XMLNode* node = new XMLNode (state_node_name);
+
+       node->add_property ("name", _name);
+       node->add_property ("feedback", get_feedback() ? "yes" : "no");
+
+       return *node;
+}
+
+int
+ControlProtocol::set_state (XMLNode const & node, int /* version */)
+{
+       const XMLProperty* prop;
+
+       if ((prop = node.property ("feedback")) != 0) {
+               set_feedback (string_is_affirmative (prop->value()));
+       }
+
+       return 0;
 }