From cdccf89368fe6851ed74a651baf1cfcbaaccfb07 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 22 Dec 2008 04:42:37 +0000 Subject: Fix crash when deleting ports that send lots of broadcast events (e.g. a control rate LFO). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1904 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/PostProcessor.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/engine/PostProcessor.cpp b/src/engine/PostProcessor.cpp index 9543a712..b90f7ddc 100644 --- a/src/engine/PostProcessor.cpp +++ b/src/engine/PostProcessor.cpp @@ -46,14 +46,25 @@ PostProcessor::process() { const FrameTime end_time = _max_time.get(); - /* Note the normal (pre-processed client originated) events must - * be sent first, since they could have e.g. created a port which - * is by now inserted, running, and may broadcast something to - * the client. If the broadcast happened first the client would - * not yet know about the port's existance. */ + /* FIXME: The order here is a bit tricky: if the normal events are + * processed first, then a deleted port may still have a pending + * broadcast event which will segfault if executed afterwards. + * If it's the other way around, broadcasts will be sent for + * ports the client doesn't even know about yet... */ /* FIXME: process events from all threads if parallel */ + /* Process audio thread generated events */ + while (_engine.audio_driver()->context().event_sink().read( + _event_buffer_size, _event_buffer)) { + if (((Event*)_event_buffer)->time() > end_time) { + cerr << "WARNING: Lost event with time " + << ((Event*)_event_buffer)->time() << " > " << end_time << endl; + break; + } + ((Event*)_event_buffer)->post_process(); + } + /* Process normal events */ Raul::List::Node* n = _events.head(); while (n) { @@ -66,18 +77,6 @@ PostProcessor::process() delete n; n = next; } - - /* Process audio thread generated events */ - while (_engine.audio_driver()->context().event_sink().read( - _event_buffer_size, _event_buffer)) { - if (((Event*)_event_buffer)->time() > end_time) { - cerr << "WARNING: Lost event with time " - << ((Event*)_event_buffer)->time() << " > " << end_time << endl; - break; - } - ((Event*)_event_buffer)->post_process(); - } - } -- cgit v1.2.1