Fix crash on save of MIDI data.
authorDavid Robillard <d@drobilla.net>
Thu, 22 Oct 2009 22:14:25 +0000 (22:14 +0000)
committerDavid Robillard <d@drobilla.net>
Thu, 22 Oct 2009 22:14:25 +0000 (22:14 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5875 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/smf_source.h
libs/ardour/midi_model.cc
libs/ardour/midi_source.cc
libs/ardour/smf_source.cc

index 7793b6a91c5cfb7b97162bc20969e71a731c80f6..e02f8eddc05241efd167f20e97e838894e1e39d8 100644 (file)
@@ -77,7 +77,7 @@ private:
                                 sframes_t stamp_offset,
                                 sframes_t negative_stamp_offset,
                                 MidiStateTracker* tracker) const;
-       
+
        nframes_t write_unlocked (MidiRingBuffer<nframes_t>& src,
                        sframes_t position,
                        nframes_t cnt);
index 688e7666688b1e5080b324ca17af85bae76d447e..47bc14852c1cf1828521f98fbc57415bebff3938 100644 (file)
@@ -688,12 +688,14 @@ MidiModel::write_to(boost::shared_ptr<MidiSource> source)
        set_percussive(false);
 
        source->drop_model();
+       source->mark_streaming_midi_write_started(note_mode(), _midi_source->timeline_position());
 
        for (Evoral::Sequence<TimeType>::const_iterator i = begin(); i != end(); ++i) {
                source->append_event_unlocked_beats(*i);
        }
 
        set_percussive(old_percussive);
+       source->mark_streaming_write_completed();
 
        set_edited(false);
 
index 133b75893d7567849209ca26b6755b897681401a..09df32a275f12e3b4ea10a845d6354bfc58fc33f 100644 (file)
@@ -219,14 +219,8 @@ MidiSource::mark_streaming_midi_write_started (NoteMode mode, sframes_t start_fr
 void
 MidiSource::mark_streaming_write_started ()
 {
-       sframes_t start_frame = _session.transport_frame();
-
-       if (_model) {
-               _model->start_write();
-       }
-
-       _last_write_end = start_frame;
-       _writing = true;
+       NoteMode note_mode = _model ? _model->note_mode() : Sustained;
+       mark_streaming_midi_write_started(note_mode, _session.transport_frame());
 }
 
 void
index 6e8a0ee0526960c007b364792bf30db9cf2a3979..c940bd33314ed4183e9f68983225c72bb359ac40 100644 (file)
@@ -183,7 +183,7 @@ SMFSource::read_unlocked (MidiRingBuffer<nframes_t>& destination, sframes_t sour
                } else {
                        break;
                }
-               
+
                _read_data_count += ev_size;
 
                if (ev_size > scratch_size) {
@@ -268,6 +268,7 @@ SMFSource::write_unlocked (MidiRingBuffer<nframes_t>& source, sframes_t position
 void
 SMFSource::append_event_unlocked_beats (const Evoral::Event<double>& ev)
 {
+       assert(_writing);
        if (ev.size() == 0)  {
                return;
        }
@@ -301,6 +302,7 @@ SMFSource::append_event_unlocked_beats (const Evoral::Event<double>& ev)
 void
 SMFSource::append_event_unlocked_frames (const Evoral::Event<nframes_t>& ev, sframes_t position)
 {
+       assert(_writing);
        if (ev.size() == 0)  {
                return;
        }