Remove frame conversion for MidiRegionView::note_in_region_range(), speed up tempo...
[ardour.git] / libs / ardour / ardour / session_route.h
index afe78b394e39efcafba0cf1b0893a1d7c2431c18..22bfc1f032b1030a1a9166cf913aec5ad5e2a983 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000 Paul Davis 
+    Copyright (C) 2000 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #ifndef __ardour_session_route_h__
 
 #include <iostream>
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
-#include <ardour/session.h>
-#include <ardour/route.h>
+#include "ardour/session.h"
+#include "ardour/route.h"
 
 namespace ARDOUR {
 
-template<class T> void 
-Session::foreach_route (T *obj, void (T::*func)(Route&))
+template<class T> void
+Session::foreach_route (T *obj, void (T::*func)(Route&), bool sort)
 {
-       RouteList public_order;
+       boost::shared_ptr<RouteList> r = routes.reader();
+       RouteList public_order (*r);
 
-       {
-               Glib::RWLock::ReaderLock lm (route_lock);
-               public_order = routes;
+       if (sort) {
+               public_order.sort (RoutePublicOrderSorter());
        }
 
-       RoutePublicOrderSorter cmp;
-       public_order.sort (cmp);
-
        for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
                (obj->*func) (**i);
        }
 }
 
-template<class T> void 
-Session::foreach_route (T *obj, void (T::*func)(Route*))
+template<class T> void
+Session::foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>), bool sort)
 {
-       RouteList public_order;
+       boost::shared_ptr<RouteList> r = routes.reader();
+       RouteList public_order (*r);
 
-       {
-               Glib::RWLock::ReaderLock lm (route_lock);
-               public_order = routes;
+       if (sort) {
+               public_order.sort (RoutePublicOrderSorter());
        }
 
-       RoutePublicOrderSorter cmp;
-       public_order.sort (cmp);
-
        for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
                (obj->*func) (*i);
        }
 }
 
-
-template<class T, class A> void 
-Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1)
+template<class T, class A> void
+Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1, bool sort)
 {
-       RouteList public_order;
+       boost::shared_ptr<RouteList> r = routes.reader();
+       RouteList public_order (*r);
 
-       {
-               Glib::RWLock::ReaderLock lm (route_lock);
-               public_order = routes;
+       if (sort) {
+               public_order.sort (RoutePublicOrderSorter());
        }
 
-       RoutePublicOrderSorter cmp;
-       public_order.sort (cmp);
-
        for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
                (obj->*func) (**i, arg1);
        }