diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 433e567efa..44ba67cb67 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -266,7 +266,7 @@ Playlist::Playlist (Playlist& pl) Playlist::~Playlist () { - { + { RegionLock rl (this); for (set >::iterator i = all_regions.begin(); i != all_regions.end(); ++i) { @@ -489,7 +489,7 @@ Playlist::flush_notifications () void Playlist::add_region (boost::shared_ptr region, nframes_t position, float times) -{ +{ RegionLock rlock (this); times = fabs (times); @@ -1346,7 +1346,7 @@ Playlist::drop_regions () void Playlist::clear (bool with_signals) { - { + { RegionLock rl (this); for ( @@ -1662,14 +1662,10 @@ Playlist::find_next_region_boundary (nframes64_t frame, int dir) if (dir > 0) { for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - + boost::shared_ptr r = (*i); nframes64_t distance; - nframes64_t end = r->position() + r->length(); - bool reset; - - reset = false; - + if (r->first_frame() > frame) { distance = r->first_frame() - frame; @@ -1677,24 +1673,18 @@ Playlist::find_next_region_boundary (nframes64_t frame, int dir) if (distance < closest) { ret = r->first_frame(); closest = distance; - reset = true; } } - if (end > frame) { + if (r->last_frame () > frame) { - distance = end - frame; + distance = r->last_frame () - frame; if (distance < closest) { - ret = end; + ret = r->last_frame (); closest = distance; - reset = true; } } - - if (reset) { - break; - } } } else { @@ -1703,9 +1693,6 @@ Playlist::find_next_region_boundary (nframes64_t frame, int dir) boost::shared_ptr r = (*i); nframes64_t distance; - bool reset; - - reset = false; if (r->last_frame() < frame) { @@ -1714,23 +1701,18 @@ Playlist::find_next_region_boundary (nframes64_t frame, int dir) if (distance < closest) { ret = r->last_frame(); closest = distance; - reset = true; } } if (r->first_frame() < frame) { - distance = frame - r->last_frame(); + distance = frame - r->first_frame(); + if (distance < closest) { ret = r->first_frame(); closest = distance; - reset = true; } } - - if (reset) { - break; - } } } @@ -1933,7 +1915,7 @@ Playlist::bump_name (string name, Session &session) layer_t Playlist::top_layer() const { - RegionLock rlock (const_cast (this)); + RegionLock rlock (const_cast (this)); layer_t top = 0; for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {