summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_source.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-04-13 10:29:07 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-04-14 02:17:30 -0400
commit343b06d8d3522d6b017d887ca754c91aec2430fd (patch)
tree81aa51fa0fea6826e62480314c1ac78b112b3a9a /libs/ardour/midi_source.cc
parentd2a31ab6eed8b3e8f34dbc1caf2285bb64777f55 (diff)
dramatic change in logic and naming for operations related to adding a MIDI region on demand and cloning/unlinking
Existing code would cause data loss due to creation of two Source objects referring the same path, one with removable flags and one without. Careful code review suggested a variety of thinkos, function naming problems and other confusion that caused this. I have tried ot extensively comment what is going on with these operations, because it is one key area in which MIDI differs from audio: with audio, capture is the only way to add a new audio region, but for MIDI there are GUI input events that can add a new region.
Diffstat (limited to 'libs/ardour/midi_source.cc')
-rw-r--r--libs/ardour/midi_source.cc28
1 files changed, 4 insertions, 24 deletions
diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc
index d4452490fb..655222413a 100644
--- a/libs/ardour/midi_source.cc
+++ b/libs/ardour/midi_source.cc
@@ -332,29 +332,9 @@ MidiSource::mark_streaming_write_completed ()
mark_midi_streaming_write_completed (Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes);
}
-boost::shared_ptr<MidiSource>
-MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::MusicalTime end)
+int
+MidiSource::write_to (boost::shared_ptr<MidiSource> newsrc, Evoral::MusicalTime begin, Evoral::MusicalTime end)
{
- string newpath;
-
- /* get a new name for the MIDI file we're going to write to
- */
-
- if (path.empty()) {
- string newname = PBD::basename_nosuffix(_name.val());
- newname = bump_name_once (newname, '-');
- newname += ".mid";
- newpath = _session.new_source_path_from_name (DataType::MIDI, newname);
- } else {
- /* caller must check for pre-existing file */
- assert (!Glib::file_test (path, Glib::FILE_TEST_EXISTS));
- newpath = path;
- }
-
- boost::shared_ptr<MidiSource> newsrc = boost::dynamic_pointer_cast<MidiSource>(
- SourceFactory::createWritable(DataType::MIDI, _session,
- newpath, false, _session.frame_rate()));
-
newsrc->set_timeline_position(_timeline_position);
newsrc->copy_interpolation_from (this);
newsrc->copy_automation_state_from (this);
@@ -367,7 +347,7 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica
}
} else {
error << string_compose (_("programming error: %1"), X_("no model for MidiSource during ::clone()"));
- return boost::shared_ptr<MidiSource>();
+ return -1;
}
newsrc->flush_midi();
@@ -384,7 +364,7 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica
boost::dynamic_pointer_cast<FileSource> (newsrc)->prevent_deletion ();
- return newsrc;
+ return 0;
}
void