+ /* destructive tracks have a single, never changing region */
+
+ if (destructive()) {
+
+ /* send a signal that any UI can pick up to do the right thing. there is
+ a small problem here in that a UI may need the peak data to be ready
+ for the data that was recorded and this isn't interlocked with that
+ process. this problem is deferred to the UI.
+ */
+
+ pl->LayeringChanged(); // XXX this may not get the UI to do the right thing
+ return;
+ }
+
+ string whole_file_region_name;
+ whole_file_region_name = region_name_from_path (afs->name(), true);
+
+ /* Register a new region with the Session that
+ describes the entire source. Do this first
+ so that any sub-regions will obviously be
+ children of this one (later!)
+ */
+
+ try {
+ PropertyList plist;
+
+ plist.add (Properties::start, afs->last_capture_start_frame());
+ plist.add (Properties::length, afs->length(0));
+ plist.add (Properties::name, whole_file_region_name);
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
+ rx->set_automatic (true);
+ rx->set_whole_file (true);
+
+ region = boost::dynamic_pointer_cast<AudioRegion> (rx);
+ region->special_set_position (afs->natural_position());
+ }
+
+
+ catch (failed_constructor& err) {
+ error << string_compose(_("%1: could not create region for complete audio file"), _name) << endmsg;
+ /* XXX what now? */
+ }
+
+ pl->clear_changes ();
+ pl->set_capture_insertion_in_progress (true);
+ pl->freeze ();
+
+ const framepos_t preroll_off = _session.preroll_record_trim_len ();
+ framecnt_t buffer_position = afs->last_capture_start_frame ();
+ CaptureInfos::const_iterator ci;
+
+ for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
+
+ string region_name;
+
+ RegionFactory::region_name (region_name, whole_file_region_name, false);
+
+ DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1 capture bufpos %5 start @ %2 length %3 add new region %4\n",
+ _name, (*ci)->start, (*ci)->frames, region_name, buffer_position));
+
+ try {
+
+ PropertyList plist;
+
+ plist.add (Properties::start, buffer_position);
+ plist.add (Properties::length, (*ci)->frames);
+ plist.add (Properties::name, region_name);
+
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
+ region = boost::dynamic_pointer_cast<AudioRegion> (rx);
+ if (preroll_off > 0) {
+ region->trim_front (buffer_position + preroll_off);
+ }
+ }
+
+ catch (failed_constructor& err) {
+ error << _("AudioDiskstream: could not create region for captured audio!") << endmsg;
+ continue; /* XXX is this OK? */
+ }
+
+ pl->add_region (region, (*ci)->start + preroll_off, 1, _disk_writer->non_layered());
+ pl->set_layer (region, DBL_MAX);
+
+ buffer_position += (*ci)->frames;
+ }
+
+ pl->thaw ();
+ pl->set_capture_insertion_in_progress (false);
+ _session.add_command (new StatefulDiffCommand (pl));