Fix MIDI file names on recording (don't write out a ton of useless empty .mid files).
Preliminary hooks for writing model to file (still does nothing). git-svn-id: svn://localhost/ardour2/trunk@2289 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b6855bc209
commit
861181d742
@ -143,6 +143,8 @@ public:
|
||||
MidiModel::DeltaCommand* new_delta_command(const std::string name="midi edit");
|
||||
void apply_command(Command* cmd);
|
||||
|
||||
bool write_new_source(const std::string& path);
|
||||
|
||||
sigc::signal<void> ContentsChanged;
|
||||
|
||||
private:
|
||||
|
@ -57,6 +57,8 @@ class MidiSource : public Source
|
||||
virtual void mark_streaming_write_started ();
|
||||
virtual void mark_streaming_write_completed ();
|
||||
|
||||
virtual void session_saved();
|
||||
|
||||
string captured_for() const { return _captured_for; }
|
||||
void set_captured_for (string str) { _captured_for = str; }
|
||||
|
||||
|
@ -75,7 +75,7 @@ class SMFSource : public MidiSource {
|
||||
|
||||
int move_to_trash (const string trash_dir_name);
|
||||
|
||||
static bool is_empty (string path);
|
||||
bool is_empty () const;
|
||||
void mark_streaming_write_completed ();
|
||||
|
||||
void mark_take (string);
|
||||
|
@ -58,6 +58,8 @@ class Source : public SessionObject
|
||||
virtual void mark_streaming_write_started () {}
|
||||
virtual void mark_streaming_write_completed () = 0;
|
||||
|
||||
virtual void session_saved() {}
|
||||
|
||||
XMLNode& get_state ();
|
||||
int set_state (const XMLNode&);
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ MidiDiskstream::use_new_write_source (uint32_t n)
|
||||
|
||||
if (_write_source) {
|
||||
|
||||
if (SMFSource::is_empty (_write_source->path())) {
|
||||
if (_write_source->is_empty ()) {
|
||||
_write_source->mark_for_remove ();
|
||||
_write_source.reset();
|
||||
} else {
|
||||
|
@ -424,3 +424,22 @@ MidiModel::DeltaCommand::undo()
|
||||
_model.ContentsChanged(); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
MidiModel::write_new_source(const std::string& path)
|
||||
{
|
||||
cerr << "Writing model to " << path << endl;
|
||||
|
||||
#if 0
|
||||
SourceFactory::createWritable (region->data_type(), session, path, false, session.frame_rate());
|
||||
|
||||
catch (failed_constructor& err) {
|
||||
error << string_compose (_("filter: error creating new file %1 (%2)"), path, strerror (errno)) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -155,3 +155,9 @@ MidiSource::mark_streaming_write_completed ()
|
||||
_writing = false;
|
||||
}
|
||||
|
||||
void
|
||||
MidiSource::session_saved()
|
||||
{
|
||||
cerr << "MidiSource saving, name = " << _name << endl;
|
||||
}
|
||||
|
||||
|
@ -560,6 +560,11 @@ Session::save_state (string snapshot_name, bool pending)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* tell sources we're saving first, in case they write out to a new file
|
||||
* which should be saved with the state rather than the old one */
|
||||
for (SourceMap::const_iterator i = sources.begin(); i != sources.end(); ++i)
|
||||
i->second->session_saved();
|
||||
|
||||
tree.set_root (&get_state());
|
||||
|
||||
if (snapshot_name.empty()) {
|
||||
|
@ -113,7 +113,7 @@ bool
|
||||
SMFSource::removable () const
|
||||
{
|
||||
return (_flags & Removable) && ((_flags & RemoveAtDestroy) ||
|
||||
((_flags & RemovableIfEmpty) && is_empty (_path)));
|
||||
((_flags & RemovableIfEmpty) && is_empty()));
|
||||
}
|
||||
|
||||
int
|
||||
@ -720,11 +720,13 @@ SMFSource::set_source_name (string newname, bool destructive)
|
||||
}
|
||||
|
||||
bool
|
||||
SMFSource::is_empty (string path)
|
||||
SMFSource::is_empty () const
|
||||
{
|
||||
/* XXX fix me */
|
||||
bool ret = (_track_size > 4);
|
||||
|
||||
return false;
|
||||
cerr << name() << " IS EMPTY: " << ret << endl;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user