From 5f11a5b2d3e040739bdebada9bab387075e1e177 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 23 May 2012 02:21:53 +0000 Subject: Fix copying of audio buffers and polyphonic audio output. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4445 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/AudioBuffer.cpp | 9 ++++++--- src/server/Buffer.cpp | 2 +- src/server/JackDriver.cpp | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/AudioBuffer.cpp b/src/server/AudioBuffer.cpp index 16a79bc0..a3c87fea 100644 --- a/src/server/AudioBuffer.cpp +++ b/src/server/AudioBuffer.cpp @@ -45,9 +45,12 @@ AudioBuffer::AudioBuffer(BufferFactory& bufs, LV2_URID type, uint32_t size) if (type == bufs.uris().atom_Sound) { // Audio port (Vector of float) - LV2_Atom_Vector* body = (LV2_Atom_Vector*)atom(); - body->body.child_size = sizeof(float); - body->body.child_type = bufs.uris().atom_Float; + LV2_Atom_Vector* vec = (LV2_Atom_Vector*)_atom; + vec->body.child_size = sizeof(float); + vec->body.child_type = bufs.uris().atom_Float; + _atom->size = size - sizeof(LV2_Atom_Vector); + } else { + _atom->size = size - sizeof(LV2_Atom); } _atom->type = type; diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index 4bc39c12..30a0781c 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -89,7 +89,7 @@ void Buffer::copy(Context& context, const Buffer* src) { // Copy only if src is a POD object that fits - if (src->_atom->type != 0 && sizeof(LV2_Atom) + src->_atom->size <= capacity()) { + if (src->_atom->type != 0 && sizeof(LV2_Atom) + src->_atom->size <= capacity()) { memcpy(_atom, src->_atom, sizeof(LV2_Atom) + src->_atom->size); } assert(_atom->type != 1); diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 30673316..45b168f9 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -113,6 +113,7 @@ JackPort::pre_process(ProcessContext& context) _buffer = jack_port_get_buffer(_jack_port, nframes); if (!is_input()) { + ((AudioBuffer*)_patch_port->buffer(0).get())->clear(); return; } @@ -149,10 +150,11 @@ JackPort::post_process(ProcessContext& context) } if (!_buffer) { - // First cycle for a new outputs, so pre_process wasn't called + // First cycle for a new output, so pre_process wasn't called _buffer = jack_port_get_buffer(_jack_port, nframes); } + _patch_port->post_process(context); if (_patch_port->is_a(PortType::AUDIO)) { AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); -- cgit v1.2.1