mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-14 18:46:34 +01:00
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
This commit is contained in:
parent
8c7fda11cf
commit
c99738d88e
10 changed files with 101 additions and 61 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -430,9 +435,15 @@ 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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue