summaryrefslogtreecommitdiffstats
path: root/src/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-09-23 22:00:38 +0000
committerDavid Robillard <d@drobilla.net>2011-09-23 22:00:38 +0000
commit41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9 (patch)
tree4803c07d4d3ebf85093068d94484dd7029a57389 /src/ingen
parent1af9036d30ba65c6ec5e04902cdfdcfc88478e62 (diff)
downloadingen-41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9.tar.gz
ingen-41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9.tar.bz2
ingen-41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9.zip
Fix broken iterator use (memory errors on erase) in ResourceImpl::set_property.
Load all required modules before starting jack (Jack went crazy sometimes otherwise, particularly with ingen running in gdb). Fix insane non-const reference return to Resource::set_property. Exit cleanly on interrupt (Ctrl-C) and terminate (kill). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3480 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/ingen')
-rw-r--r--src/ingen/main.cpp60
1 files changed, 33 insertions, 27 deletions
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp
index 2910f9eb..aae428c8 100644
--- a/src/ingen/main.cpp
+++ b/src/ingen/main.cpp
@@ -59,13 +59,18 @@ static const timespec main_rate = { 0, 125000000 }; // 1/8 second
Ingen::Shared::World* world = NULL;
void
-ingen_interrupt(int)
+ingen_interrupt(int signal)
{
- cout << "ingen: Interrupted" << endl;
- if (world->local_engine())
- world->local_engine()->quit();
- delete world;
- exit(EXIT_FAILURE);
+ if (signal == SIGTERM) {
+ cerr << "ingen: Terminated" << endl;
+ delete world;
+ exit(EXIT_FAILURE);
+ } else {
+ cout << "ingen: Interrupted" << endl;
+ if (world && world->local_engine()) {
+ world->local_engine()->quit();
+ }
+ }
}
void
@@ -110,7 +115,7 @@ main(int argc, char** argv)
g_type_init();
#endif
- Ingen::Shared::World* world = new Ingen::Shared::World(&conf, argc, argv);
+ world = new Ingen::Shared::World(&conf, argc, argv);
if (conf.option("uuid").get_string()) {
world->set_jack_uuid(conf.option("uuid").get_string());
@@ -148,20 +153,29 @@ main(int argc, char** argv)
(string("Unable to create interface to `") + uri + "'").c_str());
}
- // Activate the engine, if we have one
- if (world->local_engine()) {
- ingen_try(world->load_module("jack"),
- "Unable to load jack module");
+ world->set_engine(engine_interface);
+
+ // Load necessary modules before activating engine (and Jack driver)
+
+ if (conf.option("load").is_valid()) {
+ ingen_try(world->load_module("serialisation"),
+ "Unable to load serialisation module");
}
- world->set_engine(engine_interface);
+ if (conf.option("gui").get_bool()) {
+ ingen_try(world->load_module("gui"),
+ "Unable to load GUI module");
+ }
+ // Activate the engine, if we have one
if (world->local_engine()) {
+ ingen_try(world->load_module("jack"),
+ "Unable to load jack module");
world->local_engine()->activate();
}
// Load a patch
- if (conf.option("load").is_valid() && engine_interface) {
+ if (conf.option("load").is_valid()) {
boost::optional<Path> parent;
boost::optional<Symbol> symbol;
const Raul::Atom& path_option = conf.option("path");
@@ -178,9 +192,6 @@ main(int argc, char** argv)
}
}
- ingen_try(world->load_module("serialisation"),
- "Unable to load serialisation module");
-
ingen_try(world->parser(),
"Unable to create parser");
@@ -199,13 +210,10 @@ main(int argc, char** argv)
world, engine_interface.get(), uri, parent, symbol);
}
- // Load GUI
- if (conf.option("gui").get_bool())
- ingen_try(world->load_module("gui"),
- "Unable to load GUI module");
-
- // Run a script
- if (conf.option("run").is_valid()) {
+ if (conf.option("gui").get_bool()) {
+ world->run_module("gui");
+ } else if (conf.option("run").is_valid()) {
+ // Run a script
#ifdef WITH_BINDINGS
ingen_try(world->load_module("bindings"),
"Unable to load bindings module");
@@ -215,15 +223,13 @@ main(int argc, char** argv)
cerr << "This build of ingen does not support scripting." << endl;
#endif
- // Run main loop
} else if (world->local_engine() && !conf.option("gui").get_bool()) {
+ // Run main loop
+
// Set up signal handlers that will set quit_flag on interrupt
signal(SIGINT, ingen_interrupt);
signal(SIGTERM, ingen_interrupt);
- // Activate the engine
- world->local_engine()->activate();
-
// Run engine main loop until interrupt
while (world->local_engine()->main_iteration()) {
nanosleep(&main_rate, NULL);