NO-OP: whitespace
authorRobin Gareus <robin@gareus.org>
Fri, 21 Dec 2018 15:35:07 +0000 (16:35 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 21 Dec 2018 16:33:55 +0000 (17:33 +0100)
* Remove leading and trailing whitespace.
* use tabs to indent, space to align

/* prefer C-style comments like this,
 * always use an asterisk on every line, this
 * way small ASCII-graphics are always aligned
 * using spaces after the asterisk.
 *
 *            ^
 *           / \
 *          /   \
 *         /     \
 *        /       \
 *       /         \
 *      /  /\       \
 *     /__/  \_/\_^__\
 *       A R D O U R
 *
     << NO asterisk, there may be tabs :(
 *
 */

libs/ardour/ardour/playlist.h
libs/ardour/playlist.cc

index a8fabd7e65e9121f2f84c8ddf6328359c419842b..22e8e675522fa33f209aeada03856b78d715d97c 100644 (file)
@@ -53,21 +53,21 @@ class Crossfade;
 
 namespace Properties {
        /* fake the type, since regions are handled by SequenceProperty which doesn't
-          care about such things.
-       */
+        * care about such things.
+        */
        LIBARDOUR_API extern PBD::PropertyDescriptor<bool> regions;
 }
 
 class LIBARDOUR_API RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Region> > >
 {
-  public:
+public:
        RegionListProperty (Playlist&);
 
        RegionListProperty* clone () const;
        void get_content_as_xml (boost::shared_ptr<Region>, XMLNode &) const;
        boost::shared_ptr<Region> get_content_from_xml (XMLNode const &) const;
 
-  private:
+private:
        RegionListProperty* create () const;
 
        /* copy construction only by ourselves */
@@ -254,36 +254,36 @@ public:
 
        void set_capture_insertion_in_progress (bool yn);
 
-  protected:
+protected:
        friend class Session;
 
-  protected:
-    class RegionReadLock : public Glib::Threads::RWLock::ReaderLock {
-    public:
-        RegionReadLock (Playlist *pl) : Glib::Threads::RWLock::ReaderLock (pl->region_lock) {}
-        ~RegionReadLock() {}
-    };
-
-    class RegionWriteLock : public Glib::Threads::RWLock::WriterLock {
-    public:
-           RegionWriteLock (Playlist *pl, bool do_block_notify = true)
-                    : Glib::Threads::RWLock::WriterLock (pl->region_lock)
-                    , playlist (pl)
-                    , block_notify (do_block_notify) {
-                    if (block_notify) {
-                            playlist->delay_notifications();
-                    }
-            }
-
-        ~RegionWriteLock() {
-                Glib::Threads::RWLock::WriterLock::release ();
-                if (block_notify) {
-                        playlist->release_notifications ();
-                }
-        }
-        Playlist *playlist;
-        bool block_notify;
-    };
+protected:
+       class RegionReadLock : public Glib::Threads::RWLock::ReaderLock {
+               public:
+                       RegionReadLock (Playlist *pl) : Glib::Threads::RWLock::ReaderLock (pl->region_lock) {}
+                       ~RegionReadLock() {}
+       };
+
+       class RegionWriteLock : public Glib::Threads::RWLock::WriterLock {
+               public:
+                       RegionWriteLock (Playlist *pl, bool do_block_notify = true)
+                               : Glib::Threads::RWLock::WriterLock (pl->region_lock)
+                                       , playlist (pl)
+                                        , block_notify (do_block_notify) {
+                                                if (block_notify) {
+                                                        playlist->delay_notifications();
+                                                }
+                                        }
+
+                       ~RegionWriteLock() {
+                               Glib::Threads::RWLock::WriterLock::release ();
+                               if (block_notify) {
+                                       playlist->release_notifications ();
+                               }
+                       }
+                       Playlist *playlist;
+                       bool block_notify;
+       };
 
        RegionListProperty   regions;  /* the current list of regions in the playlist */
        std::set<boost::shared_ptr<Region> > all_regions; /* all regions ever added to this playlist */
@@ -410,12 +410,12 @@ public:
        */
        virtual void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {}
 
-  private:
+private:
        friend class RegionReadLock;
        friend class RegionWriteLock;
        mutable Glib::Threads::RWLock region_lock;
 
-  private:
+private:
        void setup_layering_indices (RegionList const &);
        void coalesce_and_check_crossfades (std::list<Evoral::Range<samplepos_t> >);
        boost::shared_ptr<RegionList> find_regions_at (samplepos_t);
index c992c1057906a1029dc55674d5130b6a52f68a0a..6a5332c34499cb2bdf3f364f0fcf8765e6da13c1 100644 (file)
@@ -55,16 +55,14 @@ namespace ARDOUR {
 }
 
 struct ShowMeTheList {
-    ShowMeTheList (boost::shared_ptr<Playlist> pl, const string& n) : playlist (pl), name (n) {}
-    ~ShowMeTheList () {
-           cerr << ">>>>" << name << endl; playlist->dump(); cerr << "<<<<" << name << endl << endl;
-    };
-    boost::shared_ptr<Playlist> playlist;
-    string name;
+       ShowMeTheList (boost::shared_ptr<Playlist> pl, const string& n) : playlist (pl), name (n) {}
+       ~ShowMeTheList () {
+               cerr << ">>>>" << name << endl; playlist->dump(); cerr << "<<<<" << name << endl << endl;
+       };
+       boost::shared_ptr<Playlist> playlist;
+       string name;
 };
 
-
-
 void
 Playlist::make_property_quarks ()
 {
@@ -102,9 +100,9 @@ RegionListProperty::create () const
 void
 RegionListProperty::get_content_as_xml (boost::shared_ptr<Region> region, XMLNode & node) const
 {
-       /* All regions (even those which are deleted) have their state saved by other
-          code, so we can just store ID here.
-       */
+       /* All regions (even those which are deleted) have their state
+        * saved by other code, so we can just store ID here.
+        */
 
        node.set_property ("id", region->id());
 }
@@ -349,11 +347,10 @@ Playlist::~Playlist ()
 void
 Playlist::_set_sort_id ()
 {
-       /*
-         Playlists are given names like <track name>.<id>
-         or <track name>.<edit group name>.<id> where id
-         is an integer. We extract the id and sort by that.
-       */
+       /* Playlists are given names like <track name>.<id>
+        * or <track name>.<edit group name>.<id> where id
+        * is an integer. We extract the id and sort by that.
+        */
 
        size_t dot_position = _name.val().find_last_of(".");
 
@@ -372,10 +369,10 @@ bool
 Playlist::set_name (const string& str)
 {
        /* in a typical situation, a playlist is being used
-          by one diskstream and also is referenced by the
-          Session. if there are more references than that,
-          then don't change the name.
-       */
+        * by one diskstream and also is referenced by the
+        * Session. if there are more references than that,
+        * then don't change the name.
+        */
 
        if (_refcnt > 2) {
                return false;
@@ -389,11 +386,11 @@ Playlist::set_name (const string& str)
 }
 
 /***********************************************************************
- CHANGE NOTIFICATION HANDLING
-
- Notifications must be delayed till the region_lock is released. This
- is necessary because handlers for the signals may need to acquire
- the lock (e.g. to read from the playlist).
CHANGE NOTIFICATION HANDLING
+ *
Notifications must be delayed till the region_lock is released. This
is necessary because handlers for the signals may need to acquire
the lock (e.g. to read from the playlist).
  ***********************************************************************/
 
 void
@@ -546,8 +543,8 @@ void
 Playlist::notify_region_added (boost::shared_ptr<Region> r)
 {
        /* the length change might not be true, but we have to act
-          as though it could be.
-       */
+        * as though it could be.
+        */
 
        if (holding_state()) {
                pending_adds.insert (r);
@@ -583,10 +580,10 @@ Playlist::flush_notifications (bool from_undo)
        */
 
        /* we have no idea what order the regions ended up in pending
-          bounds (it could be based on selection order, for example).
-          so, to preserve layering in the "most recently moved is higher"
-          model, sort them by existing layer, then timestamp them.
-       */
+        * bounds (it could be based on selection order, for example).
+        * so, to preserve layering in the "most recently moved is higher"
+        * model, sort them by existing layer, then timestamp them.
+        */
 
        // RegionSortByLayer cmp;
        // pending_bounds.sort (cmp);
@@ -661,8 +658,8 @@ Playlist::clear_pending ()
 }
 
 /*************************************************************
  PLAYLIST OPERATIONS
-*************************************************************/
* PLAYLIST OPERATIONS
+ *************************************************************/
 
 /** Note: this calls set_layer (..., DBL_MAX) so it will reset the layering index of region */
 void
@@ -692,8 +689,8 @@ Playlist::add_region (boost::shared_ptr<Region> region, samplepos_t position, fl
        }
 
        /* note that itimes can be zero if we being asked to just
-          insert a single fraction of the region.
-       */
+        * insert a single fraction of the region.
+        */
 
        for (int i = 0; i < itimes; ++i) {
                boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
@@ -918,7 +915,6 @@ static void maybe_add_start_beats (TempoMap const& tm, PropertyList& plist, boos
  *  start and end if cutting == true.  Regions that lie entirely within start and end are always
  *  removed.
  */
-
 void
 Playlist::partition_internal (samplepos_t start, samplepos_t end, bool cutting, RegionList& thawlist)
 {
@@ -935,9 +931,9 @@ Playlist::partition_internal (samplepos_t start, samplepos_t end, bool cutting,
 
                in_partition = true;
 
-               /* need to work from a copy, because otherwise the regions we add during the process
-                  get operated on as well.
-               */
+               /* need to work from a copy, because otherwise the regions we add
+                * during the process get operated on as well.
+                */
 
                RegionList copy = regions.rlist();
 
@@ -958,9 +954,9 @@ Playlist::partition_internal (samplepos_t start, samplepos_t end, bool cutting,
                        }
 
                        /* coverage will return OverlapStart if the start coincides
-                          with the end point. we do not partition such a region,
-                          so catch this special case.
-                       */
+                        * with the end point. we do not partition such a region,
+                        * so catch this special case.
+                        */
 
                        if (current->first_sample() >= end) {
                                continue;
@@ -977,19 +973,17 @@ Playlist::partition_internal (samplepos_t start, samplepos_t end, bool cutting,
 
                        if (overlap == Evoral::OverlapInternal) {
                                /* split: we need 3 new regions, the front, middle and end.
-                                  cut:   we need 2 regions, the front and end.
-                               */
-
-                               /*
-                                 start                 end
-                                 ---------------*************************------------
-                                 P1  P2              P3  P4
-                                 SPLIT:
-                                 ---------------*****++++++++++++++++====------------
-                                 CUT
-                                 ---------------*****----------------====------------
-
-                               */
+                                * cut:   we need 2 regions, the front and end.
+                                *
+                                *
+                                * start                 end
+                                * ---------------*************************------------
+                                * P1  P2              P3  P4
+                                * SPLIT:
+                                * ---------------*****++++++++++++++++====------------
+                                * CUT
+                                * ---------------*****----------------====------------
+                                */
 
                                if (!cutting) {
                                        /* "middle" ++++++ */
@@ -1088,20 +1082,18 @@ Playlist::partition_internal (samplepos_t start, samplepos_t end, bool cutting,
                        } else if (overlap == Evoral::OverlapStart) {
 
                                /* split: we need 2 regions: the front and the end.
-                                  cut: just trim current to skip the cut area
-                               */
-
-                               /*
-                                 start           end
-                                 ---------------*************************------------
-                                 P2          P1 P3                   P4
-
-                                 SPLIT:
-                                 ---------------****+++++++++++++++++++++------------
-                                 CUT:
-                                 -------------------*********************------------
-
-                               */
+                                * cut: just trim current to skip the cut area
+                                *
+                                *
+                                * start           end
+                                * ---------------*************************------------
+                                * P2          P1 P3                   P4
+                                *
+                                * SPLIT:
+                                * ---------------****+++++++++++++++++++++------------
+                                * CUT:
+                                * -------------------*********************------------
+                                */
 
                                if (!cutting) {
                                        /* front **** */
@@ -1133,20 +1125,20 @@ Playlist::partition_internal (samplepos_t start, samplepos_t end, bool cutting,
                        } else if (overlap == Evoral::OverlapExternal) {
 
                                /* split: no split required.
-                                  cut: remove the region.
-                               */
-
-                               /*
-                                 start                                      end
-                                 ---------------*************************------------
-                                 P2          P1 P3                   P4
-
-                                 SPLIT:
-                                 ---------------*************************------------
-                                 CUT:
-                                 ----------------------------------------------------
-
-                               */
+                                * cut: remove the region.
+                                *
+                                *
+                                * start                                      end
+                                * ---------------*************************------------
+                                * P2          P1 P3                   P4
+                                *
+                                *
+                                * SPLIT:
+                                * ---------------*************************------------
+                                * CUT:
+                                * ----------------------------------------------------
+                                *
+                                */
 
                                if (cutting) {
                                        remove_region_internal (current);
@@ -1186,9 +1178,9 @@ Playlist::cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(samplepos_t, sa
                } else {
 
                        /* paste the next section into the nascent playlist,
-                          offset to reflect the start of the first range we
-                          chopped.
-                       */
+                        * offset to reflect the start of the first range we
+                        * chopped.
+                        */
 
                        ret->paste (pl, (*i).start - start, 1.0f, 0);
                }
@@ -1401,143 +1393,142 @@ Playlist::duplicate_ranges (std::list<AudioRange>& ranges, float times)
        }
 }
 
- void
- Playlist::shift (samplepos_t at, sampleoffset_t distance, bool move_intersected, bool ignore_music_glue)
- {
-        RegionWriteLock rlock (this);
-        RegionList copy (regions.rlist());
-        RegionList fixup;
+void
+Playlist::shift (samplepos_t at, sampleoffset_t distance, bool move_intersected, bool ignore_music_glue)
+{
+       RegionWriteLock rlock (this);
+       RegionList copy (regions.rlist());
+       RegionList fixup;
 
-        for (RegionList::iterator r = copy.begin(); r != copy.end(); ++r) {
+       for (RegionList::iterator r = copy.begin(); r != copy.end(); ++r) {
 
-                if ((*r)->last_sample() < at) {
-                        /* too early */
-                        continue;
-                }
+               if ((*r)->last_sample() < at) {
+                       /* too early */
+                       continue;
+               }
 
-                if (at > (*r)->first_sample() && at < (*r)->last_sample()) {
-                        /* intersected region */
-                        if (!move_intersected) {
-                                continue;
-                        }
-                }
+               if (at > (*r)->first_sample() && at < (*r)->last_sample()) {
+                       /* intersected region */
+                       if (!move_intersected) {
+                               continue;
+                       }
+               }
 
-                /* do not move regions glued to music time - that
-                   has to be done separately.
+               /* do not move regions glued to music time - that
+                * has to be done separately.
                 */
 
-                if (!ignore_music_glue && (*r)->position_lock_style() != AudioTime) {
-                        fixup.push_back (*r);
-                        continue;
-                }
+               if (!ignore_music_glue && (*r)->position_lock_style() != AudioTime) {
+                       fixup.push_back (*r);
+                       continue;
+               }
 
-                (*r)->set_position ((*r)->position() + distance);
-        }
+               (*r)->set_position ((*r)->position() + distance);
+       }
 
-        /* XXX: may not be necessary; Region::post_set should do this, I think */
-        for (RegionList::iterator r = fixup.begin(); r != fixup.end(); ++r) {
-                (*r)->recompute_position_from_lock_style (0);
-        }
- }
+       /* XXX: may not be necessary; Region::post_set should do this, I think */
+       for (RegionList::iterator r = fixup.begin(); r != fixup.end(); ++r) {
+               (*r)->recompute_position_from_lock_style (0);
+       }
+}
 
- void
- Playlist::split (const MusicSample& at)
- {
-        RegionWriteLock rlock (this);
-        RegionList copy (regions.rlist());
+void
+Playlist::split (const MusicSample& at)
+{
+       RegionWriteLock rlock (this);
+       RegionList copy (regions.rlist());
 
-        /* use a copy since this operation can modify the region list
-         */
+       /* use a copy since this operation can modify the region list */
 
-        for (RegionList::iterator r = copy.begin(); r != copy.end(); ++r) {
-                _split_region (*r, at);
-        }
- }
+       for (RegionList::iterator r = copy.begin(); r != copy.end(); ++r) {
+               _split_region (*r, at);
+       }
+}
 
- void
- Playlist::split_region (boost::shared_ptr<Region> region, const MusicSample& playlist_position)
- {
-        RegionWriteLock rl (this);
-        _split_region (region, playlist_position);
- }
-
- void
- Playlist::_split_region (boost::shared_ptr<Region> region, const MusicSample& playlist_position)
- {
-        if (!region->covers (playlist_position.sample)) {
-                return;
-        }
+void
+Playlist::split_region (boost::shared_ptr<Region> region, const MusicSample& playlist_position)
+{
+       RegionWriteLock rl (this);
+       _split_region (region, playlist_position);
+}
 
-        if (region->position() == playlist_position.sample ||
-            region->last_sample() == playlist_position.sample) {
-                return;
-        }
+void
+Playlist::_split_region (boost::shared_ptr<Region> region, const MusicSample& playlist_position)
+{
+       if (!region->covers (playlist_position.sample)) {
+               return;
+       }
 
-        boost::shared_ptr<Region> left;
-        boost::shared_ptr<Region> right;
+       if (region->position() == playlist_position.sample ||
+                       region->last_sample() == playlist_position.sample) {
+               return;
+       }
 
-        MusicSample before (playlist_position.sample - region->position(), playlist_position.division);
-        MusicSample after (region->length() - before.sample, 0);
-        string before_name;
-        string after_name;
+       boost::shared_ptr<Region> left;
+       boost::shared_ptr<Region> right;
 
-        /* split doesn't change anything about length, so don't try to splice */
+       MusicSample before (playlist_position.sample - region->position(), playlist_position.division);
+       MusicSample after (region->length() - before.sample, 0);
+       string before_name;
+       string after_name;
 
-        bool old_sp = _splicing;
-        _splicing = true;
+       /* split doesn't change anything about length, so don't try to splice */
 
-        RegionFactory::region_name (before_name, region->name(), false);
+       bool old_sp = _splicing;
+       _splicing = true;
 
-        {
-                PropertyList plist;
+       RegionFactory::region_name (before_name, region->name(), false);
 
-                plist.add (Properties::length, before.sample);
-                plist.add (Properties::name, before_name);
-                plist.add (Properties::left_of_split, true);
-                plist.add (Properties::layering_index, region->layering_index ());
-                plist.add (Properties::layer, region->layer ());
+       {
+               PropertyList plist;
+
+               plist.add (Properties::length, before.sample);
+               plist.add (Properties::name, before_name);
+               plist.add (Properties::left_of_split, true);
+               plist.add (Properties::layering_index, region->layering_index ());
+               plist.add (Properties::layer, region->layer ());
 
-                /* note: we must use the version of ::create with an offset here,
-                   since it supplies that offset to the Region constructor, which
-                   is necessary to get audio region gain envelopes right.
+               /* note: we must use the version of ::create with an offset here,
+                * since it supplies that offset to the Region constructor, which
+                * is necessary to get audio region gain envelopes right.
                 */
-                left = RegionFactory::create (region, MusicSample (0, 0), plist, true);
-        }
+               left = RegionFactory::create (region, MusicSample (0, 0), plist, true);
+       }
 
-        RegionFactory::region_name (after_name, region->name(), false);
+       RegionFactory::region_name (after_name, region->name(), false);
 
-        {
-                PropertyList plist;
+       {
+               PropertyList plist;
 
-                plist.add (Properties::length, after.sample);
-                plist.add (Properties::name, after_name);
-                plist.add (Properties::right_of_split, true);
-                plist.add (Properties::layering_index, region->layering_index ());
-                plist.add (Properties::layer, region->layer ());
+               plist.add (Properties::length, after.sample);
+               plist.add (Properties::name, after_name);
+               plist.add (Properties::right_of_split, true);
+               plist.add (Properties::layering_index, region->layering_index ());
+               plist.add (Properties::layer, region->layer ());
 
-                /* same note as above */
-                right = RegionFactory::create (region, before, plist, true);
-        }
+               /* same note as above */
+               right = RegionFactory::create (region, before, plist, true);
+       }
 
-        add_region_internal (left, region->position(), 0);
-        add_region_internal (right, region->position() + before.sample, before.division);
+       add_region_internal (left, region->position(), 0);
+       add_region_internal (right, region->position() + before.sample, before.division);
 
-        remove_region_internal (region);
+       remove_region_internal (region);
 
-        _splicing = old_sp;
- }
+       _splicing = old_sp;
+}
 
 void
 Playlist::AddToSoloSelectedList(const Region* r)
 {
-       _soloSelectedRegions.insert (r);        
+       _soloSelectedRegions.insert (r);
 }
 
 
 void
 Playlist::RemoveFromSoloSelectedList(const Region* r)
 {
-       _soloSelectedRegions.erase (r); 
+       _soloSelectedRegions.erase (r);
 }
 
 
@@ -1556,73 +1547,73 @@ Playlist::SoloSelectedActive()
 }
 
 
- void
- Playlist::possibly_splice (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
- {
-        if (_splicing || in_set_state) {
-                /* don't respond to splicing moves or state setting */
-                return;
-        }
+void
+Playlist::possibly_splice (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
+{
+       if (_splicing || in_set_state) {
+               /* don't respond to splicing moves or state setting */
+               return;
+       }
 
-        if (_edit_mode == Splice) {
-                splice_locked (at, distance, exclude);
-        }
- }
-
- void
- Playlist::possibly_splice_unlocked (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
- {
-        if (_splicing || in_set_state) {
-                /* don't respond to splicing moves or state setting */
-                return;
-        }
+       if (_edit_mode == Splice) {
+               splice_locked (at, distance, exclude);
+       }
+}
 
-        if (_edit_mode == Splice) {
-                splice_unlocked (at, distance, exclude);
-        }
- }
-
- void
- Playlist::splice_locked (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
- {
-        {
-                RegionWriteLock rl (this);
-                core_splice (at, distance, exclude);
-        }
- }
+void
+Playlist::possibly_splice_unlocked (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
+{
+       if (_splicing || in_set_state) {
+               /* don't respond to splicing moves or state setting */
+               return;
+       }
 
- void
- Playlist::splice_unlocked (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
- {
-        core_splice (at, distance, exclude);
- }
+       if (_edit_mode == Splice) {
+               splice_unlocked (at, distance, exclude);
+       }
+}
 
- void
- Playlist::core_splice (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
- {
-        _splicing = true;
+void
+Playlist::splice_locked (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
+{
+       {
+               RegionWriteLock rl (this);
+               core_splice (at, distance, exclude);
+       }
+}
 
-        for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+void
+Playlist::splice_unlocked (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
+{
+       core_splice (at, distance, exclude);
+}
 
-                if (exclude && (*i) == exclude) {
-                        continue;
-                }
+void
+Playlist::core_splice (samplepos_t at, samplecnt_t distance, boost::shared_ptr<Region> exclude)
+{
+       _splicing = true;
 
-                if ((*i)->position() >= at) {
-                        samplepos_t new_pos = (*i)->position() + distance;
-                        if (new_pos < 0) {
-                                new_pos = 0;
-                        } else if (new_pos >= max_samplepos - (*i)->length()) {
-                                new_pos = max_samplepos - (*i)->length();
-                        }
+       for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
 
-                        (*i)->set_position (new_pos);
-                }
-        }
+               if (exclude && (*i) == exclude) {
+                       continue;
+               }
+
+               if ((*i)->position() >= at) {
+                       samplepos_t new_pos = (*i)->position() + distance;
+                       if (new_pos < 0) {
+                               new_pos = 0;
+                       } else if (new_pos >= max_samplepos - (*i)->length()) {
+                               new_pos = max_samplepos - (*i)->length();
+                       }
+
+                       (*i)->set_position (new_pos);
+               }
+       }
 
-        _splicing = false;
+       _splicing = false;
 
-        notify_contents_changed ();
+       notify_contents_changed ();
 }
 
 void
@@ -1679,180 +1670,180 @@ Playlist::core_ripple (samplepos_t at, samplecnt_t distance, RegionList *exclude
 void
 Playlist::region_bounds_changed (const PropertyChange& what_changed, boost::shared_ptr<Region> region)
 {
-        if (in_set_state || _splicing || _rippling || _nudging || _shuffling) {
-                return;
-        }
+       if (in_set_state || _splicing || _rippling || _nudging || _shuffling) {
+               return;
+       }
 
-        if (what_changed.contains (Properties::position)) {
+       if (what_changed.contains (Properties::position)) {
 
-                /* remove it from the list then add it back in
-                   the right place again.
+               /* remove it from the list then add it back in
+                * the right place again.
                 */
 
-                RegionSortByPosition cmp;
+               RegionSortByPosition cmp;
 
-                RegionList::iterator i = find (regions.begin(), regions.end(), region);
+               RegionList::iterator i = find (regions.begin(), regions.end(), region);
 
-                if (i == regions.end()) {
-                        /* the region bounds are being modified but its not currently
-                           in the region list. we will use its bounds correctly when/if
-                           it is added
+               if (i == regions.end()) {
+                       /* the region bounds are being modified but its not currently
+                        * in the region list. we will use its bounds correctly when/if
+                        * it is added
                         */
-                        return;
-                }
+                       return;
+               }
 
-                regions.erase (i);
-                regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp), region);
-        }
+               regions.erase (i);
+               regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp), region);
+       }
 
-        if (what_changed.contains (Properties::position) || what_changed.contains (Properties::length)) {
+       if (what_changed.contains (Properties::position) || what_changed.contains (Properties::length)) {
 
-                sampleoffset_t delta = 0;
+               sampleoffset_t delta = 0;
 
-                if (what_changed.contains (Properties::position)) {
-                        delta = region->position() - region->last_position();
-                }
+               if (what_changed.contains (Properties::position)) {
+                       delta = region->position() - region->last_position();
+               }
 
-                if (what_changed.contains (Properties::length)) {
-                        delta += region->length() - region->last_length();
-                }
+               if (what_changed.contains (Properties::length)) {
+                       delta += region->length() - region->last_length();
+               }
 
-                if (delta) {
-                        possibly_splice (region->last_position() + region->last_length(), delta, region);
-                }
+               if (delta) {
+                       possibly_splice (region->last_position() + region->last_length(), delta, region);
+               }
 
-                if (holding_state ()) {
-                        pending_bounds.push_back (region);
-                } else {
-                        notify_contents_changed ();
-                        relayer ();
-                        list<Evoral::Range<samplepos_t> > xf;
-                        xf.push_back (Evoral::Range<samplepos_t> (region->last_range()));
-                        xf.push_back (Evoral::Range<samplepos_t> (region->range()));
-                        coalesce_and_check_crossfades (xf);
-                }
-        }
- }
+               if (holding_state ()) {
+                       pending_bounds.push_back (region);
+               } else {
+                       notify_contents_changed ();
+                       relayer ();
+                       list<Evoral::Range<samplepos_t> > xf;
+                       xf.push_back (Evoral::Range<samplepos_t> (region->last_range()));
+                       xf.push_back (Evoral::Range<samplepos_t> (region->range()));
+                       coalesce_and_check_crossfades (xf);
+               }
+       }
+}
 
- void
- Playlist::region_changed_proxy (const PropertyChange& what_changed, boost::weak_ptr<Region> weak_region)
- {
-        boost::shared_ptr<Region> region (weak_region.lock());
+void
+Playlist::region_changed_proxy (const PropertyChange& what_changed, boost::weak_ptr<Region> weak_region)
+{
+       boost::shared_ptr<Region> region (weak_region.lock());
 
-        if (!region) {
-                return;
-        }
+       if (!region) {
+               return;
+       }
 
-        /* this makes a virtual call to the right kind of playlist ... */
+       /* this makes a virtual call to the right kind of playlist ... */
 
-        region_changed (what_changed, region);
- }
+       region_changed (what_changed, region);
+}
 
- bool
- Playlist::region_changed (const PropertyChange& what_changed, boost::shared_ptr<Region> region)
- {
-        PropertyChange our_interests;
-        PropertyChange bounds;
-        PropertyChange pos_and_length;
-        bool save = false;
+bool
+Playlist::region_changed (const PropertyChange& what_changed, boost::shared_ptr<Region> region)
+{
+       PropertyChange our_interests;
+       PropertyChange bounds;
+       PropertyChange pos_and_length;
+       bool save = false;
 
-        if (in_set_state || in_flush) {
-                return false;
-        }
+       if (in_set_state || in_flush) {
+               return false;
+       }
 
-        our_interests.add (Properties::muted);
-        our_interests.add (Properties::layer);
-        our_interests.add (Properties::opaque);
+       our_interests.add (Properties::muted);
+       our_interests.add (Properties::layer);
+       our_interests.add (Properties::opaque);
 
-        bounds.add (Properties::start);
-        bounds.add (Properties::position);
-        bounds.add (Properties::length);
+       bounds.add (Properties::start);
+       bounds.add (Properties::position);
+       bounds.add (Properties::length);
 
-        pos_and_length.add (Properties::position);
-        pos_and_length.add (Properties::length);
+       pos_and_length.add (Properties::position);
+       pos_and_length.add (Properties::length);
 
-        if (what_changed.contains (bounds)) {
-                region_bounds_changed (what_changed, region);
-                save = !(_splicing || _nudging);
-        }
+       if (what_changed.contains (bounds)) {
+               region_bounds_changed (what_changed, region);
+               save = !(_splicing || _nudging);
+       }
 
-        if (what_changed.contains (Properties::position) && !what_changed.contains (Properties::length)) {
-                notify_region_moved (region);
-        } else if (!what_changed.contains (Properties::position) && what_changed.contains (Properties::length)) {
-                notify_region_end_trimmed (region);
-        } else if (what_changed.contains (Properties::position) && what_changed.contains (Properties::length)) {
-                notify_region_start_trimmed (region);
-        }
+       if (what_changed.contains (Properties::position) && !what_changed.contains (Properties::length)) {
+               notify_region_moved (region);
+       } else if (!what_changed.contains (Properties::position) && what_changed.contains (Properties::length)) {
+               notify_region_end_trimmed (region);
+       } else if (what_changed.contains (Properties::position) && what_changed.contains (Properties::length)) {
+               notify_region_start_trimmed (region);
+       }
 
-        /* don't notify about layer changes, since we are the only object that can initiate
-           them, and we notify in ::relayer()
+       /* don't notify about layer changes, since we are the only object that can initiate
+        * them, and we notify in ::relayer()
         */
 
-        if (what_changed.contains (our_interests)) {
-                save = true;
-        }
+       if (what_changed.contains (our_interests)) {
+               save = true;
+       }
 
-        mark_session_dirty ();
+       mark_session_dirty ();
 
-        return save;
- }
+       return save;
+}
 
- void
- Playlist::drop_regions ()
- {
-        RegionWriteLock rl (this);
-        regions.clear ();
-        all_regions.clear ();
- }
+void
+Playlist::drop_regions ()
+{
+       RegionWriteLock rl (this);
+       regions.clear ();
+       all_regions.clear ();
+}
 
- void
- Playlist::sync_all_regions_with_regions ()
- {
-        RegionWriteLock rl (this);
+void
+Playlist::sync_all_regions_with_regions ()
+{
+       RegionWriteLock rl (this);
 
-        all_regions.clear ();
+       all_regions.clear ();
 
-        for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
-                all_regions.insert (*i);
-        }
- }
+       for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+               all_regions.insert (*i);
+       }
+}
 
- void
- Playlist::clear (bool with_signals)
- {
-        {
-                RegionWriteLock rl (this);
+void
+Playlist::clear (bool with_signals)
+{
+       {
+               RegionWriteLock rl (this);
 
-                region_state_changed_connections.drop_connections ();
-                region_drop_references_connections.drop_connections ();
+               region_state_changed_connections.drop_connections ();
+               region_drop_references_connections.drop_connections ();
 
-                for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
-                        pending_removes.insert (*i);
-                }
+               for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+                       pending_removes.insert (*i);
+               }
 
-                regions.clear ();
+               regions.clear ();
 
-                for (set<boost::shared_ptr<Region> >::iterator s = pending_removes.begin(); s != pending_removes.end(); ++s) {
-                        remove_dependents (*s);
-                }
-        }
+               for (set<boost::shared_ptr<Region> >::iterator s = pending_removes.begin(); s != pending_removes.end(); ++s) {
+                       remove_dependents (*s);
+               }
+       }
 
-        if (with_signals) {
+       if (with_signals) {
 
-                for (set<boost::shared_ptr<Region> >::iterator s = pending_removes.begin(); s != pending_removes.end(); ++s) {
-                        RegionRemoved (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
-                }
+               for (set<boost::shared_ptr<Region> >::iterator s = pending_removes.begin(); s != pending_removes.end(); ++s) {
+                       RegionRemoved (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
+               }
 
-                pending_removes.clear ();
-                pending_contents_change = false;
-                ContentsChanged ();
-        }
+               pending_removes.clear ();
+               pending_contents_change = false;
+               ContentsChanged ();
+       }
 
- }
+}
 
- /* *********************************************************************
-  FINDING THINGS
-  **********************************************************************/
+/* *********************************************************************
+FINDING THINGS
+**********************************************************************/
 
 boost::shared_ptr<RegionList>
 Playlist::region_list()
@@ -1879,68 +1870,66 @@ Playlist::regions_at (samplepos_t sample)
        return find_regions_at (sample);
 }
 
- uint32_t
- Playlist::count_regions_at (samplepos_t sample) const
- {
-        RegionReadLock rlock (const_cast<Playlist*>(this));
-        uint32_t cnt = 0;
-
-        for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
-                if ((*i)->covers (sample)) {
-                        cnt++;
-                }
-        }
-
-        return cnt;
- }
+uint32_t
+Playlist::count_regions_at (samplepos_t sample) const
+{
+       RegionReadLock rlock (const_cast<Playlist*>(this));
+       uint32_t cnt = 0;
 
- boost::shared_ptr<Region>
- Playlist::top_region_at (samplepos_t sample)
+       for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
+               if ((*i)->covers (sample)) {
+                       cnt++;
+               }
+       }
 
- {
-        RegionReadLock rlock (this);
-        boost::shared_ptr<RegionList> rlist = find_regions_at (sample);
-        boost::shared_ptr<Region> region;
+       return cnt;
+}
 
-        if (rlist->size()) {
-                RegionSortByLayer cmp;
-                rlist->sort (cmp);
-                region = rlist->back();
-        }
+boost::shared_ptr<Region>
+Playlist::top_region_at (samplepos_t sample)
+{
+       RegionReadLock rlock (this);
+       boost::shared_ptr<RegionList> rlist = find_regions_at (sample);
+       boost::shared_ptr<Region> region;
 
-        return region;
- }
+       if (rlist->size()) {
+               RegionSortByLayer cmp;
+               rlist->sort (cmp);
+               region = rlist->back();
+       }
 
- boost::shared_ptr<Region>
- Playlist::top_unmuted_region_at (samplepos_t sample)
+       return region;
+}
 
- {
-        RegionReadLock rlock (this);
-        boost::shared_ptr<RegionList> rlist = find_regions_at (sample);
+boost::shared_ptr<Region>
+Playlist::top_unmuted_region_at (samplepos_t sample)
+{
+       RegionReadLock rlock (this);
+       boost::shared_ptr<RegionList> rlist = find_regions_at (sample);
 
-        for (RegionList::iterator i = rlist->begin(); i != rlist->end(); ) {
+       for (RegionList::iterator i = rlist->begin(); i != rlist->end(); ) {
 
-                RegionList::iterator tmp = i;
+               RegionList::iterator tmp = i;
 
-                ++tmp;
+               ++tmp;
 
-                if ((*i)->muted()) {
-                        rlist->erase (i);
-                }
+               if ((*i)->muted()) {
+                       rlist->erase (i);
+               }
 
-                i = tmp;
-        }
+               i = tmp;
+       }
 
-        boost::shared_ptr<Region> region;
+       boost::shared_ptr<Region> region;
 
-        if (rlist->size()) {
-                RegionSortByLayer cmp;
-                rlist->sort (cmp);
-                region = rlist->back();
-        }
+       if (rlist->size()) {
+               RegionSortByLayer cmp;
+               rlist->sort (cmp);
+               region = rlist->back();
+       }
 
-        return region;
- }
+       return region;
+}
 
 boost::shared_ptr<RegionList>
 Playlist::find_regions_at (samplepos_t sample)
@@ -2133,212 +2122,208 @@ Playlist::find_next_region (samplepos_t sample, RegionPoint point, int dir)
        return ret;
 }
 
- samplepos_t
- Playlist::find_next_region_boundary (samplepos_t sample, int dir)
- {
-        RegionReadLock rlock (this);
+samplepos_t
+Playlist::find_next_region_boundary (samplepos_t sample, int dir)
+{
+       RegionReadLock rlock (this);
 
-        samplepos_t closest = max_samplepos;
-        samplepos_t ret = -1;
+       samplepos_t closest = max_samplepos;
+       samplepos_t ret = -1;
 
-        if (dir > 0) {
+       if (dir > 0) {
 
-                for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+               for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
 
-                        boost::shared_ptr<Region> r = (*i);
-                        sampleoffset_t distance;
-                        const samplepos_t first_sample = r->first_sample();
-                        const samplepos_t last_sample = r->last_sample();
+                       boost::shared_ptr<Region> r = (*i);
+                       sampleoffset_t distance;
+                       const samplepos_t first_sample = r->first_sample();
+                       const samplepos_t last_sample = r->last_sample();
 
-                        if (first_sample > sample) {
+                       if (first_sample > sample) {
 
-                                distance = first_sample - sample;
+                               distance = first_sample - sample;
 
-                                if (distance < closest) {
-                                        ret = first_sample;
-                                        closest = distance;
-                                }
-                        }
+                               if (distance < closest) {
+                                       ret = first_sample;
+                                       closest = distance;
+                               }
+                       }
 
-                        if (last_sample > sample) {
+                       if (last_sample > sample) {
 
-                                distance = last_sample - sample;
+                               distance = last_sample - sample;
 
-                                if (distance < closest) {
-                                        ret = last_sample;
-                                        closest = distance;
-                                }
-                        }
-                }
+                               if (distance < closest) {
+                                       ret = last_sample;
+                                       closest = distance;
+                               }
+                       }
+               }
 
-        } else {
+       } else {
 
-                for (RegionList::reverse_iterator i = regions.rbegin(); i != regions.rend(); ++i) {
+               for (RegionList::reverse_iterator i = regions.rbegin(); i != regions.rend(); ++i) {
 
-                        boost::shared_ptr<Region> r = (*i);
-                        sampleoffset_t distance;
-                        const samplepos_t first_sample = r->first_sample();
-                        const samplepos_t last_sample = r->last_sample();
+                       boost::shared_ptr<Region> r = (*i);
+                       sampleoffset_t distance;
+                       const samplepos_t first_sample = r->first_sample();
+                       const samplepos_t last_sample = r->last_sample();
 
-                        if (last_sample < sample) {
+                       if (last_sample < sample) {
 
-                                distance = sample - last_sample;
+                               distance = sample - last_sample;
 
-                                if (distance < closest) {
-                                        ret = last_sample;
-                                        closest = distance;
-                                }
-                        }
+                               if (distance < closest) {
+                                       ret = last_sample;
+                                       closest = distance;
+                               }
+                       }
 
-                        if (first_sample < sample) {
+                       if (first_sample < sample) {
 
-                                distance = sample - first_sample;
+                               distance = sample - first_sample;
 
-                                if (distance < closest) {
-                                        ret = first_sample;
-                                        closest = distance;
-                                }
-                        }
-                }
-        }
+                               if (distance < closest) {
+                                       ret = first_sample;
+                                       closest = distance;
+                               }
+                       }
+               }
+       }
 
-        return ret;
- }
+       return ret;
+}
 
+/***********************************************************************/
+
+void
+Playlist::mark_session_dirty ()
+{
+       if (!in_set_state && !holding_state ()) {
+               _session.set_dirty();
+       }
+}
 
- /***********************************************************************/
+void
+Playlist::rdiff (vector<Command*>& cmds) const
+{
+       RegionReadLock rlock (const_cast<Playlist *> (this));
+       Stateful::rdiff (cmds);
+}
 
+void
+Playlist::clear_owned_changes ()
+{
+       RegionReadLock rlock (this);
+       Stateful::clear_owned_changes ();
+}
 
+void
+Playlist::update (const RegionListProperty::ChangeRecord& change)
+{
+       DEBUG_TRACE (DEBUG::Properties, string_compose ("Playlist %1 updates from a change record with %2 adds %3 removes\n",
+                               name(), change.added.size(), change.removed.size()));
 
+       freeze ();
+       /* add the added regions */
+       for (RegionListProperty::ChangeContainer::const_iterator i = change.added.begin(); i != change.added.end(); ++i) {
+               add_region_internal ((*i), (*i)->position());
+       }
+       /* remove the removed regions */
+       for (RegionListProperty::ChangeContainer::const_iterator i = change.removed.begin(); i != change.removed.end(); ++i) {
+               remove_region (*i);
+       }
 
- void
- Playlist::mark_session_dirty ()
- {
-        if (!in_set_state && !holding_state ()) {
-                _session.set_dirty();
-        }
- }
-
- void
- Playlist::rdiff (vector<Command*>& cmds) const
- {
-        RegionReadLock rlock (const_cast<Playlist *> (this));
-        Stateful::rdiff (cmds);
- }
-
- void
- Playlist::clear_owned_changes ()
- {
-        RegionReadLock rlock (this);
-        Stateful::clear_owned_changes ();
- }
-
- void
- Playlist::update (const RegionListProperty::ChangeRecord& change)
- {
-        DEBUG_TRACE (DEBUG::Properties, string_compose ("Playlist %1 updates from a change record with %2 adds %3 removes\n",
-                                                        name(), change.added.size(), change.removed.size()));
-
-        freeze ();
-        /* add the added regions */
-        for (RegionListProperty::ChangeContainer::const_iterator i = change.added.begin(); i != change.added.end(); ++i) {
-                add_region_internal ((*i), (*i)->position());
-        }
-        /* remove the removed regions */
-        for (RegionListProperty::ChangeContainer::const_iterator i = change.removed.begin(); i != change.removed.end(); ++i) {
-                remove_region (*i);
-        }
+       thaw ();
+}
 
-        thaw ();
- }
-
- int
- Playlist::set_state (const XMLNode& node, int version)
- {
-        XMLNode *child;
-        XMLNodeList nlist;
-        XMLNodeConstIterator niter;
-        XMLPropertyConstIterator piter;
-        boost::shared_ptr<Region> region;
-        string region_name;
-        bool seen_region_nodes = false;
-        int ret = 0;
-
-        in_set_state++;
-
-        if (node.name() != "Playlist") {
-                in_set_state--;
-                return -1;
-        }
+int
+Playlist::set_state (const XMLNode& node, int version)
+{
+       XMLNode *child;
+       XMLNodeList nlist;
+       XMLNodeConstIterator niter;
+       XMLPropertyConstIterator piter;
+       boost::shared_ptr<Region> region;
+       string region_name;
+       bool seen_region_nodes = false;
+       int ret = 0;
 
-        freeze ();
+       in_set_state++;
 
-        set_id (node);
+       if (node.name() != "Playlist") {
+               in_set_state--;
+               return -1;
+       }
 
-        std::string name;
-        if (node.get_property (X_("name"), name)) {
-                _name = name;
-                _set_sort_id ();
-        }
+       freeze ();
 
-        /* XXX legacy session: fix up later */
-        node.get_property (X_("orig-diskstream-id"), _orig_track_id);
+       set_id (node);
 
-        node.get_property (X_("orig-track-id"), _orig_track_id);
-        node.get_property (X_("frozen"), _frozen);
+       std::string name;
+       if (node.get_property (X_("name"), name)) {
+               _name = name;
+               _set_sort_id ();
+       }
+
+       /* XXX legacy session: fix up later */
+       node.get_property (X_("orig-diskstream-id"), _orig_track_id);
+
+       node.get_property (X_("orig-track-id"), _orig_track_id);
+       node.get_property (X_("frozen"), _frozen);
 
-        node.get_property (X_("combine-ops"), _combine_ops);
+       node.get_property (X_("combine-ops"), _combine_ops);
 
-        string shared_ids;
-        if (node.get_property (X_("shared-with-ids"), shared_ids)) {
-                if (!shared_ids.empty()) {
+       string shared_ids;
+       if (node.get_property (X_("shared-with-ids"), shared_ids)) {
+               if (!shared_ids.empty()) {
                        vector<string> result;
                        ::split (shared_ids, result, ',');
                        vector<string>::iterator it = result.begin();
                        for (; it != result.end(); ++it) {
                                _shared_with_ids.push_back (PBD::ID(*it));
                        }
-                }
-        }
+               }
+       }
 
-        clear (true);
+       clear (true);
 
-        nlist = node.children();
+       nlist = node.children();
 
-        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
+       for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
 
-                child = *niter;
+               child = *niter;
 
-                if (child->name() == "Region") {
+               if (child->name() == "Region") {
 
-                        seen_region_nodes = true;
+                       seen_region_nodes = true;
 
-                        ID id;
-                        if (!child->get_property ("id", id)) {
-                                error << _("region state node has no ID, ignored") << endmsg;
-                                continue;
-                        }
+                       ID id;
+                       if (!child->get_property ("id", id)) {
+                               error << _("region state node has no ID, ignored") << endmsg;
+                               continue;
+                       }
 
-                        if ((region = region_by_id (id))) {
+                       if ((region = region_by_id (id))) {
 
-                                region->suspend_property_changes ();
+                               region->suspend_property_changes ();
 
-                                if (region->set_state (*child, version)) {
-                                        region->resume_property_changes ();
-                                        continue;
-                                }
+                               if (region->set_state (*child, version)) {
+                                       region->resume_property_changes ();
+                                       continue;
+                               }
 
-                        } else if ((region = RegionFactory::create (_session, *child, true)) != 0) {
-                                region->suspend_property_changes ();
-                        } else {
-                                error << _("Playlist: cannot create region from XML") << endmsg;
+                       } else if ((region = RegionFactory::create (_session, *child, true)) != 0) {
+                               region->suspend_property_changes ();
+                       } else {
+                               error << _("Playlist: cannot create region from XML") << endmsg;
                                return -1;
                        }
 
-                        {
-                                RegionWriteLock rlock (this);
-                                add_region_internal (region, region->position());
-                        }
+                       {
+                               RegionWriteLock rlock (this);
+                               add_region_internal (region, region->position());
+                       }
 
                        region->resume_property_changes ();
 
@@ -2514,13 +2499,12 @@ struct RelayerSort {
  *  regions in the playlist to put the specified region in the appropriate
  *  place.  The actual layering will be fixed up when relayer() happens.
  */
-
 void
 Playlist::set_layer (boost::shared_ptr<Region> region, double new_layer)
 {
        /* Remove the layer we are setting from our region list, and sort it
-       *  using the layer indeces.
-       */
+        *  using the layer indeces.
+        */
 
        RegionList copy = regions.rlist();
        copy.remove (region);
@@ -2569,9 +2553,9 @@ Playlist::relayer ()
        }
 
        /* Build up a new list of regions on each layer, stored in a set of lists
-          each of which represent some period of time on some layer.  The idea
-          is to avoid having to search the entire region list to establish whether
-          each region overlaps another */
+        * each of which represent some period of time on some layer.  The idea
+        * is to avoid having to search the entire region list to establish whether
+        * each region overlaps another */
 
        /* how many pieces to divide this playlist's time up into */
        int const divisions = 512;
@@ -2609,9 +2593,9 @@ Playlist::relayer ()
        for (RegionList::iterator i = copy.begin(); i != copy.end(); ++i) {
 
                /* find the time divisions that this region covers; if there are no regions on the list,
-                  division_size will equal 0 and in this case we'll just say that
-                  start_division = end_division = 0.
-               */
+                * division_size will equal 0 and in this case we'll just say that
+                * start_division = end_division = 0.
+                */
                int start_division = 0;
                int end_division = 0;
 
@@ -2629,8 +2613,8 @@ Playlist::relayer ()
                size_t j = layers.size();
                while (j > 0) {
                        /* try layer j - 1; it can go on if it overlaps no other region
-                          that is already on that layer
-                       */
+                        * that is already on that layer
+                        */
 
                        bool overlap = false;
                        for (int k = start_division; k <= end_division; ++k) {
@@ -2670,17 +2654,17 @@ Playlist::relayer ()
        }
 
        /* It's a little tricky to know when we could avoid calling this; e.g. if we are
-          relayering because we just removed the only region on the top layer, nothing will
-          appear to have changed, but the StreamView must still sort itself out.  We could
-          probably keep a note of the top layer last time we relayered, and check that,
-          but premature optimisation &c...
-       */
+        * relayering because we just removed the only region on the top layer, nothing will
+        * appear to have changed, but the StreamView must still sort itself out.  We could
+        * probably keep a note of the top layer last time we relayered, and check that,
+        * but premature optimisation &c...
+        */
        notify_layering_changed ();
 
        /* This relayer() may have been called as a result of a region removal, in which
-          case we need to setup layering indices to account for the one that has just
-          gone away.
-       */
+        * case we need to setup layering indices to account for the one that has just
+        * gone away.
+        */
        setup_layering_indices (copy);
 }
 
@@ -2766,11 +2750,11 @@ Playlist::uses_source (boost::shared_ptr<const Source> src, bool shallow) const
 
        for (set<boost::shared_ptr<Region> >::const_iterator r = all_regions.begin(); r != all_regions.end(); ++r) {
                /* Note: passing the second argument as false can cause at best
-                  incredibly deep and time-consuming recursion, and at worst
-                  cycles if the user has managed to create cycles of reference
-                  between compound regions. We generally only this during
-                  cleanup, and @param shallow is passed as true.
-               */
+                * incredibly deep and time-consuming recursion, and at worst
+                * cycles if the user has managed to create cycles of reference
+                * between compound regions. We generally only this during
+                * cleanup, and @param shallow is passed as true.
+                */
                if ((*r)->uses_source (src, shallow)) {
                        return true;
                }
@@ -2908,15 +2892,15 @@ Playlist::shuffle (boost::shared_ptr<Region> region, int dir)
 
                                                if ((*next)->position() != region->last_sample() + 1) {
                                                        /* they didn't used to touch, so after shuffle,
-                                                          just have them swap positions.
-                                                       */
+                                                        * just have them swap positions.
+                                                        */
                                                        new_pos = (*next)->position();
                                                } else {
                                                        /* they used to touch, so after shuffle,
-                                                          make sure they still do. put the earlier
-                                                          region where the later one will end after
-                                                          it is moved.
-                                                       */
+                                                        * make sure they still do. put the earlier
+                                                        * region where the later one will end after
+                                                        * it is moved.
+                                                        */
                                                        new_pos = region->position() + (*next)->length();
                                                }
 
@@ -2950,14 +2934,14 @@ Playlist::shuffle (boost::shared_ptr<Region> region, int dir)
                                                samplepos_t new_pos;
                                                if (region->position() != (*prev)->last_sample() + 1) {
                                                        /* they didn't used to touch, so after shuffle,
-                                                          just have them swap positions.
-                                                       */
+                                                        * just have them swap positions.
+                                                        */
                                                        new_pos = region->position();
                                                } else {
                                                        /* they used to touch, so after shuffle,
-                                                          make sure they still do. put the earlier
-                                                          one where the later one will end after
-                                                       */
+                                                        * make sure they still do. put the earlier
+                                                        * one where the later one will end after
+                                                        */
                                                        new_pos = (*prev)->position() + region->length();
                                                }
 
@@ -3159,9 +3143,7 @@ Playlist::combine (const RegionList& r)
 
        boost::shared_ptr<Region> parent_region = RegionFactory::create (sources, plist, true);
 
-       /* now the non-whole-file region that we will actually use in the
-        * playlist
-        */
+       /* now the non-whole-file region that we will actually use in the playlist */
 
        plist.clear ();
        plist.add (Properties::start, 0);
@@ -3171,8 +3153,7 @@ Playlist::combine (const RegionList& r)
 
        boost::shared_ptr<Region> compound_region = RegionFactory::create (parent_region, plist, true);
 
-       /* remove all the selected regions from the current playlist
-        */
+       /* remove all the selected regions from the current playlist */
 
        freeze ();
 
@@ -3180,9 +3161,7 @@ Playlist::combine (const RegionList& r)
                remove_region (*i);
        }
 
-       /* do type-specific stuff with the originals and the new compound
-          region
-       */
+       /* do type-specific stuff with the originals and the new compound region */
 
        post_combine (originals, compound_region);
 
@@ -3217,13 +3196,13 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
        samplepos_t adjusted_end = 0;   // gcc isn't smart enough
 
        /* the leftmost (earliest) edge of the compound region
-          starts at zero in its source, or larger if it
-          has been trimmed or content-scrolled.
-
-          the rightmost (latest) edge of the compound region
-          relative to its source is the starting point plus
-          the length of the region.
-       */
+        * starts at zero in its source, or larger if it
+        * has been trimmed or content-scrolled.
+        *
+        * the rightmost (latest) edge of the compound region
+        * relative to its source is the starting point plus
+        * the length of the region.
+        */
 
        // (2) get all the original regions
 
@@ -3267,9 +3246,7 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
                        samplepos_t pos = original->position();
                        /* make a copy, but don't announce it */
                        original = RegionFactory::create (original, false);
-                       /* the pure copy constructor resets position() to zero,
-                          so fix that up.
-                       */
+                       /* the pure copy constructor resets position() to zero, so fix that up.  */
                        original->set_position (pos);
                }
 
@@ -3284,8 +3261,8 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
                switch (original->coverage (adjusted_start, adjusted_end)) {
                case Evoral::OverlapNone:
                        /* original region does not cover any part
-                          of the current state of the compound region
-                       */
+                        * of the current state of the compound region
+                        */
                        continue;
 
                case Evoral::OverlapInternal:
@@ -3297,15 +3274,11 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
                        break;
 
                case Evoral::OverlapExternal:
-                       /* overlap fully covers original, so leave it
-                          as is
-                       */
+                       /* overlap fully covers original, so leave it as is */
                        break;
 
                case Evoral::OverlapEnd:
-                       /* overlap starts within but covers end,
-                          so trim the front of the region
-                       */
+                       /* overlap starts within but covers end, so trim the front of the region */
                        original->trim_front (adjusted_start);
                        modified_region = true;
                        break;
@@ -3320,8 +3293,7 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
                }
 
                if (move_offset) {
-                       /* fix the position to match any movement of the compound region.
-                        */
+                       /* fix the position to match any movement of the compound region. */
                        original->set_position (original->position() + move_offset);
                        modified_region = true;
                }
@@ -3451,8 +3423,8 @@ void
 Playlist::coalesce_and_check_crossfades (list<Evoral::Range<samplepos_t> > ranges)
 {
        /* XXX: it's a shame that this coalesce algorithm also exists in
-          TimeSelection::consolidate().
-       */
+        * TimeSelection::consolidate().
+        */
 
        /* XXX: xfade: this is implemented in Evoral::RangeList */