13
0

Implement replacing events in the immediate queue

This corrects issues introduced in a75c239c0c,
and fixes MIDI playback.
This commit is contained in:
Robin Gareus 2021-03-24 04:05:35 +01:00
parent 3f50b6d639
commit bbb244c1c9
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -250,15 +250,18 @@ SessionEventManager::_replace_event (SessionEvent* ev)
bool ret = false;
Events::iterator i;
/* private, used only for events that can only exist once in the queue */
/* use only for events that can only exist once in the respective queue */
Events& e (ev->action_sample == SessionEvent::Immediate ? immediate_events : events);
for (i = events.begin(); i != events.end(); ++i) {
if ((*i)->type == ev->type && ev->type == SessionEvent::Overwrite && (*i)->track.lock() == ev->track.lock()) {
for (i = e.begin(); i != e.end(); ++i) {
if ((*i)->type == ev->type && ev->type == SessionEvent::Overwrite && (*i)->track.lock() == ev->track.lock() && (*i)->overwrite == ev->overwrite) {
assert (ev->action_sample == SessionEvent::Immediate);
ret = true;
delete ev;
break;
}
else if ((*i)->type == ev->type && ev->type != SessionEvent::Overwrite) {
assert (ev->action_sample != SessionEvent::Immediate);
assert (ev->type == SessionEvent::PunchIn || ev->type == SessionEvent::PunchOut || ev->type == SessionEvent::AutoLoop);
(*i)->action_sample = ev->action_sample;
(*i)->target_sample = ev->target_sample;
@ -270,12 +273,17 @@ SessionEventManager::_replace_event (SessionEvent* ev)
}
}
if (i == events.end()) {
events.insert (events.begin(), ev);
if (i == e.end()) {
e.insert (e.begin(), ev);
}
events.sort (SessionEvent::compare);
next_event = events.end();
if (ev->action_sample == SessionEvent::Immediate) {
/* no need to sort immediate events */
return ret;
}
e.sort (SessionEvent::compare);
next_event = e.end();
set_next_event ();
return ret;