summaryrefslogtreecommitdiffstats
path: root/src/server/JackDriver.cpp
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/server/JackDriver.cpp
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/server/JackDriver.cpp')
-rw-r--r--src/server/JackDriver.cpp38
1 files changed, 20 insertions, 18 deletions
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);
}
}
}