aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-05-07 01:52:19 +0000
committerDavid Robillard <d@drobilla.net>2007-05-07 01:52:19 +0000
commit32778748308168a82af100bba6b3bd6699f7aa7f (patch)
treeae80b6ab0fcbb246920b1bebbc652756f63a388a
parent60f7de53c0b8763f1867d450a8195bd2845c6e66 (diff)
downloadmachina-32778748308168a82af100bba6b3bd6699f7aa7f.tar.gz
machina-32778748308168a82af100bba6b3bd6699f7aa7f.tar.bz2
machina-32778748308168a82af100bba6b3bd6699f7aa7f.zip
Fixed assert crash bug.
git-svn-id: http://svn.drobilla.net/lad/machina@515 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/engine/JackDriver.cpp2
-rw-r--r--src/engine/Machine.cpp15
2 files changed, 11 insertions, 6 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 32439c8..f45ccc6 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -269,7 +269,7 @@ JackDriver::on_process(jack_nframes_t nframes)
const TickCount run_dur_ticks = _cycle_time.beats_to_ticks(run_dur_beats);
// Machine didn't run at all (empty, or no initial states)
- if (run_dur_ticks == 0) {
+ if (run_dur_beats == 0) {
machine->reset(); // Try again next cycle
_cycle_time.set_start(0);
return;
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp
index 815ba5b..61cad67 100644
--- a/src/engine/Machine.cpp
+++ b/src/engine/Machine.cpp
@@ -78,6 +78,10 @@ Machine::remove_node(SharedPtr<Node> node)
void
Machine::reset()
{
+ for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) {
+ _active_nodes[i].reset();
+ }
+
if (!_is_finished) {
for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) {
const SharedPtr<Node> node = (*n);
@@ -88,10 +92,6 @@ Machine::reset()
assert(! node->is_active());
}
}
-
- for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) {
- _active_nodes[i].reset();
- }
_time = 0;
_is_finished = false;
@@ -234,7 +234,8 @@ Machine::run(const Raul::TimeSlice& time)
if ( ! _nodes.empty()) {
for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) {
- assert( ! (*n)->is_active());
+ if ((*n)->is_active())
+ (*n)->exit(sink, 0);
if ((*n)->is_initial()) {
if (enter_node(sink, (*n)))
@@ -257,6 +258,10 @@ Machine::run(const Raul::TimeSlice& time)
// No more active states, machine is finished
if (!earliest) {
+#ifndef NDEBUG
+ for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
+ assert( ! (*n)->is_active());
+#endif
_is_finished = true;
break;