summaryrefslogtreecommitdiff
path: root/libs/ardour/smf_source.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-07-20 18:13:03 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-07-20 18:13:03 +0000
commitc99738d88e8a2ad806b219b9f3614a6b55b6bf37 (patch)
treed506a27d404e1b63063372ebe2f63aacc7e6ebb4 /libs/ardour/smf_source.cc
parent8c7fda11cf47cd8dd04c6eabffc437dd942403d5 (diff)
try to fix data loss at end of a capture pass for MIDI - add a new virtual method to MidiSource that specifies what should be done with stuck notes, remove duplicate(i hope) _last_flush_frame from SMFSource that mirrored, more or less, MidiSource::_last_write_end; use new virtual method when stopping after capture.
git-svn-id: svn://localhost/ardour2/branches/3.0@9910 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r--libs/ardour/smf_source.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 7d90b58859..9e777b6ae5 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -243,16 +243,21 @@ SMFSource::write_unlocked (MidiRingBuffer<framepos_t>& source, framepos_t positi
cerr << "SMFSource::write unlocked, begins writing from src buffer with _last_write_end = " << _last_write_end << " dur = " << duration << endl;
while (true) {
- bool ret = source.peek ((uint8_t*)&time, sizeof (time));
- if (!ret || time > _last_write_end + duration) {
- DEBUG_TRACE (DEBUG::MidiIO, string_compose ("SMFSource::write_unlocked: dropping event @ %1 because ret %4 or it is later than %2 + %3\n",
- time, _last_write_end, duration, ret));
+ bool ret;
+
+ if (!(ret = source.peek ((uint8_t*)&time, sizeof (time)))) {
+ /* no more events to consider */
break;
}
- ret = source.read_prefix(&time, &type, &size);
- if (!ret) {
- cerr << "ERROR: Unable to read event prefix, corrupt MIDI ring buffer" << endl;
+ if ((duration != max_framecnt) && (time > (_last_write_end + duration))) {
+ DEBUG_TRACE (DEBUG::MidiIO, string_compose ("SMFSource::write_unlocked: dropping event @ %1 because it is later than %2 + %3\n",
+ time, _last_write_end, duration));
+ break;
+ }
+
+ if (!(ret = source.read_prefix (&time, &type, &size))) {
+ error << _("Unable to read event prefix, corrupt MIDI ring buffer") << endmsg;
break;
}
@@ -263,7 +268,7 @@ SMFSource::write_unlocked (MidiRingBuffer<framepos_t>& source, framepos_t positi
ret = source.read_contents(size, buf);
if (!ret) {
- cerr << "ERROR: Read time/size but not buffer, corrupt MIDI ring buffer" << endl;
+ error << _("Read time/size but not buffer, corrupt MIDI ring buffer") << endmsg;
break;
}
@@ -431,8 +436,14 @@ SMFSource::mark_streaming_midi_write_started (NoteMode mode)
void
SMFSource::mark_streaming_write_completed ()
{
+ mark_midi_streaming_write_completed (Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes);
+}
+
+void
+SMFSource::mark_midi_streaming_write_completed (Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption stuck_notes_option, Evoral::MusicalTime when)
+{
Glib::Mutex::Lock lm (_lock);
- MidiSource::mark_streaming_write_completed();
+ MidiSource::mark_midi_streaming_write_completed (stuck_notes_option, when);
if (!writable()) {
return;
@@ -551,8 +562,7 @@ SMFSource::load_model (bool lock, bool force_reload)
have_event_id = false;
}
- _model->end_write (_length_beats, false, true);
- //_model->end_write (false);
+ _model->end_write (Evoral::Sequence<Evoral::MusicalTime>::ResolveStuckNotes, _length_beats);
_model->set_edited (false);
_model_iter = _model->begin();