fixes for various bugs including dangling ref to route in session, opening sessions...
[ardour.git] / libs / ardour / import.cc
index dc9819af8ee54d3248ea938492a94f9fc30323ae..2d409e11f78c891a615d9a73bf70092358905c74 100644 (file)
@@ -64,7 +64,7 @@ Session::import_audiofile (import_status& status)
        long n;
        string basepath;
        string sounds_dir;
-       jack_nframes_t so_far;
+       nframes_t so_far;
        char buf[PATH_MAX+1];
        int ret = -1;
        vector<string> new_paths;
@@ -138,7 +138,7 @@ Session::import_audiofile (import_status& status)
                } while ( !goodfile);
 
                try { 
-                       newfiles[n] = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (buf, false, frame_rate()));
+                       newfiles[n] = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (*this, buf, false, frame_rate()));
                }
 
                catch (failed_constructor& err) {
@@ -305,14 +305,18 @@ Session::sample_rate_convert (import_status& status, string infile, string& outf
        sf_count_t  input_count = 0;
 
        SNDFILE* in = sf_open(infile.c_str(), SFM_READ, &sf_info);
+       if (!in) {
+               error << string_compose(_("Import/SRC: could not open input file: %1"), outfile) << endmsg;
+               return false;
+       }
        sf_count_t total_input_frames = sf_info.frames;
        
        outfile = build_tmp_convert_name(infile);
        SNDFILE* out = sf_open(outfile.c_str(), SFM_RDWR, &sf_info);
-       if(!out) {
-               error << string_compose(_("Import: could not open temp file: %1"), outfile) << endmsg;
-               return false;
-       }
+       if (!out) {
+               error << string_compose(_("Import/SRC: could not open output file: %1"), outfile) << endmsg;
+               return false;
+       }
        
        sf_seek (in, 0, SEEK_SET) ;
        sf_seek (out, 0, SEEK_SET) ;
@@ -371,8 +375,6 @@ Session::sample_rate_convert (import_status& status, string infile, string& outf
        sf_close(in);
        sf_close(out);
 
-       status.done = true;
-
        if (status.cancel) {
                return false;
        } else {