remove _file_path member from Evoral::SMF
This commit is contained in:
parent
ced4378d09
commit
d263cf7ded
@ -417,14 +417,14 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info << string_compose (_("Track %1 of %2 contained no usable MIDI data"), i, source->file_path()) << endmsg;
|
info << string_compose (_("Track %1 of %2 contained no usable MIDI data"), i, source->num_tracks()) << endmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
++s; // next source
|
++s; // next source
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (...) {
|
} catch (exception& e) {
|
||||||
error << string_compose (_("MIDI file %1 was not readable (no reason available)"), source->file_path()) << endmsg;
|
error << string_compose (_("MIDI file could not be written (best guess: %1)"), e.what()) << endmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -546,7 +546,7 @@ SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence
|
|||||||
_model->set_edited(false);
|
_model->set_edited(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Evoral::SMF::end_write ();
|
Evoral::SMF::end_write (_path);
|
||||||
|
|
||||||
/* data in the file now, not removable */
|
/* data in the file now, not removable */
|
||||||
|
|
||||||
@ -726,7 +726,7 @@ SMFSource::flush_midi (const Lock& lock)
|
|||||||
|
|
||||||
ensure_disk_file (lock);
|
ensure_disk_file (lock);
|
||||||
|
|
||||||
Evoral::SMF::end_write ();
|
Evoral::SMF::end_write (_path);
|
||||||
/* data in the file means its no longer removable */
|
/* data in the file means its no longer removable */
|
||||||
mark_nonremovable ();
|
mark_nonremovable ();
|
||||||
|
|
||||||
@ -737,7 +737,6 @@ void
|
|||||||
SMFSource::set_path (const string& p)
|
SMFSource::set_path (const string& p)
|
||||||
{
|
{
|
||||||
FileSource::set_path (p);
|
FileSource::set_path (p);
|
||||||
SMF::set_path (_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ensure that this source has some file on disk, even if it's just a SMF header */
|
/** Ensure that this source has some file on disk, even if it's just a SMF header */
|
||||||
|
@ -58,8 +58,6 @@ public:
|
|||||||
int create(const std::string& path, int track=1, uint16_t ppqn=19200) THROW_FILE_ERROR;
|
int create(const std::string& path, int track=1, uint16_t ppqn=19200) THROW_FILE_ERROR;
|
||||||
void close() THROW_FILE_ERROR;
|
void close() THROW_FILE_ERROR;
|
||||||
|
|
||||||
const std::string& file_path() const { return _file_path; };
|
|
||||||
|
|
||||||
void seek_to_start() const;
|
void seek_to_start() const;
|
||||||
int seek_to_track(int track);
|
int seek_to_track(int track);
|
||||||
|
|
||||||
@ -71,17 +69,13 @@ public:
|
|||||||
|
|
||||||
void begin_write();
|
void begin_write();
|
||||||
void append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf, event_id_t note_id);
|
void append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf, event_id_t note_id);
|
||||||
void end_write() THROW_FILE_ERROR;
|
void end_write(std::string const &) THROW_FILE_ERROR;
|
||||||
|
|
||||||
void flush() {};
|
void flush() {};
|
||||||
|
|
||||||
double round_to_file_precision (double val) const;
|
double round_to_file_precision (double val) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
void set_path (const std::string& p);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _file_path;
|
|
||||||
smf_t* _smf;
|
smf_t* _smf;
|
||||||
smf_track_t* _smf_track;
|
smf_track_t* _smf_track;
|
||||||
bool _empty; ///< true iff file contains(non-empty) events
|
bool _empty; ///< true iff file contains(non-empty) events
|
||||||
|
@ -108,9 +108,7 @@ SMF::open(const std::string& path, int track) THROW_FILE_ERROR
|
|||||||
smf_delete(_smf);
|
smf_delete(_smf);
|
||||||
}
|
}
|
||||||
|
|
||||||
_file_path = path;
|
FILE* f = fopen(path.c_str(), "r");
|
||||||
|
|
||||||
FILE* f = fopen(_file_path.c_str(), "r");
|
|
||||||
if (f == 0) {
|
if (f == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if ((_smf = smf_load(f)) == 0) {
|
} else if ((_smf = smf_load(f)) == 0) {
|
||||||
@ -151,8 +149,6 @@ SMF::create(const std::string& path, int track, uint16_t ppqn) THROW_FILE_ERROR
|
|||||||
smf_delete(_smf);
|
smf_delete(_smf);
|
||||||
}
|
}
|
||||||
|
|
||||||
_file_path = path;
|
|
||||||
|
|
||||||
_smf = smf_new();
|
_smf = smf_new();
|
||||||
|
|
||||||
if (_smf == NULL) {
|
if (_smf == NULL) {
|
||||||
@ -180,7 +176,7 @@ SMF::create(const std::string& path, int track, uint16_t ppqn) THROW_FILE_ERROR
|
|||||||
{
|
{
|
||||||
/* put a stub file on disk */
|
/* put a stub file on disk */
|
||||||
|
|
||||||
FILE* f = fopen (_file_path.c_str(), "w+");
|
FILE* f = fopen (path.c_str(), "w+");
|
||||||
if (f == 0) {
|
if (f == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -401,17 +397,17 @@ SMF::begin_write()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SMF::end_write() THROW_FILE_ERROR
|
SMF::end_write(string const & path) THROW_FILE_ERROR
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_smf_lock);
|
Glib::Threads::Mutex::Lock lm (_smf_lock);
|
||||||
FILE* f = fopen (_file_path.c_str(), "w+");
|
FILE* f = fopen (path.c_str(), "w+");
|
||||||
if (f == 0) {
|
if (f == 0) {
|
||||||
throw FileError (_file_path);
|
throw FileError (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smf_save(_smf, f) != 0) {
|
if (smf_save(_smf, f) != 0) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
throw FileError (_file_path);
|
throw FileError (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -425,10 +421,4 @@ SMF::round_to_file_precision (double val) const
|
|||||||
return round (val * div) / div;
|
return round (val * div) / div;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
SMF::set_path (const std::string& p)
|
|
||||||
{
|
|
||||||
_file_path = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Evoral
|
} // namespace Evoral
|
||||||
|
Loading…
Reference in New Issue
Block a user