diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-06-24 01:37:24 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-06-24 01:37:24 +0000 |
commit | fe229a830e0164e56d3aceaf3d539e4148f322a6 (patch) | |
tree | b7ce8899512827698931a9d34ae766e5d4aac710 /libs/ardour/session.cc | |
parent | d8e93be2ee68fc6a18a7ca17d36ffc67c94207b3 (diff) |
GUI-created MIDI regions now steal the pending MIDISource from the track's diskstream, to keep numbering sane; don't create any new MIDI regions if capture collected no data (fixes a crash in my previous commit, and is just logically much more sensible
git-svn-id: svn://localhost/ardour2/branches/3.0@7295 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r-- | libs/ardour/session.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 91b1e2a0f9..94945b95c2 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1456,7 +1456,7 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m } shared_ptr<MidiTrack> track; - + try { MidiTrack* mt = new MidiTrack (*this, track_name, Route::Flag (0), mode); @@ -2948,8 +2948,24 @@ Session::new_midi_source_name (const string& base) /** Create a new within-session MIDI source */ boost::shared_ptr<MidiSource> -Session::create_midi_source_for_session (string const & n) +Session::create_midi_source_for_session (Track* track, string const & n) { + /* try to use the existing write source for the track, to keep numbering sane + */ + + if (track) { + /*MidiTrack* mt = dynamic_cast<Track*> (track); + assert (mt); + */ + + list<boost::shared_ptr<Source> > l = track->steal_write_sources (); + + if (!l.empty()) { + assert (boost::dynamic_pointer_cast<MidiSource> (l.front())); + return boost::dynamic_pointer_cast<MidiSource> (l.front()); + } + } + const string name = new_midi_source_name (n); const string path = new_source_path_from_name (DataType::MIDI, name); |