From 2b04af0ab5d18d3116290fab7febac86f41068c9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 16 Apr 2011 00:24:10 +0000 Subject: Simpler and documented Engine main loop interface. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3150 a436a847-0d15-0410-975c-d299462d15a1 --- src/ingen/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/ingen') 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 #include +#include #include #include @@ -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 -- cgit v1.2.1