aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-10 03:39:10 +0000
committerDavid Robillard <d@drobilla.net>2007-02-10 03:39:10 +0000
commitb924ead0db7c09ee50d2d4eee487b844c5fb867b (patch)
tree36fa1a6c879989a111f4fbbaf9a03b7f442b618c /src/engine
parent9f2a520a8f20661385bf6c9f7447aef1227d8696 (diff)
downloadmachina-b924ead0db7c09ee50d2d4eee487b844c5fb867b.tar.gz
machina-b924ead0db7c09ee50d2d4eee487b844c5fb867b.tar.bz2
machina-b924ead0db7c09ee50d2d4eee487b844c5fb867b.zip
Machine GUI talking to Jack engine, running machines made in GUI, etc.
git-svn-id: http://svn.drobilla.net/lad/machina@297 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/JackDriver.cpp9
-rw-r--r--src/engine/Machine.cpp20
-rw-r--r--src/engine/machina/Machine.hpp2
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