summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-24 23:54:37 +0000
committerDavid Robillard <d@drobilla.net>2010-02-24 23:54:37 +0000
commitc35f3f773e68c0e787a8436393475d3269c421c9 (patch)
treefb3847a90d94394f7ff22b3fad1ccb5c0f0da546 /src
parent313af960a340f8539214d53252e3186fe3dc8f40 (diff)
downloadingen-c35f3f773e68c0e787a8436393475d3269c421c9.tar.gz
ingen-c35f3f773e68c0e787a8436393475d3269c421c9.tar.bz2
ingen-c35f3f773e68c0e787a8436393475d3269c421c9.zip
Tidy up Context and ProcessContext interfaces (ProcessContext only lives on as a useful type).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2487 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/engine/Context.hpp39
-rw-r--r--src/engine/JackDriver.cpp10
-rw-r--r--src/engine/ProcessContext.hpp23
-rw-r--r--src/engine/ProcessSlave.hpp2
-rw-r--r--src/engine/ingen.lv2/ingen_lv2.cpp2
5 files changed, 43 insertions, 33 deletions
diff --git a/src/engine/Context.hpp b/src/engine/Context.hpp
index a30706da..2a3bd7ca 100644
--- a/src/engine/Context.hpp
+++ b/src/engine/Context.hpp
@@ -25,6 +25,19 @@ namespace Ingen {
class Engine;
+
+/** Graph execution context.
+ *
+ * This is used to pass whatever information a GraphObject might need to
+ * process; such as the current time, a sink for generated events, etc.
+ *
+ * Note the logical distinction between nframes (jack relative) and start/end
+ * (timeline relative). If transport speed != 1.0, then end-start != nframes
+ * (though currently this is never the case, it may be if ingen incorporates
+ * tempo and varispeed).
+ *
+ * \ingroup engine
+ */
class Context
{
public:
@@ -34,12 +47,12 @@ public:
};
Context(Engine& engine, ID id)
- : _id(id)
- , _engine(engine)
+ : _engine(engine)
+ , _id(id)
, _event_sink(engine, event_queue_size)
, _start(0)
- , _nframes(0)
, _end(0)
+ , _nframes(0)
, _offset(0)
, _realtime(true)
{}
@@ -48,12 +61,24 @@ public:
ID id() const { return _id; }
- void locate(FrameTime s, SampleCount o=0) { _start = s; _offset=o; }
+ void locate(FrameTime s, SampleCount nframes, SampleCount offset) {
+ _start = s;
+ _end = s + nframes;
+ _nframes = nframes;
+ _offset = offset;
+ }
+
+ void locate(const Context& other) {
+ _start = other._start;
+ _end = other._end;
+ _nframes = other._nframes;
+ _offset = other._offset;
+ }
inline Engine& engine() const { return _engine; }
inline FrameTime start() const { return _start; }
- inline SampleCount nframes() const { return _nframes; }
inline FrameTime end() const { return _end; }
+ inline SampleCount nframes() const { return _nframes; }
inline SampleCount offset() const { return _offset; }
inline bool realtime() const { return _realtime; }
@@ -61,13 +86,13 @@ public:
inline EventSink& event_sink() { return _event_sink; }
protected:
- ID _id; ///< Fast ID for this context
Engine& _engine; ///< Engine we're running in
+ ID _id; ///< Fast ID for this context
EventSink _event_sink; ///< Sink for events generated in a realtime context
FrameTime _start; ///< Start frame of this cycle, timeline relative
- SampleCount _nframes; ///< Length of this cycle in frames
FrameTime _end; ///< End frame of this cycle, timeline relative
+ SampleCount _nframes; ///< Length of this cycle in frames
SampleCount _offset; ///< Start offset relative to start of driver buffers
bool _realtime; ///< True iff context is hard realtime
};
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 78b14121..a604aeae 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -413,15 +413,14 @@ JackDriver::_process_cb(jack_nframes_t nframes)
// Note that Jack can not call this function for a cycle, if overloaded
const jack_nframes_t start_of_current_cycle = jack_last_frame_time(_client);
- const jack_nframes_t end_of_current_cycle = start_of_current_cycle + nframes;
_transport_state = jack_transport_query(_client, &_position);
- _process_context.set_time_slice(nframes, 0, start_of_current_cycle, end_of_current_cycle);
+ _process_context.locate(start_of_current_cycle, nframes, 0);
for (Engine::ProcessSlaves::iterator i = _engine.process_slaves().begin();
i != _engine.process_slaves().end(); ++i) {
- (*i)->context().set_time_slice(nframes, 0, start_of_current_cycle, end_of_current_cycle);
+ (*i)->context().locate(start_of_current_cycle, nframes, 0);
}
// Read input
@@ -442,15 +441,12 @@ JackDriver::_process_cb(jack_nframes_t nframes)
if (_root_patch) {
_root_patch->process(_process_context);
#if 0
- const FrameTime cycle_start = _process_context.start();
static const SampleCount control_block_size = nframes / 2;
for (jack_nframes_t i = 0; i < nframes; i += control_block_size) {
const SampleCount block_size = (i + control_block_size < nframes)
? control_block_size
: nframes - i;
- _process_context.set_time_slice(block_size, i,
- cycle_start + i,
- cycle_start + i + block_size);
+ _process_context.locate(start_of_current_cycle + i, block_size, i);
_root_patch->process(_process_context);
}
#endif
diff --git a/src/engine/ProcessContext.hpp b/src/engine/ProcessContext.hpp
index fa8e3910..663fea78 100644
--- a/src/engine/ProcessContext.hpp
+++ b/src/engine/ProcessContext.hpp
@@ -25,30 +25,19 @@
namespace Ingen {
-/** Context of a process() call.
+/** Context of a process() call (the audio context).
*
- * This is used to pass whatever information a GraphObject might need to
- * process in the audio thread, e.g. the available thread pool, sink for
- * events (generated in the audio thread, not user initiated events), etc.
- *
- * Note the distinction between nframes and start/end. If transport speed
- * != 1.0, end-start != nframes (though currently that is never the case, it
- * may be in the future with sequencerey things).
+ * This class currently adds no functionality to Context, but the
+ * separate type is useful for writing functions that must only
+ * be run in the audio context (the function taking a ProcessContext
+ * parameter makes this clear, and makes breaking the rules obvious).
*
* \ingroup engine
*/
class ProcessContext : public Context
{
public:
- ProcessContext(Engine& engine)
- : Context(engine, AUDIO)
- {}
-
- void set_time_slice(SampleCount nframes, SampleCount offset, FrameTime start, FrameTime end) {
- locate(start, offset);
- _nframes = nframes;
- _end = end;
- }
+ ProcessContext(Engine& engine) : Context(engine, AUDIO) {}
};
diff --git a/src/engine/ProcessSlave.hpp b/src/engine/ProcessSlave.hpp
index f6efcb8e..cd7d5e8d 100644
--- a/src/engine/ProcessSlave.hpp
+++ b/src/engine/ProcessSlave.hpp
@@ -59,7 +59,7 @@ public:
_index = start_index;
_state = STATE_RUNNING;
_compiled_patch = compiled_patch;
- _process_context.set_time_slice(context.nframes(), context.offset(), context.start(), context.end());
+ _process_context.locate(context);
Raul::Slave::whip();
}
diff --git a/src/engine/ingen.lv2/ingen_lv2.cpp b/src/engine/ingen.lv2/ingen_lv2.cpp
index fb145c53..424df46c 100644
--- a/src/engine/ingen.lv2/ingen_lv2.cpp
+++ b/src/engine/ingen.lv2/ingen_lv2.cpp
@@ -48,7 +48,7 @@ struct IngenLV2Driver : public Ingen::Driver {
bool is_activated() const { return true; }
void run(uint32_t nframes) {
- _context.set_time_slice(nframes, _frame_time, _frame_time + nframes);
+ _context.locate(_frame_time, nframes, 0);
if (_root_patch)
_root_patch->process(_context);
_frame_time += nframes;