diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-13 10:29:07 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-14 13:05:08 -0400 |
commit | 0d5f4c553a7365612a44e1e0997a6d0e14d8b7ff (patch) | |
tree | d7031e5df3cbd6cae2b91630405e5f342d66f0e7 /libs/ardour/midi_diskstream.cc | |
parent | 384c0a9facf1bfecc783ac048dbb0bae4ad901fd (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_diskstream.cc')
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index eeabdcb728..21b5aa0a34 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -1199,7 +1199,7 @@ MidiDiskstream::use_new_write_source (uint32_t n) try { _write_source = boost::dynamic_pointer_cast<SMFSource>( - _session.create_midi_source_for_session (0, name ())); + _session.create_midi_source_for_session (name ())); if (!_write_source) { throw failed_constructor(); @@ -1224,13 +1224,19 @@ MidiDiskstream::use_new_write_source (uint32_t n) std::string MidiDiskstream::steal_write_source_name () { - std::string our_new_name = _session.new_midi_source_name (_write_source->name()); - std::string our_old_name = _write_source->name(); - - if (_write_source->set_source_name (our_new_name, false)) { + string our_old_name = _write_source->name(); + + /* this will bump the name of the current write source to the next one + * (e.g. "MIDI 1-1" gets renamed to "MIDI 1-2"), thus leaving the + * current write source name (e.g. "MIDI 1-1" available). See the + * comments in Session::create_midi_source_for_track() about why we do + * this. + */ + + if (_write_source->set_source_name (name(), false)) { return string(); } - + return our_old_name; } |