add new SMFSource constructor to be used for existing-external files. Fixes #5919. Needs merging with CC
This commit is contained in:
parent
16a8762dd4
commit
f5276a104c
|
@ -36,9 +36,11 @@ template<typename T> class MidiRingBuffer;
|
|||
/** Standard Midi File (Type 0) Source */
|
||||
class SMFSource : public MidiSource, public FileSource, public Evoral::SMF {
|
||||
public:
|
||||
/** Constructor for new internal-to-session files */
|
||||
SMFSource (Session& session, const std::string& path, Source::Flag flags);
|
||||
|
||||
/** Constructor for existing external-to-session files */
|
||||
SMFSource (Session& session, const std::string& path,
|
||||
Source::Flag flags = Source::Flag(0));
|
||||
SMFSource (Session& session, const std::string& path);
|
||||
|
||||
/** Constructor for existing in-session files */
|
||||
SMFSource (Session& session, const XMLNode&, bool must_exist = false);
|
||||
|
|
|
@ -82,6 +82,39 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
|
|||
_open = true;
|
||||
}
|
||||
|
||||
/** Constructor used for external-to-session files. File must exist. */
|
||||
SMFSource::SMFSource (Session& s, const string& path)
|
||||
: Source(s, DataType::MIDI, path, Source::Flag (0))
|
||||
, MidiSource(s, path, Source::Flag (0))
|
||||
, FileSource(s, DataType::MIDI, path, string(), Source::Flag (0))
|
||||
, 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 ();
|
||||
}
|
||||
|
||||
assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS));
|
||||
existence_check ();
|
||||
|
||||
/* file is not opened until write */
|
||||
|
||||
if (_flags & Writable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (open (_path)) {
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
_open = true;
|
||||
}
|
||||
|
||||
/** Constructor used for existing internal-to-session files. */
|
||||
SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist)
|
||||
: Source(s, node)
|
||||
|
|
|
@ -272,7 +272,7 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
|||
|
||||
} else if (type == DataType::MIDI) {
|
||||
|
||||
boost::shared_ptr<SMFSource> src (new SMFSource (s, path, SMFSource::Flag(0)));
|
||||
boost::shared_ptr<SMFSource> src (new SMFSource (s, path));
|
||||
src->load_model (true, true);
|
||||
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
|
||||
// boost_debug_shared_ptr_mark_interesting (src, "Source");
|
||||
|
|
Loading…
Reference in New Issue
Block a user