Merging from trunk
[ardour.git] / gtk2_ardour / editor_audio_import.cc
index 0797e291c0bd71b226063a8c31afece9a5eff770..f3e2ee1cb29046bcff46ba32984ba668af326fe2 100644 (file)
 #include <ardour/session.h>
 #include <ardour/audioplaylist.h>
 #include <ardour/audioregion.h>
-#include <ardour/diskstream.h>
-#include <ardour/filesource.h>
-#include <ardour/externalsource.h>
+#include <ardour/audio_diskstream.h>
 #include <ardour/utils.h>
 #include <ardour/audio_track.h>
 #include <ardour/audioplaylist.h>
+#include <ardour/audiofilesource.h>
 
 #include "ardour_ui.h"
 #include "editor.h"
@@ -43,6 +42,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 using namespace Editing;
@@ -74,7 +74,7 @@ Editor::bring_in_external_audio (ImportMode mode, AudioTrack* track, jack_nframe
                return;
        }
 
-       SoundFileOmega sfdb (_("Add existing audio to session"));
+       SoundFileOmega sfdb (_("Add existing audio to session"), session);
        sfdb.set_mode (mode);
 
        switch (sfdb.run()) {
@@ -187,8 +187,9 @@ int
 Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool& check_sample_rate, ImportMode mode, 
                       AudioTrack* track, jack_nframes_t& pos, bool prompt)
 {
-       ExternalSource *source = 0; /* keep g++ quiet */
+       AudioFileSource *source = 0; /* keep g++ quiet */
        AudioRegion::SourceList sources;
+       AudioRegion* region;
        string idspec;
        string linked_path;
        SoundFileInfo finfo;
@@ -202,7 +203,7 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
        /* lets see if we can link it into the session */
        
        linked_path = session->sound_dir();
-       linked_path += PBD::basename (path);
+       linked_path += Glib::path_get_basename (path);
 
        if (link (path.c_str(), linked_path.c_str()) == 0) {
 
@@ -219,7 +220,7 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
 
        string error_msg;
 
-       if (!ExternalSource::get_soundfile_info (path, finfo, error_msg)) {
+       if (!AudioFileSource::get_soundfile_info (path, finfo, error_msg)) {
                error << string_compose(_("Editor: cannot open file \"%1\", (%2)"), selection, error_msg ) << endmsg;
                return 0;
        }
@@ -227,29 +228,29 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
        if (check_sample_rate  && (finfo.samplerate != (int) session->frame_rate())) {
                vector<string> choices;
                
-               choices.push_back (_("Embed it anyway"));
-               
                if (multiple_files) {
+                       choices.push_back (_("Cancel entire import"));
                        choices.push_back (_("Don't embed it"));
                        choices.push_back (_("Embed all without questions"));
-                       choices.push_back (_("Cancel entire import"));
                } else {
                        choices.push_back (_("Cancel"));
                }
+
+               choices.push_back (_("Embed it anyway"));
                
                Gtkmm2ext::Choice rate_choice (
                        string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path),
                        choices, false);
                
                switch (rate_choice.run()) {
-               case 0: /* do it */
-                       break;
+               case 0: /* stop a multi-file import */
                case 1: /* don't import this one */
                        return -1;
                case 2: /* do it, and the rest without asking */
                        check_sample_rate = false;
                        break;
-               case 3: /* stop a multi-file import */
+               case 3: /* do it */
+                       break;
                default:
                        return -2;
                }
@@ -266,7 +267,7 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
                idspec += string_compose(":%1", n);
                
                try {
-                       source = ExternalSource::create (idspec.c_str());
+                       source = AudioFileSource::create (idspec.c_str());
                        sources.push_back(source);
                } 
                
@@ -285,8 +286,8 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
        region_name = PBD::basename_nosuffix (path);
        region_name += "-0";
        
-       AudioRegion* region = new AudioRegion (sources, 0, sources[0]->length(), region_name, 0,
-                                              Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External));
+       region = new AudioRegion (sources, 0, sources[0]->length(), region_name, 0,
+                                 Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External));
        
        input_chan = finfo.channels;