summaryrefslogtreecommitdiffstats
path: root/src/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-16 00:24:10 +0000
committerDavid Robillard <d@drobilla.net>2011-04-16 00:24:10 +0000
commit2b04af0ab5d18d3116290fab7febac86f41068c9 (patch)
treed39059c5e1b466df5c1a77f3cf8ef809051497c4 /src/ingen
parente4faf89e42e68b9eb13a23b0bdef7c00169c3831 (diff)
downloadingen-2b04af0ab5d18d3116290fab7febac86f41068c9.tar.gz
ingen-2b04af0ab5d18d3116290fab7febac86f41068c9.tar.bz2
ingen-2b04af0ab5d18d3116290fab7febac86f41068c9.zip
Simpler and documented Engine main loop interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3150 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/ingen')
-rw-r--r--src/ingen/main.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp
index 4d55f212..ae99303f 100644
--- a/src/ingen/main.cpp
+++ b/src/ingen/main.cpp
@@ -17,6 +17,7 @@
#include <signal.h>
#include <stdlib.h>
+#include <time.h>
#include <iostream>
#include <string>
@@ -30,6 +31,7 @@
#include "raul/Configuration.hpp"
#include "raul/Path.hpp"
#include "raul/SharedPtr.hpp"
+#include "raul/Thread.hpp"
#include "raul/log.hpp"
#include "serd/serd.h"
@@ -51,6 +53,8 @@ using namespace std;
using namespace Raul;
using namespace Ingen;
+static const timespec main_rate = { 0, 125000000 }; // 1/8 second
+
Ingen::Shared::World* world = NULL;
void
@@ -212,12 +216,22 @@ main(int argc, char** argv)
cerr << "This build of ingen does not support scripting." << endl;
#endif
- // Listen to OSC and run main loop
+ // Run main loop
} else if (world->local_engine() && !conf.option("gui").get_bool()) {
+ // Set up signal handlers that will set quit_flag on interrupt
signal(SIGINT, ingen_interrupt);
signal(SIGTERM, ingen_interrupt);
+
+ // Activate the enginie
world->local_engine()->activate();
- world->local_engine()->main(); // Block here
+
+ // Run engine main loop until interrupt
+ while (world->local_engine()->main_iteration()) {
+ nanosleep(&main_rate, NULL);
+ }
+ info << "Finished main loop" << endl;
+
+ world->local_engine()->deactivate();
}
// Shut down