diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/session.h | 4 | ||||
-rw-r--r-- | libs/ardour/session.cc | 72 |
2 files changed, 50 insertions, 26 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 521054dfdf..d86b919111 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -251,7 +251,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi boost::shared_ptr<Route> route_by_id (PBD::ID); boost::shared_ptr<Route> route_by_remote_id (uint32_t id); boost::shared_ptr<Track> track_by_diskstream_id (PBD::ID); - void routes_using_input_from (const std::string& str, RouteList& rl); + void routes_using_input_from (const std::string& str, RouteList& rl); bool route_name_unique (std::string) const; bool route_name_internal (std::string) const; @@ -616,8 +616,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void set_listen (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); void set_record_enabled (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); void set_solo_isolated (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); - void set_exclusive_input_active (boost::shared_ptr<Route> rt, bool others_on); void set_monitoring (boost::shared_ptr<RouteList>, MonitorChoice, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); + void set_exclusive_input_active (boost::shared_ptr<RouteList> rt, bool onoff, bool flip_others=false); PBD::Signal1<void,bool> SoloActive; PBD::Signal0<void> SoloChanged; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 180a6070fe..440ba026ae 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2686,44 +2686,68 @@ Session::io_name_is_legal (const std::string& name) } void -Session::set_exclusive_input_active (boost::shared_ptr<Route> rt, bool /*others_on*/) +Session::set_exclusive_input_active (boost::shared_ptr<RouteList> rl, bool onoff, bool flip_others) { - RouteList rl; + RouteList rl2; vector<string> connections; - PortSet& ps (rt->input()->ports()); - - for (PortSet::iterator p = ps.begin(); p != ps.end(); ++p) { - p->get_connections (connections); - } + /* if we are passed only a single route and we're not told to turn + * others off, then just do the simple thing. + */ - for (vector<string>::iterator s = connections.begin(); s != connections.end(); ++s) { - routes_using_input_from (*s, rl); + if (flip_others == false && rl->size() == 1) { + boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (rl->front()); + if (mt) { + mt->set_input_active (onoff); + return; + } } - /* scan all relevant routes to see if others are on or off */ + for (RouteList::iterator rt = rl->begin(); rt != rl->end(); ++rt) { - bool others_are_already_on = false; + PortSet& ps ((*rt)->input()->ports()); + + for (PortSet::iterator p = ps.begin(); p != ps.end(); ++p) { + p->get_connections (connections); + } + + for (vector<string>::iterator s = connections.begin(); s != connections.end(); ++s) { + routes_using_input_from (*s, rl2); + } + + /* scan all relevant routes to see if others are on or off */ + + bool others_are_already_on = false; + + for (RouteList::iterator r = rl2.begin(); r != rl2.end(); ++r) { - for (RouteList::iterator r = rl.begin(); r != rl.end(); ++r) { - if ((*r) != rt) { boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (*r); - if (mt) { + + if (!mt) { + continue; + } + + if ((*r) != (*rt)) { if (mt->input_active()) { others_are_already_on = true; - break; } + } else { + /* this one needs changing */ + mt->set_input_active (onoff); } } - } - - /* globally reverse other routes */ + + if (flip_others) { - for (RouteList::iterator r = rl.begin(); r != rl.end(); ++r) { - if ((*r) != rt) { - boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (*r); - if (mt) { - mt->set_input_active (!others_are_already_on); + /* globally reverse other routes */ + + for (RouteList::iterator r = rl2.begin(); r != rl2.end(); ++r) { + if ((*r) != (*rt)) { + boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (*r); + if (mt) { + mt->set_input_active (!others_are_already_on); + } + } } } } @@ -2732,7 +2756,7 @@ Session::set_exclusive_input_active (boost::shared_ptr<Route> rt, bool /*others_ void Session::routes_using_input_from (const string& str, RouteList& rl) { - boost::shared_ptr<RouteList> r = routes.reader (); + boost::shared_ptr<RouteList> r = routes.reader(); for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if ((*i)->input()->connected_to (str)) { |