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
try {
fs = boost::dynamic_pointer_cast<AudioFileSource> (
SourceFactory::createWritable (DataType::AUDIO, *_session,
- path, string(), true,
+ path, true,
false, _session->frame_rate()));
}
try {
fs = boost::dynamic_pointer_cast<AudioFileSource> (
SourceFactory::createWritable (DataType::AUDIO, *_session,
- path, string(), true,
+ path, true,
false, _session->frame_rate()));
}
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) {
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);
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) {
/* 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 ();
}
AudioFileSource::setup_peakfile ()
{
if (!(_flags & NoPeakFile)) {
- return initialize_peakfile (_file_is_new, _path);
+ return initialize_peakfile (_origin.empty(), _path);
} else {
return 0;
}
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)
}
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;
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) {
}
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)
source = SourceFactory::createWritable (type, sess,
i->c_str(),
- origin,
false, // destructive
samplerate);
}
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
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);
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 */
return boost::dynamic_pointer_cast<SMFSource> (
SourceFactory::createWritable (
- DataType::MIDI, *this, path, string(), false, frame_rate()));
+ DataType::MIDI, *this, path, false, frame_rate()));
}
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) {
}
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 {
}
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