fix up some confusion with filesources' _origin and _file_is_new members. if _origin...
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 30 Mar 2013 18:02:26 +0000 (14:02 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 30 Mar 2013 18:02:26 +0000 (14:02 -0400)
12 files changed:
gtk2_ardour/editor_audio_import.cc
gtk2_ardour/editor_export_audio.cc
gtk2_ardour/sfdb_ui.cc
libs/ardour/ardour/source_factory.h
libs/ardour/audio_diskstream.cc
libs/ardour/audiofilesource.cc
libs/ardour/file_source.cc
libs/ardour/filter.cc
libs/ardour/import.cc
libs/ardour/midi_source.cc
libs/ardour/session.cc
libs/ardour/source_factory.cc

index 3a120c709fd2445c3c0936dc7bc2d928ad550339..31ccdb7a533df0c93581feed8f6f5bb7317575ce 100644 (file)
@@ -612,7 +612,7 @@ Editor::embed_sndfiles (vector<string> paths, bool multifile,
                                if ((s = _session->source_by_path_and_channel (path, n)) == 0) {
 
                                        source = boost::dynamic_pointer_cast<AudioFileSource> (
-                                               SourceFactory::createReadable (DataType::AUDIO, *_session,
+                                               SourceFactory::createExternal (DataType::AUDIO, *_session,
                                                                               path, n,
                                                                               (mode == ImportAsTapeTrack
                                                                                ? Source::Destructive
index 78e7674042b69da0d399dceff5dde01ba45026f2..877a39e7730478303b4898071a02230eb9583792 100644 (file)
@@ -274,7 +274,7 @@ Editor::write_region (string path, boost::shared_ptr<AudioRegion> region)
                        try {
                                fs = boost::dynamic_pointer_cast<AudioFileSource> (
                                        SourceFactory::createWritable (DataType::AUDIO, *_session,
-                                                                      path, string(), true,
+                                                                      path, true,
                                                                       false, _session->frame_rate()));
                        }
 
@@ -413,7 +413,7 @@ Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list
                try {
                        fs = boost::dynamic_pointer_cast<AudioFileSource> (
                                SourceFactory::createWritable (DataType::AUDIO, *_session,
-                                                              path, string(), true,
+                                                              path, true,
                                                               false, _session->frame_rate()));
                }
 
index 20c2875d9cfde03239816184dcff2544bb9ac00f..3383cf3ff9d9d380e54bf2796e2fdbf8b7bcd60f 100644 (file)
@@ -340,9 +340,9 @@ SoundFileBox::audition ()
        for (int n = 0; n < sf_info.channels; ++n) {
                try {
                        afs = boost::dynamic_pointer_cast<AudioFileSource> (
-                                       SourceFactory::createReadable (DataType::AUDIO, *_session,
-                                                       path, n, Source::Flag (0), false));
-
+                               SourceFactory::createExternal (DataType::AUDIO, *_session,
+                                                              path, n, Source::Flag (0), false));
+                       
                        srclist.push_back(afs);
 
                } catch (failed_constructor& err) {
index 387a40aff32326443a7d0d9e775f99050d0b7659..c94f783b445f51fba4b9fa1505459e3e42bb1f9b 100644 (file)
@@ -46,14 +46,14 @@ class SourceFactory {
        static boost::shared_ptr<Source> createSilent (Session&, const XMLNode& node,
                                                       framecnt_t nframes, float sample_rate);
 
-       static boost::shared_ptr<Source> createReadable
+       static boost::shared_ptr<Source> createExternal
                (DataType type, Session&,
-                const std::string& path,
+                const std::string& path, 
                 int chn, Source::Flag flags, bool announce = true, bool async = false);
 
        static boost::shared_ptr<Source> createWritable
                (DataType type, Session&,
-                const std::string& path, const std::string& origin,
+                const std::string& path, 
                 bool destructive, framecnt_t rate, bool announce = true, bool async = false);
 
 
index 24687c766f242fff2e1d8181107c9923ab539f1a..c302e06681ca05f394b14c7451eafafb6e27501b 100644 (file)
@@ -2168,7 +2168,7 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
                                fs = boost::dynamic_pointer_cast<AudioFileSource> (
                                        SourceFactory::createWritable (
                                                DataType::AUDIO, _session,
-                                               prop->value(), string(), false, _session.frame_rate()));
+                                               prop->value(), false, _session.frame_rate()));
                        }
 
                        catch (failed_constructor& err) {
index 2486d45ca1c21cd13983af534a4ea540fb2a9e2d..e7d69d2258d631647361a2faac3f9be0514c7274 100644 (file)
@@ -95,8 +95,6 @@ AudioFileSource::AudioFileSource (Session& s, const string& path, Source::Flag f
           /* note that external files have their own path as "origin" */
        , FileSource (s, DataType::AUDIO, path, path, flags)
 {
-        /* note that origin remains empty */
-
        if (init (_path, true)) {
                throw failed_constructor ();
        }
@@ -322,7 +320,7 @@ int
 AudioFileSource::setup_peakfile ()
 {
        if (!(_flags & NoPeakFile)) {
-               return initialize_peakfile (_file_is_new, _path);
+               return initialize_peakfile (_origin.empty(), _path);
        } else {
                return 0;
        }
index 8c207feea73d4d65b80e7be0cb2292791beb7a7e..e3a442b0de79fa9fda9a86131a0b7400c5232c1f 100644 (file)
@@ -55,8 +55,8 @@ PBD::Signal3<int,std::string,std::string,std::vector<std::string> > FileSource::
 
 FileSource::FileSource (Session& session, DataType type, const string& path, const string& origin, Source::Flag flag)
        : Source(session, type, path, flag)
-       , _path(path)
-       , _file_is_new(true)
+       , _path (path)
+       , _file_is_new (!origin.empty()) // origin empty => new file VS. origin !empty => new file
        , _channel (0)
         , _origin (origin)
         , _open (false)
@@ -133,11 +133,12 @@ FileSource::init (const string& pathstr, bool must_exist)
        }
 
        set_within_session_from_path (_path);
-       
         _name = Glib::path_get_basename (_path);
 
-       if (_file_is_new && must_exist) {
-               return -1;
+       if (must_exist) {
+               if (!Glib::file_test (_path, Glib::FILE_TEST_EXISTS)) {
+                       throw MissingSource (pathstr, _type);
+               }
        }
 
        return 0;
index 67aa840cad4b8da26ab5c3475596f952879b4254..b085ec946b3d09305d52b3b8871e8a05a29f1e30 100644 (file)
@@ -71,7 +71,7 @@ Filter::make_new_sources (boost::shared_ptr<Region> region, SourceList& nsrcs, s
                try {
                        nsrcs.push_back (boost::dynamic_pointer_cast<Source> (
                                SourceFactory::createWritable (region->data_type(), session,
-                                                              path, string(), false, session.frame_rate())));
+                                                              path, false, session.frame_rate())));
                }
 
                catch (failed_constructor& err) {
index 07c7958ad79a4b1d0268805c22c7ffd93fa3fe62..047b46f55305d5ff68d3beda87e0623ce60abe7d 100644 (file)
@@ -214,8 +214,7 @@ map_existing_mono_sources (const vector<string>& new_paths, Session& /*sess*/,
 }
 
 static bool
-create_mono_sources_for_writing (const string& origin,
-                                 const vector<string>& new_paths,
+create_mono_sources_for_writing (const vector<string>& new_paths,
                                  Session& sess, uint samplerate,
                                  vector<boost::shared_ptr<Source> >& newfiles,
                                  framepos_t timeline_position)
@@ -229,7 +228,6 @@ create_mono_sources_for_writing (const string& origin,
 
                        source = SourceFactory::createWritable (type, sess,
                                                                i->c_str(),
-                                                               origin,
                                                                false, // destructive
                                                                samplerate);
                }
@@ -527,7 +525,7 @@ Session::import_files (ImportStatus& status)
                        fatal << "THIS IS NOT IMPLEMENTED YET, IT SHOULD NEVER GET CALLED!!! DYING!" << endmsg;
                        status.cancel = !map_existing_mono_sources (new_paths, *this, frame_rate(), newfiles, this);
                } else {
-                       status.cancel = !create_mono_sources_for_writing (*p, new_paths, *this, frame_rate(), newfiles, natural_position);
+                       status.cancel = !create_mono_sources_for_writing (new_paths, *this, frame_rate(), newfiles, natural_position);
                }
 
                // copy on cancel/failure so that any files that were created will be removed below
index 30dc23f998ac1bca92709b7eb0d682e84d8ea21e..124d3f7c9bf11b4443befe29d068bbce86bcf074 100644 (file)
@@ -355,7 +355,7 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica
 
        boost::shared_ptr<MidiSource> newsrc = boost::dynamic_pointer_cast<MidiSource>(
                SourceFactory::createWritable(DataType::MIDI, _session,
-                                             newpath, string(), false, _session.frame_rate()));
+                                             newpath, false, _session.frame_rate()));
 
        newsrc->set_timeline_position(_timeline_position);
        newsrc->copy_interpolation_from (this);
index cb743cca62d9b8c302dd29aa595e348eba529617..75303251d83138d824ee32b574063e389159779c 100644 (file)
@@ -3381,7 +3381,7 @@ Session::create_audio_source_for_session (size_t n_chans, string const & n, uint
        const string path    = new_source_path_from_name(DataType::AUDIO, name);
 
        return boost::dynamic_pointer_cast<AudioFileSource> (
-               SourceFactory::createWritable (DataType::AUDIO, *this, path, string(), destructive, frame_rate()));
+               SourceFactory::createWritable (DataType::AUDIO, *this, path, destructive, frame_rate()));
 }
 
 /** Return a unique name based on \a base for a new internal MIDI source */
@@ -3457,7 +3457,7 @@ Session::create_midi_source_for_session (Track* track, string const & n)
 
        return boost::dynamic_pointer_cast<SMFSource> (
                SourceFactory::createWritable (
-                       DataType::MIDI, *this, path, string(), false, frame_rate()));
+                       DataType::MIDI, *this, path, false, frame_rate()));
 }
 
 
@@ -4009,7 +4009,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
 
                try {
                        fsource = boost::dynamic_pointer_cast<AudioFileSource> (
-                               SourceFactory::createWritable (DataType::AUDIO, *this, buf, string(), false, frame_rate()));
+                               SourceFactory::createWritable (DataType::AUDIO, *this, buf, false, frame_rate()));
                }
 
                catch (failed_constructor& err) {
index da5980599d989f3530224de70d47b10ba4e967ef..5e1a7d40d90507bf13cf57ffeaea36ea87412677 100644 (file)
@@ -218,11 +218,11 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
 }
 
 boost::shared_ptr<Source>
-SourceFactory::createReadable (DataType type, Session& s, const string& path,
+SourceFactory::createExternal (DataType type, Session& s, const string& path,
                               int chn, Source::Flag flags, bool announce, bool defer_peaks)
 {
        if (type == DataType::AUDIO) {
-
+               
                if (!(flags & Destructive)) {
 
                        try {
@@ -291,19 +291,19 @@ SourceFactory::createReadable (DataType type, Session& s, const string& path,
 }
 
 boost::shared_ptr<Source>
-SourceFactory::createWritable (DataType type, Session& s, const std::string& path, const std::string& origin,
+SourceFactory::createWritable (DataType type, Session& s, const std::string& path, 
                               bool destructive, framecnt_t rate, bool announce, bool defer_peaks)
 {
        /* this might throw failed_constructor(), which is OK */
 
        if (type == DataType::AUDIO) {
-               Source* src = new SndFileSource (s, path, origin,
-                               s.config.get_native_file_data_format(),
-                               s.config.get_native_file_header_format(),
-                               rate,
-                               (destructive
-                                       ? Source::Flag (SndFileSource::default_writable_flags | Source::Destructive)
-                                : SndFileSource::default_writable_flags));
+               Source* src = new SndFileSource (s, path, string(),
+                                                s.config.get_native_file_data_format(),
+                                                s.config.get_native_file_header_format(),
+                                                rate,
+                                                (destructive
+                                                 ? Source::Flag (SndFileSource::default_writable_flags | Source::Destructive)
+                                                 : SndFileSource::default_writable_flags));
 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
                // boost_debug_shared_ptr_mark_interesting (src, "Source");
 #endif