summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/QueuedEventSource.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-08 06:23:25 +0000
committerDavid Robillard <d@drobilla.net>2006-09-08 06:23:25 +0000
commit43d51948ccae71b8f0a1c1710e25cf36da8d7d7c (patch)
treef81e18174cf0a798a908afb954f6595d6c0b72ab /src/libs/engine/QueuedEventSource.cpp
parent48f87f1f1649fb7e169fdaac2cd38370e8a4a1fa (diff)
downloadingen-43d51948ccae71b8f0a1c1710e25cf36da8d7d7c.tar.gz
ingen-43d51948ccae71b8f0a1c1710e25cf36da8d7d7c.tar.bz2
ingen-43d51948ccae71b8f0a1c1710e25cf36da8d7d7c.zip
Renamed communications classes for consistency.
Removed engine dependency on OSC (mostly). git-svn-id: http://svn.drobilla.net/lad/ingen@120 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/QueuedEventSource.cpp')
-rw-r--r--src/libs/engine/QueuedEventSource.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/libs/engine/QueuedEventSource.cpp b/src/libs/engine/QueuedEventSource.cpp
index 0ef11ac1..915b7811 100644
--- a/src/libs/engine/QueuedEventSource.cpp
+++ b/src/libs/engine/QueuedEventSource.cpp
@@ -16,6 +16,7 @@
#include "QueuedEventSource.h"
#include "QueuedEvent.h"
+#include "PostProcessor.h"
#include <sys/mman.h>
#include <iostream>
using std::cout; using std::cerr; using std::endl;
@@ -64,12 +65,43 @@ QueuedEventSource::push_queued(QueuedEvent* const ev)
}
+/** Process all events for a cycle.
+ *
+ * Executed events will be pushed to @a dest.
+ */
void
-QueuedEventSource::push_stamped(Event* const ev)
+QueuedEventSource::process(PostProcessor& dest, SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end)
{
- _stamped_queue.push(ev);
+ Event* ev = NULL;
+
+ /* Limit the maximum number of queued events to process per cycle. This
+ * makes the process callback (more) realtime-safe by preventing being
+ * choked by events coming in faster than they can be processed.
+ * FIXME: test this and figure out a good value */
+ const unsigned int MAX_QUEUED_EVENTS = nframes / 100;
+
+ unsigned int num_events_processed = 0;
+
+ /* FIXME: Merge these next two loops into one */
+
+ while ((ev = pop_earliest_queued_before(cycle_end))) {
+ ev->execute(nframes, cycle_start, cycle_end);
+ dest.push(ev);
+ if (++num_events_processed > MAX_QUEUED_EVENTS)
+ break;
+ }
+
+ while ((ev = pop_earliest_stamped_before(cycle_end))) {
+ ev->execute(nframes, cycle_start, cycle_end);
+ dest.push(ev);
+ ++num_events_processed;
+ }
+
+ if (num_events_processed > 0)
+ dest.whip();
}
+
/** Pops the prepared event at the front of the prepare queue, if it exists.
*
* This method will only pop events that have been prepared, and are