Remove unused variable and the accessor methods for it from ARDOUR_UI
[ardour.git] / gtk2_ardour / editor_audio_import.cc
index df737429bdbe9206473fb3736f24060889c7ffd7..2eb8b9140a08cd2801d3f088b038ce439be55b31 100644 (file)
 
 */
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <unistd.h>
+
 #include <pbd/pthread_utils.h>
 #include <pbd/basename.h>
 #include <pbd/shortpath.h>
@@ -258,7 +263,7 @@ Editor::import_sndfile (vector<ustring> paths, ImportMode mode, AudioTrack* trac
        /* import thread finished - see if we should build a new track */
        
        if (!import_status.new_regions.empty()) {
-               boost::shared_ptr<AudioRegion> region (import_status.new_regions.front());
+               boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(import_status.new_regions.front());
                finish_bringing_in_audio (region, region->n_channels(), region->n_channels(), track, pos, mode);
        }
 
@@ -294,7 +299,7 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
                linked_path += Glib::path_get_basename (path);
                
                if (link (path.c_str(), linked_path.c_str()) == 0) {
-                       
+
                        /* there are many reasons why link(2) might have failed.
                           but if it succeeds, we now have a link in the
                           session sound dir that will protect against
@@ -302,6 +307,21 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
                        */
                        
                        path = linked_path;
+
+               } else {
+
+                       /* one possible reason is that its already linked */
+
+                       if (errno == EEXIST) {
+                               struct stat sb;
+
+                               if (stat (linked_path.c_str(), &sb) == 0) {
+                                       if (sb.st_nlink > 1) { // its a hard link, assume its the one we want
+                                               path = linked_path;
+                                       }
+                               }
+                       }
+
                }
                
                /* note that we temporarily truncated _id at the colon */
@@ -382,7 +402,7 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
 
                                if ((s = session->source_by_path_and_channel (path, n)) == 0) {
                                        source = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable 
-                                                                                              (*session, path,  n,
+                                                                                              (DataType::AUDIO, *session, path,  n,
                                                                                                (mode == ImportAsTapeTrack ? 
                                                                                                 AudioFileSource::Destructive : 
                                                                                                 AudioFileSource::Flag (0))));
@@ -416,7 +436,7 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
                                                                                  Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External)));
 
        if (Config->get_output_auto_connect() & AutoConnectMaster) {
-               output_chan = (session->master_out() ? session->master_out()->n_inputs() : input_chan);
+               output_chan = (session->master_out() ? session->master_out()->n_inputs().n_audio() : input_chan);
        } else {
                output_chan = input_chan;
        }