aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-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;