try {
fs = boost::dynamic_pointer_cast<AudioFileSource> (
SourceFactory::createWritable (DataType::AUDIO, *_session,
- path, true,
- false, _session->frame_rate()));
+ path, string(), true,
+ false, _session->frame_rate()));
}
catch (failed_constructor& err) {
try {
fs = boost::dynamic_pointer_cast<AudioFileSource> (
SourceFactory::createWritable (DataType::AUDIO, *_session,
- path, true,
- false, _session->frame_rate()));
+ path, string(), true,
+ false, _session->frame_rate()));
}
catch (failed_constructor& err) {
AudioFileSource (Session&, const std::string& path, Source::Flag flags);
/** Constructor to be called for new in-session files */
- AudioFileSource (Session&, const std::string& path, Source::Flag flags,
+ AudioFileSource (Session&, const std::string& path, const std::string& origin, Source::Flag flags,
SampleFormat samp_format, HeaderFormat hdr_format);
/** Constructor to be called for existing in-session files */
void inc_use_count ();
bool removable () const;
+ const std::string& origin() const { return _origin; }
+
static PBD::Signal3<int,std::string,std::string,std::vector<std::string> > AmbiguousFileName;
protected:
FileSource (Session& session, DataType type,
- const std::string& path,
- Source::Flag flags = Source::Flag(0));
+ const std::string& path,
+ const std::string& origin,
+ Source::Flag flags = Source::Flag(0));
FileSource (Session& session, const XMLNode& node, bool must_exist);
std::string _path;
std::string _take_id;
- bool _file_is_new;
- uint16_t _channel;
- bool _within_session;
+ bool _file_is_new;
+ uint16_t _channel;
+ bool _within_session;
+ std::string _origin;
};
} // namespace ARDOUR
class SndFileSource : public AudioFileSource {
public:
/** Constructor to be called for existing external-to-session files */
- SndFileSource (Session&, const std::string& path, int chn, Flag flags);
+ SndFileSource (Session&, const std::string& path, int chn, Flag flags);
/* Constructor to be called for new in-session files */
- SndFileSource (Session&, const std::string& path,
+ SndFileSource (Session&, const std::string& path, const std::string& origin,
SampleFormat samp_format, HeaderFormat hdr_format, nframes_t rate,
Flag flags = SndFileSource::default_writable_flags);
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& path, const std::string& origin,
bool destructive, nframes_t rate, bool announce = true, bool async = false);
static Glib::Cond* PeaksToBuild;
try {
fs = boost::dynamic_pointer_cast<AudioFileSource> (
SourceFactory::createWritable (DataType::AUDIO, _session,
- prop->value(), false, _session.frame_rate()));
+ prop->value(), string(), false, _session.frame_rate()));
}
catch (failed_constructor& err) {
Glib::StaticPrivate<SizedSampleBuffer> thread_interleave_buffer = GLIBMM_STATIC_PRIVATE_INIT;
-/** Constructor used for existing internal-to-session files. */
+/** Constructor used for existing external-to-session files. */
AudioFileSource::AudioFileSource (Session& s, const string& path, Source::Flag flags)
: Source (s, DataType::AUDIO, path, flags)
, AudioSource (s, path)
- , FileSource (s, DataType::AUDIO, path, flags)
+ /* 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 ();
}
}
/** Constructor used for new internal-to-session files. */
-AudioFileSource::AudioFileSource (Session& s, const string& path, Source::Flag flags,
+AudioFileSource::AudioFileSource (Session& s, const string& path, const string& origin, Source::Flag flags,
SampleFormat /*samp_format*/, HeaderFormat /*hdr_format*/)
: Source (s, DataType::AUDIO, path, flags)
, AudioSource (s, path)
- , FileSource (s, DataType::AUDIO, path, flags)
+ , FileSource (s, DataType::AUDIO, path, origin, flags)
{
+ /* note that origin remains empty */
+
if (init (_path, false)) {
throw failed_constructor ();
}
char buf[32];
snprintf (buf, sizeof (buf), "%u", _channel);
root.add_property (X_("channel"), buf);
+ root.add_property (X_("origin"), _origin);
return root;
}
PBD::Signal3<int,std::string,std::string,std::vector<std::string> > FileSource::AmbiguousFileName;
-FileSource::FileSource (Session& session, DataType type, const string& path, Source::Flag flag)
+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)
, _channel (0)
+ , _origin (origin)
{
set_within_session_from_path (path);
}
_channel = 0;
}
+ if ((prop = node.property (X_("origin"))) != 0) {
+ _origin = prop->value();
+ }
+
return 0;
}
try {
nsrcs.push_back (boost::dynamic_pointer_cast<Source> (
SourceFactory::createWritable (region->data_type(), session,
- path, false, session.frame_rate())));
+ path, string(), false, session.frame_rate())));
}
catch (failed_constructor& err) {
}
static bool
-create_mono_sources_for_writing (const vector<string>& new_paths, Session& sess,
- uint samplerate, vector<boost::shared_ptr<Source> >& newfiles,
+create_mono_sources_for_writing (const string& origin,
+ const vector<string>& new_paths,
+ Session& sess, uint samplerate,
+ vector<boost::shared_ptr<Source> >& newfiles,
framepos_t timeline_position)
{
- for (vector<string>::const_iterator i = new_paths.begin(); i != new_paths.end(); ++i)
- {
+ for (vector<string>::const_iterator i = new_paths.begin(); i != new_paths.end(); ++i) {
+
boost::shared_ptr<Source> source;
- try
- {
+ try {
const DataType type = SMFSource::safe_midi_file_extension (*i) ? DataType::MIDI : DataType::AUDIO;
source = SourceFactory::createWritable (type, sess,
- i->c_str(),
- false, // destructive
- samplerate);
+ i->c_str(),
+ origin,
+ false, // destructive
+ samplerate);
}
- catch (const failed_constructor& err)
- {
+
+ catch (const failed_constructor& err) {
error << string_compose (_("Unable to create file %1 during import"), *i) << endmsg;
return false;
}
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 (new_paths, *this, frame_rate(), newfiles, natural_position);
+ status.cancel = !create_mono_sources_for_writing (*p, 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, false, _session.frame_rate()));
+ newpath, string(), 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, as_stub);
return boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createWritable (DataType::AUDIO, *this, path, destructive, frame_rate()));
+ SourceFactory::createWritable (DataType::AUDIO, *this, path, string(), 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, false, frame_rate()));
+ DataType::MIDI, *this, path, string(), false, frame_rate()));
}
try {
fsource = boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createWritable (DataType::AUDIO, *this, buf, false, frame_rate()));
+ SourceFactory::createWritable (DataType::AUDIO, *this, buf, string(), false, frame_rate()));
}
catch (failed_constructor& err) {
SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
: Source(s, DataType::MIDI, path, flags)
, MidiSource(s, path)
- , FileSource(s, DataType::MIDI, path, flags)
+ , FileSource(s, DataType::MIDI, path, string(), flags)
, Evoral::SMF()
, _last_ev_time_beats(0.0)
, _last_ev_time_frames(0)
, _smf_last_read_end (0)
, _smf_last_read_time (0)
{
+ /* note that origin remains empty */
+
if (init(_path, false)) {
throw failed_constructor ();
}
XMLNode&
SMFSource::get_state ()
{
- return MidiSource::get_state();
+ XMLNode& node = MidiSource::get_state();
+ node.add_property (X_("origin"), _origin);
+ return node;
}
int
/** Files created this way are never writable or removable */
SndFileSource::SndFileSource (Session& s, const string& path, int chn, Flag flags)
: Source(s, DataType::AUDIO, path, flags)
+ /* note that the origin of an external file is itself */
, AudioFileSource (s, path, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
{
_channel = chn;
}
/** This constructor is used to construct new files, not open existing ones. */
-SndFileSource::SndFileSource (Session& s, const string& path,
- SampleFormat sfmt, HeaderFormat hf, nframes_t rate, Flag flags)
+SndFileSource::SndFileSource (Session& s, const string& path, const string& origin,
+ SampleFormat sfmt, HeaderFormat hf, nframes_t rate, Flag flags)
: Source(s, DataType::AUDIO, path, flags)
- , AudioFileSource (s, path, flags, sfmt, hf)
+ , AudioFileSource (s, path, origin, flags, sfmt, hf)
{
int fmt = 0;
}
boost::shared_ptr<Source>
-SourceFactory::createWritable (DataType type, Session& s, const std::string& path,
+SourceFactory::createWritable (DataType type, Session& s, const std::string& path, const std::string& origin,
bool destructive, nframes_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,
+ Source* src = new SndFileSource (s, path, origin,
s.config.get_native_file_data_format(),
s.config.get_native_file_header_format(),
rate,