summaryrefslogtreecommitdiff
path: root/libs/ardour/source.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/source.cc')
-rw-r--r--libs/ardour/source.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index c4cf1156cd..86afe4cb8d 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -132,7 +132,17 @@ Source::update_length (jack_nframes_t pos, jack_nframes_t cnt)
void
Source::add_playlist (boost::shared_ptr<Playlist> pl)
{
- _playlists.insert (pl);
+ std::pair<PlaylistMap::iterator,bool> res;
+ std::pair<boost::shared_ptr<Playlist>, uint32_t> newpair (pl, 1);
+ Glib::Mutex::Lock lm (playlist_lock);
+
+ res = _playlists.insert (newpair);
+
+ if (!res.second) {
+ /* it already existed, bump count */
+ res.first->second++;
+ }
+
pl->GoingAway.connect (bind (mem_fun (*this, &Source::remove_playlist), boost::weak_ptr<Playlist> (pl)));
}
@@ -145,10 +155,15 @@ Source::remove_playlist (boost::weak_ptr<Playlist> wpl)
return;
}
- std::set<boost::shared_ptr<Playlist> >::iterator x;
+ PlaylistMap::iterator x;
+ Glib::Mutex::Lock lm (playlist_lock);
if ((x = _playlists.find (pl)) != _playlists.end()) {
- _playlists.erase (x);
+ if (x->second > 1) {
+ x->second--;
+ } else {
+ _playlists.erase (x);
+ }
}
}