fix up some confusion with filesources' _origin and _file_is_new members. if _origin is set, it means that the file is "external" to the session (aka "embedded") and for some purposes this is more significant than _file_is_new. rename SourceFactory::createReadable() to ::createExternal() to more clearly indicate its purpose; remove never-supplied "origin" argument from SourceFactor::createWritable(). Fixes problems caused by 864ce8f0
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user