mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 05:35:47 +01:00
triggerbox: prevent downstream crashes if a tempo map or other change invalidates MidiTrigger iter
The iterator into the model can become incorrect in the sense that it is no longer the correct next event to play. This can happen at least with a tempo map change, and possible under other conditions. Catch this when it happens, and act as if we reached the end of the trigger
This commit is contained in:
parent
bb4b07cca6
commit
9781c1baca
1 changed files with 11 additions and 1 deletions
|
|
@ -2697,13 +2697,22 @@ MIDITrigger::midi_run (BufferSet& bufs, samplepos_t start_sample, samplepos_t en
|
|||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 tlrr %2 >= fb %3, so at end with %4\n", index(), maybe_last_event_timeline_beats, final_beat, event));
|
||||
iter = model->end();
|
||||
break;
|
||||
} else if (maybe_last_event_timeline_beats < start_beats) {
|
||||
/* something made iter incorrect, maybe tempo map
|
||||
change. Pretend that we reached the end
|
||||
*/
|
||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 tlrr %2 < sb %3, so at end with %4\n", index(), maybe_last_event_timeline_beats, start_beats, event));
|
||||
iter = model->end();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now get samples */
|
||||
|
||||
const samplepos_t timeline_samples = tmap->sample_at (maybe_last_event_timeline_beats);
|
||||
|
||||
if (timeline_samples >= end_sample) {
|
||||
if (timeline_samples >= end_sample || timeline_samples < start_sample) {
|
||||
/* we should not get here but if we do, pretend we reached the end */
|
||||
iter = model->end();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2720,6 +2729,7 @@ MIDITrigger::midi_run (BufferSet& bufs, samplepos_t start_sample, samplepos_t en
|
|||
*/
|
||||
|
||||
samplepos_t buffer_samples = (timeline_samples - start_sample) + dest_offset;
|
||||
assert (buffer_samples >= 0);
|
||||
|
||||
Evoral::Event<MidiBuffer::TimeType> ev (Evoral::MIDI_EVENT, buffer_samples, event.size(), const_cast<uint8_t*>(event.buffer()), false);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue