summaryrefslogtreecommitdiff
path: root/libs/ardour/session.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-05-17 15:05:36 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-05-31 15:30:43 -0400
commitc448b805d1124a2d4a2004efb685ff54674f719f (patch)
tree1fa92e101ecd5f8b496f8812e21f7efc766d0afa /libs/ardour/session.cc
parent05647470ef5646f4443c08aada03ca46d099cb14 (diff)
fix implementation of Session::get_remote_nth_stripable()
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r--libs/ardour/session.cc32
1 files changed, 23 insertions, 9 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 39b8e6c50d..d150860584 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4213,25 +4213,39 @@ Session::get_remote_nth_route (uint16_t n) const
return boost::dynamic_pointer_cast<Route> (get_remote_nth_stripable (n, PresentationInfo::Route));
}
+struct GlobalPresentationOrderSorter {
+ bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
+ return a->presentation_info() < b->presentation_info();
+ }
+};
+
boost::shared_ptr<Stripable>
Session::get_remote_nth_stripable (uint16_t n, PresentationInfo::Flag flags) const
{
- boost::shared_ptr<RouteList> r = routes.reader ();
- vector<boost::shared_ptr<Route> > v;
+ StripableList sl;
+ uint32_t match_cnt = 0;
+
+ /* API is one-based, so adjust n */
- if (n >= r->size()) {
- return boost::shared_ptr<Route> ();
+ if (n) {
+ --n;
}
- v.assign (r->size(), boost::shared_ptr<Route>());
+ get_stripables (sl);
+ GlobalPresentationOrderSorter cmp;
+ sl.sort (cmp);
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if ((*i)->presentation_info().flag_match (flags)) {
- v[(*i)->presentation_info().group_order()] = (*i);
+ for (StripableList::const_iterator s = sl.begin(); s != sl.end(); ++s) {
+ if ((*s)->presentation_info().flag_match (flags)) {
+ cerr << '\t' << (*s)->name() << " matches " << enum_2_string (flags) << endl;
+ if (match_cnt++ == n) {
+ return *s;
+ }
}
}
- return v[n];
+ /* there is no nth stripable that matches the given flags */
+ return boost::shared_ptr<Stripable>();
}
boost::shared_ptr<Route>