+ boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (*x);
+
+ if (sources.size() > 1 && disposition == ImportDistinctChannels) {
+
+ /* generate a per-channel region name so that things work as
+ * intended
+ */
+
+ string path;
+
+ if (fs) {
+ region_name = basename_nosuffix (fs->path());
+ } else {
+ region_name = (*x)->name();
+ }
+
+ switch (sources.size()) {
+ /* zero and one channel handled
+ by previous if() condition
+ */
+ case 2:
+ if (n == 0) {
+ region_name += "-L";
+ } else {
+ region_name += "-R";
+ }
+ break;
+ default:
+ region_name += (char) '-';
+ region_name += (char) ('1' + n);
+ break;
+ }
+
+ } else {
+ if (fs) {
+ region_name = region_name_from_path (fs->path(), false, false, sources.size(), n);
+ } else{
+ region_name = (*x)->name();
+ }
+ }
+
+ PropertyList plist;
+
+ /* Fudge region length to ensure it is non-zero; make it 1 beat at 120bpm
+ for want of a better idea. It can't be too small, otherwise if this
+ is a MIDI region the conversion from frames -> beats -> frames will
+ round it back down to 0 again.
+ */
+ framecnt_t len = (*x)->length (pos);
+ if (len == 0) {
+ len = (60.0 / 120.0) * _session->frame_rate ();
+ }
+
+ plist.add (ARDOUR::Properties::start, 0);
+ plist.add (ARDOUR::Properties::length, len);
+ plist.add (ARDOUR::Properties::name, region_name);
+ plist.add (ARDOUR::Properties::layer, 0);
+ plist.add (ARDOUR::Properties::whole_file, true);
+ plist.add (ARDOUR::Properties::external, true);
+
+ boost::shared_ptr<Region> r = RegionFactory::create (just_one, plist);
+
+ if (use_timestamp && boost::dynamic_pointer_cast<AudioRegion>(r)) {
+ boost::dynamic_pointer_cast<AudioRegion>(r)->special_set_position((*x)->natural_position());
+ }