diff options
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/JackDriver.cpp | 9 | ||||
-rw-r--r-- | src/engine/Machine.cpp | 20 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 2 |
3 files changed, 22 insertions, 9 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 848c3d7..f6f0ea6 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -33,7 +33,7 @@ JackDriver::JackDriver() void JackDriver::attach(const std::string& client_name) { - Raul::JackDriver::attach(client_name); + Raul::JackDriver::attach(client_name, "debug"); if (jack_client()) { _output_port = jack_port_register(jack_client(), @@ -57,6 +57,8 @@ JackDriver::detach() Timestamp JackDriver::stamp_to_offset(Timestamp stamp) { + assert(stamp >= _current_cycle_start); + Timestamp ret = stamp - _current_cycle_start + _current_cycle_offset; assert(ret < _current_cycle_offset + _current_cycle_nframes); return ret; @@ -77,6 +79,11 @@ JackDriver::on_process(jack_nframes_t nframes) bool machine_done = ! _machine->run(_current_cycle_nframes); + if (machine_done && _machine->time() == 0) { + _machine->reset(); + return; + } + if (!machine_done) { _current_cycle_start += _current_cycle_nframes; break; diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 426ffd3..5cc54ee 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -39,8 +39,6 @@ Machine::~Machine() void Machine::add_node(SharedPtr<Node> node) { - assert(!_is_activated); - _nodes.push_back(node); } @@ -118,9 +116,6 @@ Machine::run(FrameCount nframes) if (_is_finished) return false; - if (_nodes.size() == 0) - return true; - const FrameCount cycle_end = _time + nframes; assert(_is_activated); @@ -128,10 +123,19 @@ Machine::run(FrameCount nframes) //std::cerr << "--------- " << _time << " - " << _time + nframes << std::endl; // Initial run, enter all initial states - if (_time == 0) - for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) - if ((*n)->is_initial()) + if (_time == 0) { + bool entered = false; + for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { + if ((*n)->is_initial()) { (*n)->enter(0); + entered = true; + } + } + if (!entered) { + _is_finished = true; + return false; + } + } while (true) { diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 2ac739e..5d16a4e 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -36,6 +36,8 @@ public: void activate() { _is_activated = true; } void deactivate() { _is_activated = false; } + bool is_finished() { return _is_finished; } + void add_node(SharedPtr<Node> node); // Audio context |