summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/ardour/session.h6
-rw-r--r--libs/ardour/ardour/session_route.h47
-rw-r--r--libs/ardour/session.cc15
-rw-r--r--libs/ardour/session_butler.cc8
4 files changed, 56 insertions, 20 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 52a752d601..86822f3adc 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -350,6 +350,12 @@ public:
template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>), bool sort = true);
template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg, bool sort = true);
+ template<class A> void foreach_track (void (Track::*method)(A), A arg);
+ template<class A1, class A2> void foreach_track (void (Track::*method)(A1, A2), A1 arg1, A2 arg2);
+
+ template<class A> void foreach_route (void (Route::*method)(A), A arg);
+ template<class A1, class A2> void foreach_route (void (Route::*method)(A1, A2), A1 arg1, A2 arg2);
+
static char session_name_is_legal (const std::string&);
bool io_name_is_legal (const std::string&) const;
boost::shared_ptr<Route> route_by_name (std::string) const;
diff --git a/libs/ardour/ardour/session_route.h b/libs/ardour/ardour/session_route.h
index d6f212ec42..fe5f7ad8c0 100644
--- a/libs/ardour/ardour/session_route.h
+++ b/libs/ardour/ardour/session_route.h
@@ -76,6 +76,53 @@ Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1, bool sort)
}
}
+
+template<class A> void
+Session::foreach_track (void (Track::*method)(A), A arg)
+{
+ boost::shared_ptr<RouteList> r = routes.reader();
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); i++) {
+ boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+ if (tr) {
+ (tr->*method) (arg);
+ }
+ }
+}
+
+template<class A1, class A2> void
+Session::foreach_track (void (Track::*method)(A1, A2), A1 arg1, A2 arg2)
+{
+ boost::shared_ptr<RouteList> r = routes.reader();
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); i++) {
+ boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+ if (tr) {
+ (tr->*method) (arg1, arg2);
+ }
+ }
+}
+
+template<class A> void
+Session::foreach_route (void (Route::*method)(A), A arg)
+{
+ boost::shared_ptr<RouteList> r = routes.reader();
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); i++) {
+ ((*i).get()->*method) (arg);
+ }
+}
+
+template<class A1, class A2> void
+Session::foreach_route (void (Route::*method)(A1, A2), A1 arg1, A2 arg2)
+{
+ boost::shared_ptr<RouteList> r = routes.reader();
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); i++) {
+ ((*i).get()->*method) (arg1, arg2);
+ }
+}
+
} /* namespace */
#endif /* __ardour_session_route_h__ */
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 5242ab28ad..1a84fe4f86 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -109,6 +109,7 @@
#include "ardour/session.h"
#include "ardour/session_directory.h"
#include "ardour/session_playlists.h"
+#include "ardour/session_route.h"
#include "ardour/smf_source.h"
#include "ardour/solo_isolate_control.h"
#include "ardour/source_factory.h"
@@ -2080,19 +2081,7 @@ Session::set_block_size (pframes_t nframes)
ensure_buffers ();
- boost::shared_ptr<RouteList> r = routes.reader ();
-
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- (*i)->set_block_size (nframes);
- }
-
- boost::shared_ptr<RouteList> rl = routes.reader ();
- for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
- boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
- if (tr) {
- tr->set_block_size (nframes);
- }
- }
+ foreach_route (&Route::set_block_size, nframes);
DEBUG_TRACE (DEBUG::LatencyCompensation, "Session::set_block_size -> update worst i/o latency\n");
/* when this is called from the auto-connect thread, the process-lock is held */
diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc
index ee8fc08f3b..53fa929ff7 100644
--- a/libs/ardour/session_butler.cc
+++ b/libs/ardour/session_butler.cc
@@ -107,13 +107,7 @@ Session::overwrite_some_buffers (boost::shared_ptr<Route> r, OverwriteReason why
} else {
- boost::shared_ptr<RouteList> rl = routes.reader();
- for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
- boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
- if (tr) {
- tr->set_pending_overwrite (why);
- }
- }
+ foreach_track (&Track::set_pending_overwrite, why);
}
add_post_transport_work (PostTransportOverWrite);