aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/Machine.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-17 01:43:22 +0000
committerDavid Robillard <d@drobilla.net>2010-12-17 01:43:22 +0000
commit02bb4118d6f056553daf383975e7a5e7eac4f38b (patch)
tree28f9c558335a2ca15bc3f1e17fd8f9ea4e8c1252 /src/engine/Machine.cpp
parent95b4da8350d77e28f2c37a58a18be5684c90a450 (diff)
downloadmachina-02bb4118d6f056553daf383975e7a5e7eac4f38b.tar.gz
machina-02bb4118d6f056553daf383975e7a5e7eac4f38b.tar.bz2
machina-02bb4118d6f056553daf383975e7a5e7eac4f38b.zip
Fix run duration handling and associated constant crashes (assertion failures).
Execution seemingly works for fractional note durations now... git-svn-id: http://svn.drobilla.net/lad/trunk/machina@2730 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/Machine.cpp')
-rw-r--r--src/engine/Machine.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp
index fffadc3..cbfa54e 100644
--- a/src/engine/Machine.cpp
+++ b/src/engine/Machine.cpp
@@ -299,11 +299,11 @@ Machine::exit_node(SharedPtr<Raul::MIDISink> sink, SharedPtr<Node> node)
* machine actually finished on (so it can be restarted immediately
* with sample accuracy if necessary).
*/
-TimeDuration
+uint32_t
Machine::run(const Raul::TimeSlice& time)
{
if (_is_finished)
- return TimeDuration(_time.unit(), 0, 0);
+ return 0;
SharedPtr<Raul::MIDISink> sink = _sink.lock();
@@ -317,7 +317,6 @@ Machine::run(const Raul::TimeSlice& time)
bool entered = false;
if ( ! _nodes.empty()) {
for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) {
-
if ((*n)->is_active())
(*n)->exit(sink, _time);
@@ -325,23 +324,20 @@ Machine::run(const Raul::TimeSlice& time)
if (enter_node(sink, (*n)))
entered = true;
}
-
}
}
if (!entered) {
_is_finished = true;
- return TimeStamp(_time.unit(), 0, 0);
+ return 0;
}
}
- TimeStamp this_time(_time.unit(), 0, 0);
-
while (true) {
SharedPtr<Node> earliest = earliest_node();
- // No more active states, machine is finished
if (!earliest) {
+ // No more active states, machine is finished
#ifndef NDEBUG
for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
assert( ! (*n)->is_active());
@@ -349,23 +345,20 @@ Machine::run(const Raul::TimeSlice& time)
_is_finished = true;
break;
- // Earliest active state ends this cycle
- } else if (earliest->exit_time() <= cycle_end) {
- this_time += earliest->exit_time() - _time;
+ } else if (time.beats_to_ticks(earliest->exit_time()) < cycle_end_frames) {
+ // Earliest active state ends this cycle
_time = earliest->exit_time();
exit_node(sink, earliest);
- // Earliest active state ends in the future, done this cycle
} else {
+ // Earliest active state ends in the future, done this cycle
_time = cycle_end;
- this_time = cycle_end; // ran the entire cycle
break;
}
}
- //assert(this_time <= time.length_beats());
- return this_time;
+ return time.beats_to_ticks(_time).ticks() - time.start_ticks().ticks();
}