From fe229a830e0164e56d3aceaf3d539e4148f322a6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Jun 2010 01:37:24 +0000 Subject: 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 --- libs/ardour/session.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'libs/ardour/session.cc') 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 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 -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); + assert (mt); + */ + + list > l = track->steal_write_sources (); + + if (!l.empty()) { + assert (boost::dynamic_pointer_cast (l.front())); + return boost::dynamic_pointer_cast (l.front()); + } + } + const string name = new_midi_source_name (n); const string path = new_source_path_from_name (DataType::MIDI, name); -- cgit v1.2.3