X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Froute_graph.cc;h=dfe61c4c331b378026ff5dc72efa752e095fa2d8;hb=6bc95465d6137da74907bb528861681deec7b2df;hp=ab88a0d839c5b45f676531e3216006597fdc43a3;hpb=22b07e0233a29d9633ffa825a79503befaf2e16e;p=ardour.git diff --git a/libs/ardour/route_graph.cc b/libs/ardour/route_graph.cc index ab88a0d839..dfe61c4c33 100644 --- a/libs/ardour/route_graph.cc +++ b/libs/ardour/route_graph.cc @@ -20,8 +20,9 @@ #include "ardour/route.h" #include "ardour/route_graph.h" +#include "ardour/track.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -59,6 +60,24 @@ GraphEdges::find_in_from_to_with_sends (GraphVertex from, GraphVertex to) return _from_to_with_sends.end (); } +GraphEdges::EdgeMapWithSends::iterator +GraphEdges::find_recursively_in_from_to_with_sends (GraphVertex from, GraphVertex to) +{ + typedef EdgeMapWithSends::iterator Iter; + pair r = _from_to_with_sends.equal_range (from); + for (Iter i = r.first; i != r.second; ++i) { + if (i->second.first == to) { + return i; + } + GraphEdges::EdgeMapWithSends::iterator t = find_recursively_in_from_to_with_sends (i->second.first, to); + if (t != _from_to_with_sends.end ()) { + return t; + } + } + + return _from_to_with_sends.end (); +} + /** @param via_sends_only if non-0, filled in with true if the edge is a * path via a send only. * @return true if the given edge is present. @@ -78,6 +97,16 @@ GraphEdges::has (GraphVertex from, GraphVertex to, bool* via_sends_only) return true; } +bool +GraphEdges::feeds (GraphVertex from, GraphVertex to) +{ + EdgeMapWithSends::iterator i = find_recursively_in_from_to_with_sends (from, to); + if (i == _from_to_with_sends.end ()) { + return false; + } + return true; +} + /** @return the vertices that are fed from `r' */ set GraphEdges::from (GraphVertex r) const @@ -167,21 +196,41 @@ struct RouteRecEnabledComparator { bool operator () (GraphVertex r1, GraphVertex r2) const { - if (r1->record_enabled()) { - if (r2->record_enabled()) { + boost::shared_ptr t1 (boost::dynamic_pointer_cast(r1)); + boost::shared_ptr t2 (boost::dynamic_pointer_cast(r2)); + PresentationInfo::order_t r1o = r1->presentation_info().order(); + PresentationInfo::order_t r2o = r2->presentation_info().order(); + + if (!t1) { + if (!t2) { + /* makes no difference which is first, use presentation order */ + return r1o < r2o; + } else { + /* r1 is not a track, r2 is, run it early */ + return false; + } + } + + if (!t2) { + /* we already tested !t1, so just use presentation order */ + return r1o < r2o; + } + + if (t1->rec_enable_control()->get_value()) { + if (t2->rec_enable_control()->get_value()) { /* both rec-enabled, just use signal order */ - return r1->order_key () < r2->order_key (); + return r1o < r2o; } else { - /* r1 rec-enabled, r2 not rec-enabled, run r2 early */ + /* t1 rec-enabled, t2 not rec-enabled, run t2 early */ return false; } } else { - if (r2->record_enabled()) { - /* r2 rec-enabled, r1 not rec-enabled, run r1 early */ + if (t2->rec_enable_control()->get_value()) { + /* t2 rec-enabled, t1 not rec-enabled, run t1 early */ return true; } else { - /* neither rec-enabled, use signal order */ - return r1->order_key () < r2->order_key (); + /* neither rec-enabled, use presentation order */ + return r1o < r2o; } } }