remove debug output and add a few suggestive comments
[ardour.git] / libs / ardour / session_playlists.cc
index 649d42902bfa4f846a840c9c8c7ba17913ce858e..368b043ef73f335361ddf805f421d02174bbb1af 100644 (file)
@@ -244,7 +244,6 @@ SessionPlaylists::destroy_region (boost::shared_ptr<Region> r)
        }
 }
 
-
 void
 SessionPlaylists::find_equivalent_playlist_regions (boost::shared_ptr<Region> region, vector<boost::shared_ptr<Region> >& result)
 {
@@ -260,6 +259,10 @@ SessionPlaylists::source_use_count (boost::shared_ptr<const Source> src) const
 {
        uint32_t count = 0;
 
+       /* XXXX this can go wildly wrong in the presence of circular references
+        * between compound regions.
+        */
+
        for (List::const_iterator p = playlists.begin(); p != playlists.end(); ++p) {
                 if ((*p)->uses_source (src)) {
                         ++count;
@@ -500,3 +503,19 @@ SessionPlaylists::playlists_for_track (boost::shared_ptr<Track> tr) const
 
        return pl_tr;
 }
+
+void
+SessionPlaylists::foreach (boost::function<void(boost::shared_ptr<const Playlist>)> functor)
+{
+       Glib::Threads::Mutex::Lock lm (lock);
+       for (List::iterator i = playlists.begin(); i != playlists.end(); i++) {
+               if (!(*i)->hidden()) {
+                       functor (*i);
+               }
+       }
+       for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); i++) {
+               if (!(*i)->hidden()) {
+                       functor (*i);
+               }
+       }
+}