fix up escaping of strings in TOC files (suggested by andreas ruge)
[ardour.git] / libs / ardour / audio_playlist.cc
index 70cd9ec3f5de0f837b4d4210e705a1844d6990be..56f2c4fe83bf3a0cd0c76eda6d1be3da3d427b30 100644 (file)
@@ -113,6 +113,8 @@ AudioPlaylist::AudioPlaylist (Session& session, const XMLNode& node, bool hidden
                throw failed_constructor();
        }
        in_set_state--;
+
+       relayer ();
 }
 
 AudioPlaylist::AudioPlaylist (Session& session, string name, bool hidden)
@@ -286,16 +288,10 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, fr
        Glib::RecMutex::Lock rm (region_lock);
 
        framepos_t const end = start + cnt - 1;
-       framecnt_t read_frames = 0;
-       framecnt_t skip_frames = 0;
-       _read_data_count = 0;
-
-       _read_data_count = 0;
 
-       RegionList* rlist = regions_to_read (start, start+cnt);
+       boost::shared_ptr<RegionList> rlist = regions_to_read (start, start+cnt);
 
        if (rlist->empty()) {
-               delete rlist;
                return cnt;
        }
 
@@ -313,12 +309,14 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, fr
        DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("Checking %1 xfades\n", _crossfades.size()));
 
        for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) {
-               DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("%1 check xfade between %2 and %3 ...\n",
-                                                                  name(), (*i)->out()->name(), (*i)->in()->name()));
+               DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("%1 check xfade between %2 and %3 ... [ %4 ... %5 | %6 ... %7]\n",
+                                                                  name(), (*i)->out()->name(), (*i)->in()->name(), 
+                                                                  (*i)->first_frame(), (*i)->last_frame(),
+                                                                  start, end));
                if ((*i)->coverage (start, end) != OverlapNone) {
                        relevant_xfades[(*i)->upper_layer()].push_back (*i);
-                       DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("\t\txfade is relevant, place on layer %1\n",
-                                                                          (*i)->upper_layer()));
+                       DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("\t\txfade is relevant (coverage = %2), place on layer %1\n",
+                                                                          (*i)->upper_layer(), enum_2_string ((*i)->coverage (start, end))));
                }
        }
 
@@ -345,21 +343,15 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, fr
                        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();
+                       ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n);
                }
 
                for (vector<boost::shared_ptr<Crossfade> >::iterator i = x.begin(); i != x.end(); ++i) {
                         DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("read from xfade between %1 & %2\n", (*i)->out()->name(), (*i)->in()->name()));
                        (*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;
 }
 
@@ -498,7 +490,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
        boost::shared_ptr<AudioRegion> top;
        boost::shared_ptr<AudioRegion> bottom;
        boost::shared_ptr<Crossfade>   xfade;
-       RegionList*  touched_regions = 0;
+       boost::shared_ptr<RegionList> touched_regions;
 
        if (in_set_state || in_partition) {
                return;
@@ -549,8 +541,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
 
                OverlapType c = top->coverage (bottom->position(), bottom->last_frame());
 
-               delete touched_regions;
-               touched_regions = 0;
+               touched_regions.reset ();
 
                try {
                        framecnt_t xfade_length;
@@ -581,7 +572,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
 
                                if (top_region_at (top->first_frame()) == top) {
 
-                                       xfade = boost::shared_ptr<Crossfade> (new Crossfade (top, bottom, xfade_length, top->first_frame(), StartOfIn));
+                                       xfade = boost::shared_ptr<Crossfade> (new Crossfade (top, bottom, xfade_length, StartOfIn));
+                                       xfade->set_position (top->first_frame());
                                        add_crossfade (xfade);
                                }
 
@@ -592,7 +584,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
                                           would cover it).
                                        */
 
-                                       xfade = boost::shared_ptr<Crossfade> (new Crossfade (bottom, top, xfade_length, top->last_frame() - xfade_length, EndOfOut));
+                                       xfade = boost::shared_ptr<Crossfade> (new Crossfade (bottom, top, xfade_length, EndOfOut));
+                                       xfade->set_position (top->last_frame() - xfade_length);
                                        add_crossfade (xfade);
                                }
                                break;
@@ -661,8 +654,6 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
                }
 
        }
-
-       delete touched_regions;
 }
 
 void