From 719fc353d389b936cc1c064d512453268283b424 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 1 Apr 2007 15:18:31 +0000 Subject: Fixed exception bug. git-svn-id: http://svn.drobilla.net/lad/machina@387 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/JackDriver.cpp | 9 +++++++++ src/gui/main.cpp | 20 ++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index d19bdeb..7a2b03d 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -179,6 +179,13 @@ JackDriver::write_event(Raul::BeatTime time, size_t size, const byte* event) throw (std::logic_error) { + if (_cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks() < _cycle_time.start_ticks()) { + std::cerr << "ERROR: Missed event by " + << _cycle_time.start_ticks() - (_cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks()) + << "ticks." << std::endl; + return; + } + const TickCount nframes = _cycle_time.length_ticks(); const TickCount offset = _cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks() - _cycle_time.start_ticks(); @@ -221,9 +228,11 @@ JackDriver::on_process(jack_nframes_t nframes) if (machine != _last_machine) { if (_last_machine) { assert(!_last_machine.unique()); // Realtime, can't delete + _last_machine->set_sink(shared_from_this()); _last_machine->reset(); // Exit all active states _last_machine.reset(); // Cut our reference } + _cycle_time.set_start(0); _machine_changed.post(); // Signal we're done with it } diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 741c801..c522898 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -36,7 +36,7 @@ int main(int argc, char** argv) { SharedPtr machine; - + // Load machine, if given if (argc >= 2) { const string filename = argv[1]; @@ -67,22 +67,14 @@ main(int argc, char** argv) SharedPtr engine(new Engine(driver)); - // Launch GUI - try { - - Gnome::Canvas::init(); - Gtk::Main app(argc, argv); + Gnome::Canvas::init(); + Gtk::Main app(argc, argv); - driver->activate(); - MachinaGUI gui(engine); + driver->activate(); + MachinaGUI gui(engine); - app.run(*gui.window()); + app.run(*gui.window()); - } catch (string msg) { - cerr << "Caught exception, aborting. Error message was: " << msg << endl; - return 1; - } - return 0; } -- cgit v1.2.1