From 773a6ce4d153c6ecc8fb5cf9b41bcf9f25144d7c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 28 May 2020 21:01:56 +0200 Subject: Get rid of haunting assert in input/jackmidi module. --- drumgizmo/input/jackmidi.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drumgizmo/input/jackmidi.cc b/drumgizmo/input/jackmidi.cc index cf4dc6c..445678b 100644 --- a/drumgizmo/input/jackmidi.cc +++ b/drumgizmo/input/jackmidi.cc @@ -110,8 +110,12 @@ void JackMidiInputEngine::process(jack_nframes_t num_frames) void* buffer = jack_port_get_buffer(port->port, num_frames); jack_nframes_t num_events = jack_midi_get_event_count(buffer); - assert(events.empty()); - events.reserve(num_events); + // The event list is assumed to be empty here. + // It might not be though in case the system is under heavy load. + // Make room for both the new and old events to make sure we don't throw + // anything away. + events.reserve(events.size() + num_events); + for(jack_nframes_t i = 0; i < num_events; ++i) { jack_midi_event_t event; -- cgit v1.2.3