summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-11 05:14:11 +0000
committerDavid Robillard <d@drobilla.net>2012-05-11 05:14:11 +0000
commite684838068b6f8b37fe130195cdeb3a0f3b17ffd (patch)
treec3896b4039b875157a03d49f698a848c37957361 /src
parente64eabe64ee966364bc5f6704c5227687ea309d8 (diff)
downloadingen-e684838068b6f8b37fe130195cdeb3a0f3b17ffd.tar.gz
ingen-e684838068b6f8b37fe130195cdeb3a0f3b17ffd.tar.bz2
ingen-e684838068b6f8b37fe130195cdeb3a0f3b17ffd.zip
Move buffer stuff down to EnginePort.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4351 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/server/EnginePort.hpp12
-rw-r--r--src/server/JackDriver.cpp38
-rw-r--r--src/server/ingen_lv2.cpp5
3 files changed, 28 insertions, 27 deletions
diff --git a/src/server/EnginePort.hpp b/src/server/EnginePort.hpp
index 39f25d5c..7ba58871 100644
--- a/src/server/EnginePort.hpp
+++ b/src/server/EnginePort.hpp
@@ -19,9 +19,8 @@
#include <string>
-#include <boost/utility.hpp>
-
#include "raul/Deletable.hpp"
+#include "raul/Noncopyable.hpp"
#include "DuplexPort.hpp"
@@ -33,7 +32,7 @@ namespace Server {
class DuplexPort;
class ProcessContext;
-/** Representation of a "system" (eg outside Ingen) port.
+/** Representation of a "system" port (a port outside Ingen).
*
* This is the class through which the rest of the engine manages everything
* related to driver ports. Derived classes are expected to have a pointer to
@@ -41,8 +40,9 @@ class ProcessContext;
*
* \ingroup engine
*/
-class EnginePort : boost::noncopyable, public Raul::Deletable {
+class EnginePort : public Raul::Noncopyable, public Raul::Deletable {
public:
+ EnginePort() : _patch_port(NULL), _buffer(NULL) {}
virtual ~EnginePort() {}
/** Set the name of the system port according to new path */
@@ -54,6 +54,9 @@ public:
/** Destroy system port */
virtual void destroy() = 0;
+ void* buffer() const { return _buffer; }
+ void set_buffer(void* buf) { _buffer = buf; }
+
bool is_input() const { return _patch_port->is_input(); }
DuplexPort* patch_port() const { return _patch_port; }
@@ -61,6 +64,7 @@ protected:
explicit EnginePort(DuplexPort* port) : _patch_port(port) {}
DuplexPort* _patch_port;
+ void* _buffer;
};
} // namespace Server
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index edebff55..40644a08 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -110,29 +110,28 @@ JackPort::move(const Raul::Path& path)
void
JackPort::pre_process(ProcessContext& context)
{
- if (!is_input())
- return;
-
const SampleCount nframes = context.nframes();
+ _buffer = jack_port_get_buffer(_jack_port, nframes);
- if (_patch_port->is_a(PortType::AUDIO)) {
- jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(_jack_port, nframes);
- AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
+ if (!is_input()) {
+ return;
+ }
- patch_buf->copy(jack_buf, 0, nframes - 1);
+ if (_patch_port->is_a(PortType::AUDIO)) {
+ AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
+ patch_buf->copy((jack_sample_t*)_buffer, 0, nframes - 1);
} else if (_patch_port->buffer_type() == _patch_port->bufs().uris().atom_Sequence) {
- void* jack_buf = jack_port_get_buffer(_jack_port, nframes);
Buffer* patch_buf = (Buffer*)_patch_port->buffer(0).get();
- const jack_nframes_t event_count = jack_midi_get_event_count(jack_buf);
+ const jack_nframes_t event_count = jack_midi_get_event_count(_buffer);
patch_buf->prepare_write(context);
// Copy events from Jack port buffer into patch port buffer
for (jack_nframes_t i = 0; i < event_count; ++i) {
jack_midi_event_t ev;
- jack_midi_event_get(&ev, jack_buf, i);
+ jack_midi_event_get(&ev, _buffer, i);
if (!patch_buf->append_event(
ev.time, ev.size, _driver->_midi_event_type, ev.buffer)) {
@@ -145,29 +144,32 @@ JackPort::pre_process(ProcessContext& context)
void
JackPort::post_process(ProcessContext& context)
{
- if (is_input())
+ const SampleCount nframes = context.nframes();
+ if (is_input()) {
return;
+ }
- const SampleCount nframes = context.nframes();
+ if (!_buffer) {
+ // First cycle for a new outputs, so pre_process wasn't called
+ _buffer = jack_port_get_buffer(_jack_port, nframes);
+ }
if (_patch_port->is_a(PortType::AUDIO)) {
- jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(_jack_port, nframes);
- AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
+ AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
- memcpy(jack_buf, patch_buf->data(), nframes * sizeof(Sample));
+ memcpy(_buffer, patch_buf->data(), nframes * sizeof(Sample));
} else if (_patch_port->buffer_type() == _patch_port->bufs().uris().atom_Sequence) {
- void* jack_buf = jack_port_get_buffer(_jack_port, context.nframes());
Buffer* patch_buf = (Buffer*)_patch_port->buffer(0).get();
patch_buf->prepare_read(context);
- jack_midi_clear_buffer(jack_buf);
+ jack_midi_clear_buffer(_buffer);
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)patch_buf->atom();
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
if (ev->body.type == _patch_port->bufs().uris().midi_MidiEvent) {
- jack_midi_event_write(jack_buf, ev->time.frames, buf, ev->body.size);
+ jack_midi_event_write(_buffer, ev->time.frames, buf, ev->body.size);
}
}
}
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 0de22ed3..34d8003f 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -87,7 +87,6 @@ public:
LV2Port(LV2Driver* driver, DuplexPort* patch_port)
: EnginePort(patch_port)
, _driver(driver)
- , _buffer(NULL)
{}
// TODO: LV2 dynamic ports
@@ -123,12 +122,8 @@ public:
}
}
- void* buffer() const { return _buffer; }
- void set_buffer(void* buf) { _buffer = buf; }
-
private:
LV2Driver* _driver;
- void* _buffer;
};
class LV2Driver : public Ingen::Server::Driver