- sort (relevant_layers.begin(), relevant_layers.end());
-
- for (vector<uint32_t>::iterator l = relevant_layers.begin(); l != relevant_layers.end(); ++l) {
-
- vector<boost::shared_ptr<Region> > r (relevant_regions[*l]);
- vector<boost::shared_ptr<Crossfade> >& x (relevant_xfades[*l]);
-
-
- for (vector<boost::shared_ptr<Region> >::iterator i = r.begin(); i != r.end(); ++i) {
- boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(*i);
- DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("read from region %1\n", ar->name()));
- assert(ar);
- ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n, read_frames, skip_frames);
- _read_data_count += ar->read_data_count();
- }
-
- for (vector<boost::shared_ptr<Crossfade> >::iterator i = x.begin(); i != x.end(); ++i) {
- (*i)->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n);
-
- /* don't JACK up _read_data_count, since its the same data as we just
- read from the regions, and the OS should handle that for us.
- */
- }
- }
-
- delete rlist;
- return ret;
-}
-
-
-void
-AudioPlaylist::remove_dependents (boost::shared_ptr<Region> region)
-{
- boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
-
- if (in_set_state) {
- return;
- }
-
- if (r == 0) {
- fatal << _("programming error: non-audio Region passed to remove_overlap in audio playlist")
- << endmsg;
- return;
- }
-
- for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ) {
-
- if ((*i)->involves (r)) {
- i = _crossfades.erase (i);
- } else {
- ++i;
- }
- }
-}
-
-
-void
-AudioPlaylist::flush_notifications (bool from_undo)
-{
- Playlist::flush_notifications (from_undo);
-
- if (in_flush) {
- return;
- }
-
- in_flush = true;
-
- Crossfades::iterator a;
- for (a = _pending_xfade_adds.begin(); a != _pending_xfade_adds.end(); ++a) {
- NewCrossfade (*a); /* EMIT SIGNAL */
- }
-
- _pending_xfade_adds.clear ();
-
- in_flush = false;
-}
-
-void
-AudioPlaylist::refresh_dependents (boost::shared_ptr<Region> r)
-{
- boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(r);
- set<boost::shared_ptr<Crossfade> > updated;
-
- if (ar == 0) {
- return;
- }
-
- for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end();) {
-
- Crossfades::iterator tmp;
-
- tmp = x;
- ++tmp;
-
- /* only update them once */
-
- if ((*x)->involves (ar)) {
-
- pair<set<boost::shared_ptr<Crossfade> >::iterator, bool> const u = updated.insert (*x);
-
- if (u.second) {
- /* x was successfully inserted into the set, so it has not already been updated */
- try {
- (*x)->refresh ();
- }
-
- catch (Crossfade::NoCrossfadeHere& err) {
- // relax, Invalidated during refresh
- }
- }
- }
-
- x = tmp;
- }
-}
-
-void
-AudioPlaylist::finalize_split_region (boost::shared_ptr<Region> o, boost::shared_ptr<Region> l, boost::shared_ptr<Region> r)
-{
- boost::shared_ptr<AudioRegion> orig = boost::dynamic_pointer_cast<AudioRegion>(o);
- boost::shared_ptr<AudioRegion> left = boost::dynamic_pointer_cast<AudioRegion>(l);
- boost::shared_ptr<AudioRegion> right = boost::dynamic_pointer_cast<AudioRegion>(r);
-
- for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end();) {
- Crossfades::iterator tmp;
- tmp = x;
- ++tmp;
-
- boost::shared_ptr<Crossfade> fade;
-
- if ((*x)->_in == orig) {
- if (! (*x)->covers(right->position())) {
- fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, left, (*x)->_out));
- } else {
- // Overlap, the crossfade is copied on the left side of the right region instead
- fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, right, (*x)->_out));
- }
- }
-
- if ((*x)->_out == orig) {
- if (! (*x)->covers(right->position())) {
- fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, (*x)->_in, right));
- } else {
- // Overlap, the crossfade is copied on the right side of the left region instead
- fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, (*x)->_in, left));
- }
- }
-
- if (fade) {
- _crossfades.remove (*x);
- add_crossfade (fade);
- }
- x = tmp;
- }
-}
-
-void
-AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
-{
- boost::shared_ptr<AudioRegion> other;
- boost::shared_ptr<AudioRegion> region;
- boost::shared_ptr<AudioRegion> top;
- boost::shared_ptr<AudioRegion> bottom;
- boost::shared_ptr<Crossfade> xfade;
- RegionList* touched_regions = 0;
-
- if (in_set_state || in_partition) {
- return;
- }
-
- if ((region = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
- fatal << _("programming error: non-audio Region tested for overlap in audio playlist")
- << endmsg;
- return;
- }
-
- if (!norefresh) {
- refresh_dependents (r);
- }
-
-
- if (!_session.config.get_auto_xfade()) {
- return;
- }
-
- for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
- other = boost::dynamic_pointer_cast<AudioRegion> (*i);
-
- if (other == region) {
- continue;
- }
-
- if (other->muted() || region->muted()) {
- continue;
- }