| @@ -1094,9 +1094,20 @@ LIB_EXPORT jack_port_t* jack_port_register(jack_client_t* ext_client, const char | |||
| } else if ((port_name == NULL) || (port_type == NULL)) { | |||
| jack_error("jack_port_register called with a NULL port name or a NULL port_type"); | |||
| return NULL; | |||
| } | |||
| if (strcmp(port_type, JACK_DEFAULT_AUDIO_TYPE) == 0) { | |||
| // Don't change anything | |||
| } else if (strcmp(port_type, JACK_DEFAULT_MESSAGE_TYPE) == 0) { | |||
| // Don't change anything | |||
| } else if (strcmp(port_type, JACK_DEFAULT_MIDI_TYPE) == 0) { | |||
| // Rename the old port type | |||
| port_type = JACK_DEFAULT_MESSAGE_TYPE; | |||
| } else { | |||
| return (jack_port_t *)((uintptr_t)client->PortRegister(port_name, port_type, flags, buffer_size)); | |||
| jack_info("jack_port_register called with a non-default port_type: '%s'.", port_type); | |||
| } | |||
| return (jack_port_t *)((uintptr_t)client->PortRegister(port_name, port_type, flags, buffer_size)); | |||
| } | |||
| LIB_EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port) | |||
| @@ -0,0 +1,160 @@ | |||
| /* | |||
| Copyright (C) 2007 Dmitry Baikov | |||
| Original JACK MIDI implementation Copyright (C) 2004 Ian Esten | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU Lesser General Public License as published by | |||
| the Free Software Foundation; either version 2.1 of the License, or | |||
| (at your option) any later version. | |||
| This program is distributed in the hope that it will be useful, | |||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| GNU Lesser General Public License for more details. | |||
| You should have received a copy of the GNU Lesser General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackError.h" | |||
| #include "JackEventPort.h" | |||
| #include <errno.h> | |||
| #include <string.h> | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| { | |||
| #endif | |||
| LIB_EXPORT uint32_t jack_event_get_count(void* port_buffer); | |||
| LIB_EXPORT int jack_event_get(jack_event_t* event, | |||
| void* port_buffer, uint32_t event_index); | |||
| LIB_EXPORT void jack_event_clear_buffer(void* port_buffer); | |||
| LIB_EXPORT void jack_event_reset_buffer(void* port_buffer); | |||
| LIB_EXPORT size_t jack_event_max_size(void* port_buffer); | |||
| LIB_EXPORT jack_event_data_t* jack_event_reserve(void* port_buffer, | |||
| jack_nframes_t time, size_t data_size); | |||
| LIB_EXPORT int jack_event_write(void* port_buffer, | |||
| jack_nframes_t time, const jack_event_data_t* data, size_t data_size); | |||
| LIB_EXPORT jack_nframes_t jack_event_get_lost_count(void* port_buffer); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| using namespace Jack; | |||
| LIB_EXPORT | |||
| uint32_t jack_event_get_count(void* port_buffer) | |||
| { | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (!buf || !buf->IsValid()) { | |||
| return 0; | |||
| } | |||
| return buf->event_count; | |||
| } | |||
| LIB_EXPORT | |||
| int jack_event_get(jack_event_t *event, void* port_buffer, uint32_t event_index) | |||
| { | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (!buf || !buf->IsValid()) { | |||
| return -EINVAL; | |||
| } | |||
| if (event_index >= buf->event_count) { | |||
| return -ENOBUFS; | |||
| } | |||
| JackEvent* ev = &buf->events[event_index]; | |||
| event->time = ev->time; | |||
| event->size = ev->size; | |||
| event->buffer = ev->GetData(buf); | |||
| return 0; | |||
| } | |||
| LIB_EXPORT | |||
| void jack_event_clear_buffer(void* port_buffer) | |||
| { | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (buf && buf->IsValid()) { | |||
| buf->Reset(buf->nframes); | |||
| } | |||
| } | |||
| LIB_EXPORT | |||
| void jack_event_reset_buffer(void* port_buffer) | |||
| { | |||
| EventBufferInit(port_buffer, BUFFER_SIZE_MAX, BUFFER_SIZE_MAX); | |||
| } | |||
| LIB_EXPORT | |||
| size_t jack_event_max_size(void* port_buffer) | |||
| { | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (buf && buf->IsValid()) { | |||
| return buf->MaxEventSize(); | |||
| } | |||
| return 0; | |||
| } | |||
| LIB_EXPORT | |||
| jack_event_data_t* jack_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size) | |||
| { | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (! buf) { | |||
| jack_error("jack_event_reserve: port buffer is set to NULL"); | |||
| return 0; | |||
| } | |||
| if (! buf->IsValid()) { | |||
| jack_error("jack_event_reserve: port buffer is invalid"); | |||
| return 0; | |||
| } | |||
| if (time >= buf->nframes) { | |||
| jack_error("jack_event_reserve: time parameter is out of range " | |||
| "(%lu >= %lu)", time, buf->nframes); | |||
| return 0; | |||
| } | |||
| if (buf->event_count && (buf->events[buf->event_count - 1].time > time)) { | |||
| jack_error("jack_event_reserve: time parameter is earlier than " | |||
| "last reserved event"); | |||
| return 0; | |||
| } | |||
| return buf->ReserveEvent(time, data_size); | |||
| } | |||
| LIB_EXPORT | |||
| int jack_event_write(void* port_buffer, | |||
| jack_nframes_t time, const jack_event_data_t* data, size_t data_size) | |||
| { | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (!buf || !buf->IsValid()) { | |||
| return -EINVAL; | |||
| } | |||
| if (time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time)) { | |||
| return -EINVAL; | |||
| } | |||
| jack_event_data_t* dest = buf->ReserveEvent(time, data_size); | |||
| if (!dest) { | |||
| return -ENOBUFS; | |||
| } | |||
| memcpy(dest, data, data_size); | |||
| return 0; | |||
| } | |||
| LIB_EXPORT | |||
| uint32_t jack_event_get_lost_count(void* port_buffer) | |||
| { | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (buf && buf->IsValid()) { | |||
| return buf->lost_events; | |||
| } | |||
| return 0; | |||
| } | |||
| @@ -19,14 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #include <new> | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackEventAsyncQueue.h" | |||
| using Jack::JackMidiAsyncQueue; | |||
| using Jack::JackEventAsyncQueue; | |||
| JackMidiAsyncQueue::JackMidiAsyncQueue(size_t max_bytes, size_t max_messages) | |||
| JackEventAsyncQueue::JackEventAsyncQueue(size_t max_bytes, size_t max_messages) | |||
| { | |||
| data_buffer = new jack_midi_data_t[max_bytes]; | |||
| byte_ring = jack_ringbuffer_create((max_bytes * sizeof(jack_midi_data_t)) + | |||
| data_buffer = new jack_event_data_t[max_bytes]; | |||
| byte_ring = jack_ringbuffer_create((max_bytes * sizeof(jack_event_data_t)) + | |||
| 1); | |||
| if (byte_ring) { | |||
| info_ring = jack_ringbuffer_create((max_messages * INFO_SIZE) + 1); | |||
| @@ -42,17 +42,17 @@ JackMidiAsyncQueue::JackMidiAsyncQueue(size_t max_bytes, size_t max_messages) | |||
| throw std::bad_alloc(); | |||
| } | |||
| JackMidiAsyncQueue::~JackMidiAsyncQueue() | |||
| JackEventAsyncQueue::~JackEventAsyncQueue() | |||
| { | |||
| jack_ringbuffer_free(byte_ring); | |||
| jack_ringbuffer_free(info_ring); | |||
| delete[] data_buffer; | |||
| } | |||
| jack_midi_event_t * | |||
| JackMidiAsyncQueue::DequeueEvent() | |||
| jack_event_t * | |||
| JackEventAsyncQueue::DequeueEvent() | |||
| { | |||
| jack_midi_event_t *event = 0; | |||
| jack_event_t *event = 0; | |||
| if (jack_ringbuffer_read_space(info_ring) >= INFO_SIZE) { | |||
| size_t size; | |||
| event = &dequeue_event; | |||
| @@ -61,27 +61,27 @@ JackMidiAsyncQueue::DequeueEvent() | |||
| jack_ringbuffer_read(info_ring, (char *) &size, | |||
| sizeof(size_t)); | |||
| jack_ringbuffer_read(byte_ring, (char *) data_buffer, | |||
| size * sizeof(jack_midi_data_t)); | |||
| size * sizeof(jack_event_data_t)); | |||
| event->buffer = data_buffer; | |||
| event->size = size; | |||
| } | |||
| return event; | |||
| } | |||
| Jack::JackMidiWriteQueue::EnqueueResult | |||
| JackMidiAsyncQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer) | |||
| Jack::JackEventWriteQueue::EnqueueResult | |||
| JackEventAsyncQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_event_data_t *buffer) | |||
| { | |||
| if (size > max_bytes) { | |||
| return BUFFER_TOO_SMALL; | |||
| } | |||
| if (! ((jack_ringbuffer_write_space(info_ring) >= INFO_SIZE) && | |||
| (jack_ringbuffer_write_space(byte_ring) >= | |||
| (size * sizeof(jack_midi_data_t))))) { | |||
| (size * sizeof(jack_event_data_t))))) { | |||
| return BUFFER_FULL; | |||
| } | |||
| jack_ringbuffer_write(byte_ring, (const char *) buffer, | |||
| size * sizeof(jack_midi_data_t)); | |||
| size * sizeof(jack_event_data_t)); | |||
| jack_ringbuffer_write(info_ring, (const char *) (&time), | |||
| sizeof(jack_nframes_t)); | |||
| jack_ringbuffer_write(info_ring, (const char *) (&size), sizeof(size_t)); | |||
| @@ -89,7 +89,7 @@ JackMidiAsyncQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| } | |||
| size_t | |||
| JackMidiAsyncQueue::GetAvailableSpace() | |||
| JackEventAsyncQueue::GetAvailableSpace() | |||
| { | |||
| return jack_ringbuffer_write_space(info_ring) < INFO_SIZE ? 0 : | |||
| max_bytes - jack_ringbuffer_read_space(byte_ring); | |||
| @@ -17,28 +17,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiAsyncQueue__ | |||
| #define __JackMidiAsyncQueue__ | |||
| #ifndef __JackEventAsyncQueue__ | |||
| #define __JackEventAsyncQueue__ | |||
| #include "JackMidiPort.h" | |||
| #include "JackMidiReadQueue.h" | |||
| #include "JackMidiWriteQueue.h" | |||
| #include "JackEventPort.h" | |||
| #include "JackEventReadQueue.h" | |||
| #include "JackEventWriteQueue.h" | |||
| #include "ringbuffer.h" | |||
| namespace Jack { | |||
| /** | |||
| * This is a MIDI message queue designed to allow one thread to pass MIDI | |||
| * This is a event message queue designed to allow one thread to pass event | |||
| * messages to another thread (though it can also be used to buffer events | |||
| * internally). This is especially useful if the MIDI API you're | |||
| * internally). This is especially useful if the event API you're | |||
| * attempting to interface with doesn't provide the ability to schedule | |||
| * MIDI events ahead of time and/or has blocking send/receive calls, as it | |||
| * events ahead of time and/or has blocking send/receive calls, as it | |||
| * allows a separate thread to handle input/output while the JACK process | |||
| * thread copies events from a MIDI buffer to this queue, or vice versa. | |||
| * thread copies events from a buffer to this queue, or vice versa. | |||
| */ | |||
| class SERVER_EXPORT JackMidiAsyncQueue: | |||
| public JackMidiReadQueue, public JackMidiWriteQueue { | |||
| class SERVER_EXPORT JackEventAsyncQueue: | |||
| public JackEventReadQueue, public JackEventWriteQueue { | |||
| private: | |||
| @@ -46,43 +46,43 @@ namespace Jack { | |||
| sizeof(jack_nframes_t) + sizeof(size_t); | |||
| jack_ringbuffer_t *byte_ring; | |||
| jack_midi_data_t *data_buffer; | |||
| jack_midi_event_t dequeue_event; | |||
| jack_event_data_t *data_buffer; | |||
| jack_event_t dequeue_event; | |||
| jack_ringbuffer_t *info_ring; | |||
| size_t max_bytes; | |||
| public: | |||
| using JackMidiWriteQueue::EnqueueEvent; | |||
| using JackEventWriteQueue::EnqueueEvent; | |||
| /** | |||
| * Creates a new asynchronous MIDI message queue. The queue can store | |||
| * up to `max_messages` MIDI messages and up to `max_bytes` of MIDI | |||
| * Creates a new asynchronous event message queue. The queue can store | |||
| * up to `max_messages` messages and up to `max_bytes` of | |||
| * data before it starts rejecting messages. | |||
| */ | |||
| JackMidiAsyncQueue(size_t max_bytes=4096, size_t max_messages=1024); | |||
| JackEventAsyncQueue(size_t max_bytes=4096, size_t max_messages=1024); | |||
| virtual | |||
| ~JackMidiAsyncQueue(); | |||
| ~JackEventAsyncQueue(); | |||
| /** | |||
| * Dequeues and returns a MIDI event. Returns '0' if there are no MIDI | |||
| * events available. This method may be overridden. | |||
| * Dequeues and returns an event. Returns '0' if there are none | |||
| * available. This method may be overridden. | |||
| */ | |||
| virtual jack_midi_event_t * | |||
| virtual jack_event_t * | |||
| DequeueEvent(); | |||
| /** | |||
| * Enqueues the MIDI event specified by the arguments. The return | |||
| * Enqueues the event specified by the arguments. The return | |||
| * value indicates whether or not the event was successfully enqueued. | |||
| * This method may be overridden. | |||
| */ | |||
| virtual EnqueueResult | |||
| EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer); | |||
| jack_event_data_t *buffer); | |||
| /** | |||
| * Returns the maximum size event that can be enqueued right *now*. | |||
| @@ -19,34 +19,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #include <new> | |||
| #include "JackMidiAsyncWaitQueue.h" | |||
| #include "JackEventAsyncWaitQueue.h" | |||
| #include "JackMidiUtil.h" | |||
| #include "JackTime.h" | |||
| using Jack::JackMidiAsyncWaitQueue; | |||
| using Jack::JackEventAsyncWaitQueue; | |||
| JackMidiAsyncWaitQueue::JackMidiAsyncWaitQueue(size_t max_bytes, | |||
| JackEventAsyncWaitQueue::JackEventAsyncWaitQueue(size_t max_bytes, | |||
| size_t max_messages): | |||
| JackMidiAsyncQueue(max_bytes, max_messages) | |||
| JackEventAsyncQueue(max_bytes, max_messages) | |||
| { | |||
| if (semaphore.Allocate("JackMidiAsyncWaitQueue", "midi-thread", 0)) { | |||
| if (semaphore.Allocate("JackEventAsyncWaitQueue", "event-thread", 0)) { | |||
| throw std::bad_alloc(); | |||
| } | |||
| } | |||
| JackMidiAsyncWaitQueue::~JackMidiAsyncWaitQueue() | |||
| JackEventAsyncWaitQueue::~JackEventAsyncWaitQueue() | |||
| { | |||
| semaphore.Destroy(); | |||
| } | |||
| jack_midi_event_t * | |||
| JackMidiAsyncWaitQueue::DequeueEvent() | |||
| jack_event_t * | |||
| JackEventAsyncWaitQueue::DequeueEvent() | |||
| { | |||
| return DequeueEvent((long) 0); | |||
| } | |||
| jack_midi_event_t * | |||
| JackMidiAsyncWaitQueue::DequeueEvent(jack_nframes_t frame) | |||
| jack_event_t * | |||
| JackEventAsyncWaitQueue::DequeueEvent(jack_nframes_t frame) | |||
| { | |||
| // XXX: I worry about timer resolution on Solaris and Windows. When the | |||
| @@ -65,18 +65,18 @@ JackMidiAsyncWaitQueue::DequeueEvent(jack_nframes_t frame) | |||
| (long) (frame_time - current_time)); | |||
| } | |||
| jack_midi_event_t * | |||
| JackMidiAsyncWaitQueue::DequeueEvent(long usec) | |||
| jack_event_t * | |||
| JackEventAsyncWaitQueue::DequeueEvent(long usec) | |||
| { | |||
| return ((usec < 0) ? semaphore.Wait() : semaphore.TimedWait(usec)) ? | |||
| JackMidiAsyncQueue::DequeueEvent() : 0; | |||
| JackEventAsyncQueue::DequeueEvent() : 0; | |||
| } | |||
| Jack::JackMidiWriteQueue::EnqueueResult | |||
| JackMidiAsyncWaitQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer) | |||
| Jack::JackEventWriteQueue::EnqueueResult | |||
| JackEventAsyncWaitQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_event_data_t *buffer) | |||
| { | |||
| EnqueueResult result = JackMidiAsyncQueue::EnqueueEvent(time, size, | |||
| EnqueueResult result = JackEventAsyncQueue::EnqueueEvent(time, size, | |||
| buffer); | |||
| if (result == OK) { | |||
| semaphore.Signal(); | |||
| @@ -17,26 +17,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiAsyncWaitQueue__ | |||
| #define __JackMidiAsyncWaitQueue__ | |||
| #ifndef __JackEventAsyncWaitQueue__ | |||
| #define __JackEventAsyncWaitQueue__ | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackEventAsyncQueue.h" | |||
| namespace Jack { | |||
| /** | |||
| * This is an asynchronous wait queue that allows a thread to wait for a | |||
| * message, either indefinitely or for a specified time. This is one | |||
| * example of a way that the `JackMidiAsyncQueue` class can be extended so | |||
| * that process threads can interact with non-process threads to send MIDI | |||
| * example of a way that the `JackEventAsyncQueue` class can be extended so | |||
| * that process threads can interact with non-process threads to send | |||
| * events. | |||
| * | |||
| * XXX: As of right now, this code hasn't been tested. Also, note the | |||
| * warning in the JackMidiAsyncWaitQueue.cpp about semaphore wait | |||
| * warning in the JackEventAsyncWaitQueue.cpp about semaphore wait | |||
| * resolution. | |||
| */ | |||
| class SERVER_EXPORT JackMidiAsyncWaitQueue: public JackMidiAsyncQueue { | |||
| class SERVER_EXPORT JackEventAsyncWaitQueue: public JackEventAsyncQueue { | |||
| private: | |||
| @@ -44,53 +44,53 @@ namespace Jack { | |||
| public: | |||
| using JackMidiAsyncQueue::EnqueueEvent; | |||
| using JackEventAsyncQueue::EnqueueEvent; | |||
| /** | |||
| * Creates a new asynchronous MIDI wait message queue. The queue can | |||
| * store up to `max_messages` MIDI messages and up to `max_bytes` of | |||
| * MIDI data before it starts rejecting messages. | |||
| * Creates a new asynchronous wait message queue. The queue can | |||
| * store up to `max_messages` messages and up to `max_bytes` of | |||
| * messagea data before it starts rejecting messages. | |||
| */ | |||
| JackMidiAsyncWaitQueue(size_t max_bytes=4096, | |||
| JackEventAsyncWaitQueue(size_t max_bytes=4096, | |||
| size_t max_messages=1024); | |||
| ~JackMidiAsyncWaitQueue(); | |||
| ~JackEventAsyncWaitQueue(); | |||
| /** | |||
| * Dequeues and returns a MIDI event. Returns '0' if there are no MIDI | |||
| * events available right now. | |||
| */ | |||
| jack_midi_event_t * | |||
| jack_event_t * | |||
| DequeueEvent(); | |||
| /** | |||
| * Waits a specified time for a MIDI event to be available, or | |||
| * indefinitely if the time is negative. Returns the MIDI event, or | |||
| * '0' if time runs out and no MIDI event is available. | |||
| * Waits a specified time for an event to be available, or | |||
| * indefinitely if the time is negative. Returns the event, or | |||
| * '0' if time runs out and no event is available. | |||
| */ | |||
| jack_midi_event_t * | |||
| jack_event_t * | |||
| DequeueEvent(long usecs); | |||
| /** | |||
| * Waits until the specified frame for a MIDI event to be available. | |||
| * Returns the MIDI event, or '0' if time runs out and no MIDI event is | |||
| * Waits until the specified frame for an event to be available. | |||
| * Returns the event, or '0' if time runs out and no event is | |||
| * available. | |||
| */ | |||
| jack_midi_event_t * | |||
| jack_event_t * | |||
| DequeueEvent(jack_nframes_t frame); | |||
| /** | |||
| * Enqueues the MIDI event specified by the arguments. The return | |||
| * Enqueues the event specified by the arguments. The return | |||
| * value indicates whether or not the event was successfully enqueued. | |||
| */ | |||
| EnqueueResult | |||
| EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer); | |||
| jack_event_data_t *buffer); | |||
| }; | |||
| @@ -17,48 +17,48 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackMidiBufferReadQueue.h" | |||
| #include "JackEventBufferReadQueue.h" | |||
| #include "JackMidiUtil.h" | |||
| #include "JackError.h" | |||
| using Jack::JackMidiBufferReadQueue; | |||
| using Jack::JackEventBufferReadQueue; | |||
| JackMidiBufferReadQueue::JackMidiBufferReadQueue() | |||
| JackEventBufferReadQueue::JackEventBufferReadQueue() | |||
| { | |||
| event_count = 0; | |||
| index = 0; | |||
| } | |||
| jack_midi_event_t * | |||
| JackMidiBufferReadQueue::DequeueEvent() | |||
| jack_event_t * | |||
| JackEventBufferReadQueue::DequeueEvent() | |||
| { | |||
| jack_midi_event_t *e = 0; | |||
| jack_event_t *e = 0; | |||
| if (index < event_count) { | |||
| JackMidiEvent *event = &(buffer->events[index]); | |||
| midi_event.buffer = event->GetData(buffer); | |||
| midi_event.size = event->size; | |||
| midi_event.time = last_frame_time + event->time; | |||
| e = &midi_event; | |||
| JackEvent *jack_event = &(buffer->events[index]); | |||
| event.buffer = jack_event->GetData(buffer); | |||
| event.size = jack_event->size; | |||
| event.time = last_frame_time + jack_event->time; | |||
| e = &event; | |||
| index++; | |||
| } | |||
| return e; | |||
| } | |||
| void | |||
| JackMidiBufferReadQueue::ResetMidiBuffer(JackMidiBuffer *buffer) | |||
| JackEventBufferReadQueue::ResetEventBuffer(JackEventBuffer *buffer) | |||
| { | |||
| event_count = 0; | |||
| index = 0; | |||
| if (! buffer) { | |||
| jack_error("JackMidiBufferReadQueue::ResetMidiBuffer - buffer reset " | |||
| jack_error("JackEventBufferReadQueue::ResetEventBuffer - buffer reset " | |||
| "to NULL"); | |||
| } else if (! buffer->IsValid()) { | |||
| jack_error("JackMidiBufferReadQueue::ResetMidiBuffer - buffer reset " | |||
| jack_error("JackEventBufferReadQueue::ResetEventBuffer - buffer reset " | |||
| "to invalid buffer"); | |||
| } else { | |||
| uint32_t lost_events = buffer->lost_events; | |||
| if (lost_events) { | |||
| jack_error("JackMidiBufferReadQueue::ResetMidiBuffer - %d events " | |||
| jack_error("JackEventBufferReadQueue::ResetEventBuffer - %d events " | |||
| "lost during mixdown", lost_events); | |||
| } | |||
| this->buffer = buffer; | |||
| @@ -17,41 +17,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiBufferReadQueue__ | |||
| #define __JackMidiBufferReadQueue__ | |||
| #ifndef __JackEventBufferReadQueue__ | |||
| #define __JackEventBufferReadQueue__ | |||
| #include "JackMidiReadQueue.h" | |||
| #include "JackEventReadQueue.h" | |||
| namespace Jack { | |||
| /** | |||
| * Wrapper class to present a JackMidiBuffer in a read queue interface. | |||
| * Wrapper class to present a JackEventBuffer in a read queue interface. | |||
| */ | |||
| class SERVER_EXPORT JackMidiBufferReadQueue: public JackMidiReadQueue { | |||
| class SERVER_EXPORT JackEventBufferReadQueue: public JackEventReadQueue { | |||
| private: | |||
| JackMidiBuffer *buffer; | |||
| JackEventBuffer *buffer; | |||
| jack_nframes_t event_count; | |||
| jack_nframes_t index; | |||
| jack_nframes_t last_frame_time; | |||
| jack_midi_event_t midi_event; | |||
| jack_event_t event; | |||
| public: | |||
| JackMidiBufferReadQueue(); | |||
| JackEventBufferReadQueue(); | |||
| jack_midi_event_t * | |||
| jack_event_t * | |||
| DequeueEvent(); | |||
| /** | |||
| * This method must be called each period to reset the MIDI buffer for | |||
| * This method must be called each period to reset the buffer for | |||
| * processing. | |||
| */ | |||
| void | |||
| ResetMidiBuffer(JackMidiBuffer *buffer); | |||
| ResetEventBuffer(JackEventBuffer *buffer); | |||
| void | |||
| ResetMidiBuffer(JackEventBuffer *buffer) { | |||
| ResetEventBuffer(buffer); | |||
| } | |||
| }; | |||
| @@ -17,20 +17,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackMidiBufferWriteQueue.h" | |||
| #include "JackEventBufferWriteQueue.h" | |||
| #include "JackMidiUtil.h" | |||
| #include "JackError.h" | |||
| using Jack::JackMidiBufferWriteQueue; | |||
| using Jack::JackEventBufferWriteQueue; | |||
| JackMidiBufferWriteQueue::JackMidiBufferWriteQueue() | |||
| JackEventBufferWriteQueue::JackEventBufferWriteQueue() | |||
| { | |||
| // Empty | |||
| } | |||
| Jack::JackMidiWriteQueue::EnqueueResult | |||
| JackMidiBufferWriteQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *data) | |||
| Jack::JackEventWriteQueue::EnqueueResult | |||
| JackEventBufferWriteQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_event_data_t *data) | |||
| { | |||
| if (time >= next_frame_time) { | |||
| return EVENT_EARLY; | |||
| @@ -38,7 +38,7 @@ JackMidiBufferWriteQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| if (time < last_frame_time) { | |||
| time = last_frame_time; | |||
| } | |||
| jack_midi_data_t *dst = buffer->ReserveEvent(time - last_frame_time, size); | |||
| jack_event_data_t *dst = buffer->ReserveEvent(time - last_frame_time, size); | |||
| if (! dst) { | |||
| return size > max_bytes ? BUFFER_TOO_SMALL : BUFFER_FULL; | |||
| } | |||
| @@ -47,14 +47,14 @@ JackMidiBufferWriteQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| } | |||
| void | |||
| JackMidiBufferWriteQueue::ResetMidiBuffer(JackMidiBuffer *buffer, | |||
| JackEventBufferWriteQueue::ResetEventBuffer(JackEventBuffer *buffer, | |||
| jack_nframes_t frames) | |||
| { | |||
| if (! buffer) { | |||
| jack_error("JackMidiBufferWriteQueue::ResetMidiBuffer - buffer reset " | |||
| jack_error("JackEventBufferWriteQueue::ResetEventBuffer - buffer reset " | |||
| "to NULL"); | |||
| } else if (! buffer->IsValid()) { | |||
| jack_error("JackMidiBufferWriteQueue::ResetMidiBuffer - buffer reset " | |||
| jack_error("JackEventBufferWriteQueue::ResetEventBuffer - buffer reset " | |||
| "to invalid buffer"); | |||
| } else { | |||
| this->buffer = buffer; | |||
| @@ -17,43 +17,48 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiBufferWriteQueue__ | |||
| #define __JackMidiBufferWriteQueue__ | |||
| #ifndef __JackEventBufferWriteQueue__ | |||
| #define __JackEventBufferWriteQueue__ | |||
| #include "JackMidiWriteQueue.h" | |||
| #include "JackEventWriteQueue.h" | |||
| namespace Jack { | |||
| /** | |||
| * Wrapper class to present a JackMidiBuffer in a write queue interface. | |||
| * Wrapper class to present a JackEventBuffer in a write queue interface. | |||
| */ | |||
| class SERVER_EXPORT JackMidiBufferWriteQueue: public JackMidiWriteQueue { | |||
| class SERVER_EXPORT JackEventBufferWriteQueue: public JackEventWriteQueue { | |||
| private: | |||
| JackMidiBuffer *buffer; | |||
| JackEventBuffer *buffer; | |||
| jack_nframes_t last_frame_time; | |||
| size_t max_bytes; | |||
| jack_nframes_t next_frame_time; | |||
| public: | |||
| using JackMidiWriteQueue::EnqueueEvent; | |||
| using JackEventWriteQueue::EnqueueEvent; | |||
| JackMidiBufferWriteQueue(); | |||
| JackEventBufferWriteQueue(); | |||
| EnqueueResult | |||
| EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer); | |||
| jack_event_data_t *buffer); | |||
| /** | |||
| * This method must be called each period to reset the MIDI buffer for | |||
| * This method must be called each period to reset the buffer for | |||
| * processing. | |||
| */ | |||
| void | |||
| ResetMidiBuffer(JackMidiBuffer *buffer, jack_nframes_t frames); | |||
| ResetEventBuffer(JackEventBuffer *buffer, jack_nframes_t frames); | |||
| void | |||
| ResetMidiBuffer(JackEventBuffer *buffer, jack_nframes_t frames) { | |||
| ResetEventBuffer(buffer, frames); | |||
| } | |||
| }; | |||
| @@ -21,14 +21,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #include "JackError.h" | |||
| #include "JackPortType.h" | |||
| #include "JackMidiPort.h" | |||
| #include "JackEventPort.h" | |||
| #include <assert.h> | |||
| #include <string.h> | |||
| namespace Jack | |||
| { | |||
| SERVER_EXPORT void JackMidiBuffer::Reset(jack_nframes_t nframes) | |||
| SERVER_EXPORT void JackEventBuffer::Reset(jack_nframes_t nframes) | |||
| { | |||
| /* This line ate 1 hour of my life... dsbaikov */ | |||
| this->nframes = nframes; | |||
| @@ -37,48 +37,48 @@ SERVER_EXPORT void JackMidiBuffer::Reset(jack_nframes_t nframes) | |||
| lost_events = 0; | |||
| } | |||
| SERVER_EXPORT jack_shmsize_t JackMidiBuffer::MaxEventSize() const | |||
| SERVER_EXPORT jack_shmsize_t JackEventBuffer::MaxEventSize() const | |||
| { | |||
| assert (((jack_shmsize_t) - 1) < 0); // jack_shmsize_t should be signed | |||
| jack_shmsize_t left = buffer_size - (sizeof(JackMidiBuffer) + sizeof(JackMidiEvent) * (event_count + 1) + write_pos); | |||
| jack_shmsize_t left = buffer_size - (sizeof(JackEventBuffer) + sizeof(JackEvent) * (event_count + 1) + write_pos); | |||
| if (left < 0) { | |||
| return 0; | |||
| } | |||
| if (left <= JackMidiEvent::INLINE_SIZE_MAX) { | |||
| return JackMidiEvent::INLINE_SIZE_MAX; | |||
| if (left <= JackEvent::INLINE_SIZE_MAX) { | |||
| return JackEvent::INLINE_SIZE_MAX; | |||
| } | |||
| return left; | |||
| } | |||
| SERVER_EXPORT jack_midi_data_t* JackMidiBuffer::ReserveEvent(jack_nframes_t time, jack_shmsize_t size) | |||
| SERVER_EXPORT jack_event_data_t* JackEventBuffer::ReserveEvent(jack_nframes_t time, jack_shmsize_t size) | |||
| { | |||
| jack_shmsize_t space = MaxEventSize(); | |||
| if (space == 0 || size > space) { | |||
| jack_error("JackMidiBuffer::ReserveEvent - the buffer does not have " | |||
| jack_error("JackEventBuffer::ReserveEvent - the buffer does not have " | |||
| "enough room to enqueue a %lu byte event", size); | |||
| lost_events++; | |||
| return 0; | |||
| } | |||
| JackMidiEvent* event = &events[event_count++]; | |||
| JackEvent* event = &events[event_count++]; | |||
| event->time = time; | |||
| event->size = size; | |||
| if (size <= JackMidiEvent::INLINE_SIZE_MAX) { | |||
| if (size <= JackEvent::INLINE_SIZE_MAX) { | |||
| return event->data; | |||
| } | |||
| write_pos += size; | |||
| event->offset = buffer_size - write_pos; | |||
| return (jack_midi_data_t*)this + event->offset; | |||
| return (jack_event_data_t*)this + event->offset; | |||
| } | |||
| void MidiBufferInit(void* buffer, size_t buffer_size, jack_nframes_t nframes) | |||
| void EventBufferInit(void* buffer, size_t buffer_size, jack_nframes_t nframes) | |||
| { | |||
| JackMidiBuffer* midi = (JackMidiBuffer*)buffer; | |||
| midi->magic = JackMidiBuffer::MAGIC; | |||
| JackEventBuffer* event_buffer = (JackEventBuffer*)buffer; | |||
| event_buffer->magic = JackEventBuffer::MAGIC; | |||
| /* Since port buffer has actually always BUFFER_SIZE_MAX frames, we can safely use all the size */ | |||
| midi->buffer_size = BUFFER_SIZE_MAX * sizeof(jack_default_audio_sample_t); | |||
| midi->Reset(nframes); | |||
| event_buffer->buffer_size = BUFFER_SIZE_MAX * sizeof(jack_default_audio_sample_t); | |||
| event_buffer->Reset(nframes); | |||
| } | |||
| /* | |||
| @@ -91,11 +91,11 @@ void MidiBufferInit(void* buffer, size_t buffer_size, jack_nframes_t nframes) | |||
| * implementation as is, until it is proved to be a bottleneck. | |||
| * Dmitry Baikov. | |||
| */ | |||
| static void MidiBufferMixdown(void* mixbuffer, void** src_buffers, int src_count, jack_nframes_t nframes) | |||
| static void EventBufferMixdown(void* mixbuffer, void** src_buffers, int src_count, jack_nframes_t nframes) | |||
| { | |||
| JackMidiBuffer* mix = static_cast<JackMidiBuffer*>(mixbuffer); | |||
| JackEventBuffer* mix = static_cast<JackEventBuffer*>(mixbuffer); | |||
| if (!mix->IsValid()) { | |||
| jack_error("Jack::MidiBufferMixdown - invalid mix buffer"); | |||
| jack_error("Jack::EventBufferMixdown - invalid mix buffer"); | |||
| return; | |||
| } | |||
| mix->Reset(nframes); | |||
| @@ -103,9 +103,9 @@ static void MidiBufferMixdown(void* mixbuffer, void** src_buffers, int src_count | |||
| uint32_t mix_index[src_count]; | |||
| int event_count = 0; | |||
| for (int i = 0; i < src_count; ++i) { | |||
| JackMidiBuffer* buf = static_cast<JackMidiBuffer*>(src_buffers[i]); | |||
| JackEventBuffer* buf = static_cast<JackEventBuffer*>(src_buffers[i]); | |||
| if (!buf->IsValid()) { | |||
| jack_error("Jack::MidiBufferMixdown - invalid source buffer"); | |||
| jack_error("Jack::EventBufferMixdown - invalid source buffer"); | |||
| return; | |||
| } | |||
| mix_index[i] = 0; | |||
| @@ -115,16 +115,16 @@ static void MidiBufferMixdown(void* mixbuffer, void** src_buffers, int src_count | |||
| int events_done; | |||
| for (events_done = 0; events_done < event_count; ++events_done) { | |||
| JackMidiBuffer* next_buf = 0; | |||
| JackMidiEvent* next_event = 0; | |||
| JackEventBuffer* next_buf = 0; | |||
| JackEvent* next_event = 0; | |||
| uint32_t next_buf_index = 0; | |||
| // find the earliest event | |||
| for (int i = 0; i < src_count; ++i) { | |||
| JackMidiBuffer* buf = static_cast<JackMidiBuffer*>(src_buffers[i]); | |||
| JackEventBuffer* buf = static_cast<JackEventBuffer*>(src_buffers[i]); | |||
| if (mix_index[i] >= buf->event_count) | |||
| continue; | |||
| JackMidiEvent* e = &buf->events[mix_index[i]]; | |||
| JackEvent* e = &buf->events[mix_index[i]]; | |||
| if (!next_event || e->time < next_event->time) { | |||
| next_event = e; | |||
| next_buf = buf; | |||
| @@ -132,12 +132,12 @@ static void MidiBufferMixdown(void* mixbuffer, void** src_buffers, int src_count | |||
| } | |||
| } | |||
| if (next_event == 0) { | |||
| jack_error("Jack::MidiBufferMixdown - got invalid next event"); | |||
| jack_error("Jack::EventBufferMixdown - got invalid next event"); | |||
| break; | |||
| } | |||
| // write the event | |||
| jack_midi_data_t* dest = mix->ReserveEvent(next_event->time, next_event->size); | |||
| jack_event_data_t* dest = mix->ReserveEvent(next_event->time, next_event->size); | |||
| if (!dest) break; | |||
| memcpy(dest, next_event->GetData(next_buf), next_event->size); | |||
| @@ -146,17 +146,19 @@ static void MidiBufferMixdown(void* mixbuffer, void** src_buffers, int src_count | |||
| mix->lost_events += event_count - events_done; | |||
| } | |||
| static size_t MidiBufferSize() | |||
| static size_t EventBufferSize() | |||
| { | |||
| return BUFFER_SIZE_MAX * sizeof(jack_default_audio_sample_t); | |||
| } | |||
| const JackPortType gMidiPortType = | |||
| const JackPortType gMessagePortType = | |||
| { | |||
| JACK_DEFAULT_MIDI_TYPE, | |||
| MidiBufferSize, | |||
| MidiBufferInit, | |||
| MidiBufferMixdown | |||
| JACK_DEFAULT_MESSAGE_TYPE, | |||
| EventBufferSize, | |||
| EventBufferInit, | |||
| EventBufferMixdown | |||
| }; | |||
| const JackPortType gMidiPortType = gMessagePortType; | |||
| } // namespace Jack | |||
| @@ -18,49 +18,58 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiPort__ | |||
| #define __JackMidiPort__ | |||
| #ifndef __JackEventPort__ | |||
| #define __JackEventPort__ | |||
| #include "types.h" | |||
| #include "JackConstants.h" | |||
| #include "JackPlatformPlug.h" | |||
| #include <stddef.h> | |||
| /** Type for raw event data contained in @ref jack_midi_event_t. */ | |||
| typedef unsigned char jack_midi_data_t; | |||
| /** Type for raw event data contained in @ref jack_event_t. */ | |||
| typedef unsigned char jack_event_data_t; | |||
| /** A Jack MIDI event. */ | |||
| struct jack_midi_event_t | |||
| /** A Jack event. */ | |||
| struct jack_event_t | |||
| { | |||
| jack_nframes_t time; /**< Sample index at which event is valid */ | |||
| size_t size; /**< Number of bytes of data in \a buffer */ | |||
| jack_midi_data_t *buffer; /**< Raw MIDI data */ | |||
| jack_nframes_t time; /**< Sample index at which event is valid */ | |||
| size_t size; /**< Number of bytes of data in \a buffer */ | |||
| jack_event_data_t *buffer; /**< Raw event data */ | |||
| }; | |||
| /** A Jack MIDI port type. */ | |||
| /** Backwards compability */ | |||
| typedef jack_event_data_t jack_midi_data_t; | |||
| typedef jack_event_t jack_midi_event_t; | |||
| /** A Jack MIDI port type. Use @ref JACK_DEFAULT_MESSAGE_TYPE instead if possible */ | |||
| #define JACK_DEFAULT_MIDI_TYPE "8 bit raw midi" | |||
| #define JACK_DEFAULT_MESSAGE_TYPE "binary message data" | |||
| namespace Jack | |||
| { | |||
| struct SERVER_EXPORT JackMidiEvent | |||
| struct SERVER_EXPORT JackEvent | |||
| { | |||
| // Most MIDI events are < 4 bytes in size, so we can save a lot, storing them inplace. | |||
| /** Most MIDI events are < 4 bytes in size, so we can save a lot, storing them inplace. | |||
| * "inplace" means that instead of storing an offset to the actual data we store 4 bytes in that | |||
| * pointer. This is not relevant for OSC data (and other newer protocols) since most packets are a | |||
| * lot larger. | |||
| */ | |||
| enum { INLINE_SIZE_MAX = sizeof(jack_shmsize_t) }; | |||
| uint32_t time; | |||
| jack_shmsize_t size; | |||
| union { | |||
| jack_shmsize_t offset; | |||
| jack_midi_data_t data[INLINE_SIZE_MAX]; | |||
| jack_event_data_t data[INLINE_SIZE_MAX]; | |||
| }; | |||
| jack_midi_data_t* GetData(void* buffer) | |||
| jack_event_data_t* GetData(void* buffer) | |||
| { | |||
| if (size <= INLINE_SIZE_MAX) { | |||
| return data; | |||
| } else { | |||
| return (jack_midi_data_t*)buffer + offset; | |||
| return (jack_event_data_t*)buffer + offset; | |||
| } | |||
| } | |||
| }; | |||
| @@ -72,7 +81,7 @@ struct SERVER_EXPORT JackMidiEvent | |||
| * but their data (if not inlined) is stored from the end of the same buffer. | |||
| */ | |||
| struct SERVER_EXPORT JackMidiBuffer | |||
| struct SERVER_EXPORT JackEventBuffer | |||
| { | |||
| enum { MAGIC = 0x900df00d }; | |||
| @@ -83,7 +92,7 @@ struct SERVER_EXPORT JackMidiBuffer | |||
| uint32_t event_count; | |||
| uint32_t lost_events; | |||
| JackMidiEvent events[1]; // Using 0 size does not compile with older GCC versions, so use 1 here. | |||
| JackEvent events[1]; // Using 0 size does not compile with older GCC versions, so use 1 here. | |||
| int IsValid() const | |||
| { | |||
| @@ -93,10 +102,10 @@ struct SERVER_EXPORT JackMidiBuffer | |||
| jack_shmsize_t MaxEventSize() const; | |||
| // checks only size constraints. | |||
| jack_midi_data_t* ReserveEvent(jack_nframes_t time, jack_shmsize_t size); | |||
| jack_event_data_t* ReserveEvent(jack_nframes_t time, jack_shmsize_t size); | |||
| }; | |||
| void MidiBufferInit(void* buffer, size_t buffer_size, jack_nframes_t nframes); | |||
| void EventBufferInit(void* buffer, size_t buffer_size, jack_nframes_t nframes); | |||
| } // namespace Jack | |||
| @@ -17,11 +17,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackMidiWriteQueue.h" | |||
| #include "JackEventReadQueue.h" | |||
| using Jack::JackMidiWriteQueue; | |||
| using Jack::JackEventReadQueue; | |||
| JackMidiWriteQueue::~JackMidiWriteQueue() | |||
| JackEventReadQueue::~JackEventReadQueue() | |||
| { | |||
| // Empty | |||
| } | |||
| @@ -17,23 +17,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiReadQueue__ | |||
| #define __JackMidiReadQueue__ | |||
| #ifndef __JackEventReadQueue__ | |||
| #define __JackEventReadQueue__ | |||
| #include "JackMidiPort.h" | |||
| #include "JackEventPort.h" | |||
| namespace Jack { | |||
| /** | |||
| * Interface for objects that MIDI events can be read from. | |||
| * Interface for objects that events can be read from. | |||
| */ | |||
| class SERVER_EXPORT JackMidiReadQueue { | |||
| class SERVER_EXPORT JackEventReadQueue { | |||
| public: | |||
| virtual | |||
| ~JackMidiReadQueue(); | |||
| ~JackEventReadQueue(); | |||
| /** | |||
| * Dequeues an event from the queue. Returns the event, or 0 if no | |||
| @@ -45,7 +45,7 @@ namespace Jack { | |||
| * next event. | |||
| */ | |||
| virtual jack_midi_event_t * | |||
| virtual jack_event_t * | |||
| DequeueEvent() = 0; | |||
| }; | |||
| @@ -17,11 +17,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackMidiReceiveQueue.h" | |||
| #include "JackEventReceiveQueue.h" | |||
| using Jack::JackMidiReceiveQueue; | |||
| using Jack::JackEventReceiveQueue; | |||
| JackMidiReceiveQueue::~JackMidiReceiveQueue() | |||
| JackEventReceiveQueue::~JackEventReceiveQueue() | |||
| { | |||
| // Empty | |||
| } | |||
| @@ -17,10 +17,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiReceiveQueue__ | |||
| #define __JackMidiReceiveQueue__ | |||
| #ifndef __JackEventReceiveQueue__ | |||
| #define __JackEventReceiveQueue__ | |||
| #include "JackMidiReadQueue.h" | |||
| #include "JackEventReadQueue.h" | |||
| namespace Jack { | |||
| @@ -28,12 +28,12 @@ namespace Jack { | |||
| * Implemented by MIDI input connections. | |||
| */ | |||
| class SERVER_EXPORT JackMidiReceiveQueue: public JackMidiReadQueue { | |||
| class SERVER_EXPORT JackEventReceiveQueue: public JackEventReadQueue { | |||
| public: | |||
| virtual | |||
| ~JackMidiReceiveQueue(); | |||
| ~JackEventReceiveQueue(); | |||
| }; | |||
| @@ -17,18 +17,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackMidiSendQueue.h" | |||
| #include "JackEventSendQueue.h" | |||
| #include "JackMidiUtil.h" | |||
| using Jack::JackMidiSendQueue; | |||
| using Jack::JackEventSendQueue; | |||
| JackMidiSendQueue::~JackMidiSendQueue() | |||
| JackEventSendQueue::~JackEventSendQueue() | |||
| { | |||
| // Empty | |||
| } | |||
| jack_nframes_t | |||
| JackMidiSendQueue::GetNextScheduleFrame() | |||
| JackEventSendQueue::GetNextScheduleFrame() | |||
| { | |||
| return GetCurrentFrame(); | |||
| } | |||
| @@ -17,28 +17,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiSendQueue__ | |||
| #define __JackMidiSendQueue__ | |||
| #ifndef __JackEventSendQueue__ | |||
| #define __JackEventSendQueue__ | |||
| #include "JackMidiWriteQueue.h" | |||
| #include "JackEventWriteQueue.h" | |||
| namespace Jack { | |||
| /** | |||
| * Implemented by MIDI output connections. | |||
| * Implemented by event output connections. | |||
| */ | |||
| class SERVER_EXPORT JackMidiSendQueue: public JackMidiWriteQueue { | |||
| class SERVER_EXPORT JackEventSendQueue: public JackEventWriteQueue { | |||
| public: | |||
| using JackMidiWriteQueue::EnqueueEvent; | |||
| using JackEventWriteQueue::EnqueueEvent; | |||
| virtual | |||
| ~JackMidiSendQueue(); | |||
| ~JackEventSendQueue(); | |||
| /** | |||
| * Returns the next frame that a MIDI message can be sent at. The | |||
| * Returns the next frame that a message can be sent at. The | |||
| * default method returns the current frame. | |||
| */ | |||
| @@ -17,11 +17,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackMidiReadQueue.h" | |||
| #include "JackEventWriteQueue.h" | |||
| using Jack::JackMidiReadQueue; | |||
| using Jack::JackEventWriteQueue; | |||
| JackMidiReadQueue::~JackMidiReadQueue() | |||
| JackEventWriteQueue::~JackEventWriteQueue() | |||
| { | |||
| // Empty | |||
| } | |||
| @@ -17,19 +17,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidiWriteQueue__ | |||
| #define __JackMidiWriteQueue__ | |||
| #ifndef __JackEventWriteQueue__ | |||
| #define __JackEventWriteQueue__ | |||
| #include "JackMidiPort.h" | |||
| #include "JackEventPort.h" | |||
| namespace Jack { | |||
| /** | |||
| * Interface for classes that act as write queues for MIDI messages. Write | |||
| * Interface for classes that act as write queues for event messages. Write | |||
| * queues are used by processors to transfer data to the next processor. | |||
| */ | |||
| class SERVER_EXPORT JackMidiWriteQueue { | |||
| class SERVER_EXPORT JackEventWriteQueue { | |||
| public: | |||
| @@ -41,7 +41,7 @@ namespace Jack { | |||
| OK | |||
| }; | |||
| virtual ~JackMidiWriteQueue(); | |||
| virtual ~JackEventWriteQueue(); | |||
| /** | |||
| * Enqueues a data packet in the write queue of `size` bytes contained | |||
| @@ -60,7 +60,7 @@ namespace Jack { | |||
| virtual EnqueueResult | |||
| EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer) = 0; | |||
| jack_event_data_t *buffer) = 0; | |||
| /** | |||
| * A wrapper method for the `EnqueueEvent` method above. The optional | |||
| @@ -69,7 +69,7 @@ namespace Jack { | |||
| */ | |||
| inline EnqueueResult | |||
| EnqueueEvent(jack_midi_event_t *event, jack_nframes_t frame_offset=0) | |||
| EnqueueEvent(jack_event_t *event, jack_nframes_t frame_offset=0) | |||
| { | |||
| return EnqueueEvent(event->time + frame_offset, event->size, | |||
| event->buffer); | |||
| @@ -28,16 +28,17 @@ | |||
| #define JACK_METADATA_PREFIX "http://jackaudio.org/metadata/" | |||
| LIB_EXPORT const char* JACK_METADATA_CONNECTED = JACK_METADATA_PREFIX "connected"; | |||
| LIB_EXPORT const char* JACK_METADATA_EVENT_TYPES = JACK_METADATA_PREFIX "event-types"; | |||
| LIB_EXPORT const char* JACK_METADATA_HARDWARE = JACK_METADATA_PREFIX "hardware"; | |||
| LIB_EXPORT const char* JACK_METADATA_ICON_LARGE = JACK_METADATA_PREFIX "icon-large"; | |||
| LIB_EXPORT const char* JACK_METADATA_ICON_NAME = JACK_METADATA_PREFIX "icon-name"; | |||
| LIB_EXPORT const char* JACK_METADATA_ICON_SMALL = JACK_METADATA_PREFIX "icon-small"; | |||
| LIB_EXPORT const char* JACK_METADATA_ORDER = JACK_METADATA_PREFIX "order"; | |||
| LIB_EXPORT const char* JACK_METADATA_PORT_GROUP = JACK_METADATA_PREFIX "port-group"; | |||
| LIB_EXPORT const char* JACK_METADATA_PRETTY_NAME = JACK_METADATA_PREFIX "pretty-name"; | |||
| LIB_EXPORT const char* JACK_METADATA_SIGNAL_TYPE = JACK_METADATA_PREFIX "signal-type"; | |||
| LIB_EXPORT const char* JACK_METADATA_CONNECTED = JACK_METADATA_PREFIX "connected"; | |||
| LIB_EXPORT const char* JACK_METADATA_EVENT_TYPES = JACK_METADATA_PREFIX "event-types"; | |||
| LIB_EXPORT const char* JACK_METADATA_EVENT_OSC_NAMESPACE = JACK_METADATA_PREFIX "event-osc-namespace"; | |||
| LIB_EXPORT const char* JACK_METADATA_HARDWARE = JACK_METADATA_PREFIX "hardware"; | |||
| LIB_EXPORT const char* JACK_METADATA_ICON_LARGE = JACK_METADATA_PREFIX "icon-large"; | |||
| LIB_EXPORT const char* JACK_METADATA_ICON_NAME = JACK_METADATA_PREFIX "icon-name"; | |||
| LIB_EXPORT const char* JACK_METADATA_ICON_SMALL = JACK_METADATA_PREFIX "icon-small"; | |||
| LIB_EXPORT const char* JACK_METADATA_ORDER = JACK_METADATA_PREFIX "order"; | |||
| LIB_EXPORT const char* JACK_METADATA_PORT_GROUP = JACK_METADATA_PREFIX "port-group"; | |||
| LIB_EXPORT const char* JACK_METADATA_PRETTY_NAME = JACK_METADATA_PREFIX "pretty-name"; | |||
| LIB_EXPORT const char* JACK_METADATA_SIGNAL_TYPE = JACK_METADATA_PREFIX "signal-type"; | |||
| #undef JACK_METADATA_PREFIX | |||
| namespace Jack | |||
| @@ -0,0 +1,46 @@ | |||
| /* | |||
| Copyright (C) 2010 Devin Anderson | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU Lesser General Public License as published by | |||
| the Free Software Foundation; either version 2.1 of the License, or | |||
| (at your option) any later version. | |||
| This program is distributed in the hope that it will be useful, | |||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| GNU Lesser General Public License for more details. | |||
| You should have received a copy of the GNU Lesser General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JackMidi__ | |||
| #define __JackMidi__ | |||
| #include "JackEventPort.h" | |||
| #include "JackEventReceiveQueue.h" | |||
| #include "JackEventSendQueue.h" | |||
| #include "JackEventWriteQueue.h" | |||
| #include "JackEventAsyncQueue.h" | |||
| #include "JackEventBufferReadQueue.h" | |||
| #include "JackEventBufferWriteQueue.h" | |||
| namespace Jack { | |||
| typedef jack_event_data_t jack_midi_data_t; | |||
| typedef jack_event_t jack_midi_event_t; | |||
| typedef JackEventBuffer JackMidiBuffer; | |||
| typedef JackEventReceiveQueue JackMidiReceiveQueue; | |||
| typedef JackEventSendQueue JackMidiSendQueue; | |||
| typedef JackEventWriteQueue JackMidiWriteQueue; | |||
| typedef JackEventAsyncQueue JackMidiAsyncQueue; | |||
| typedef JackEventBufferReadQueue JackMidiBufferReadQueue; | |||
| typedef JackEventBufferWriteQueue JackMidiBufferWriteQueue; | |||
| } | |||
| #endif | |||
| @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #include "JackError.h" | |||
| #include "JackMidiPort.h" | |||
| #include "JackEventPort.h" | |||
| #include <errno.h> | |||
| #include <string.h> | |||
| @@ -56,7 +56,7 @@ using namespace Jack; | |||
| LIB_EXPORT | |||
| uint32_t jack_midi_get_event_count(void* port_buffer) | |||
| { | |||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (!buf || !buf->IsValid()) { | |||
| return 0; | |||
| } | |||
| @@ -64,16 +64,16 @@ uint32_t jack_midi_get_event_count(void* port_buffer) | |||
| } | |||
| LIB_EXPORT | |||
| int jack_midi_event_get(jack_midi_event_t *event, void* port_buffer, uint32_t event_index) | |||
| int jack_midi_event_get(jack_event_t *event, void* port_buffer, uint32_t event_index) | |||
| { | |||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (!buf || !buf->IsValid()) { | |||
| return -EINVAL; | |||
| } | |||
| if (event_index >= buf->event_count) { | |||
| return -ENOBUFS; | |||
| } | |||
| JackMidiEvent* ev = &buf->events[event_index]; | |||
| JackEvent* ev = &buf->events[event_index]; | |||
| event->time = ev->time; | |||
| event->size = ev->size; | |||
| event->buffer = ev->GetData(buf); | |||
| @@ -83,7 +83,7 @@ int jack_midi_event_get(jack_midi_event_t *event, void* port_buffer, uint32_t ev | |||
| LIB_EXPORT | |||
| void jack_midi_clear_buffer(void* port_buffer) | |||
| { | |||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (buf && buf->IsValid()) { | |||
| buf->Reset(buf->nframes); | |||
| } | |||
| @@ -92,13 +92,13 @@ void jack_midi_clear_buffer(void* port_buffer) | |||
| LIB_EXPORT | |||
| void jack_midi_reset_buffer(void* port_buffer) | |||
| { | |||
| MidiBufferInit(port_buffer, BUFFER_SIZE_MAX, BUFFER_SIZE_MAX); | |||
| EventBufferInit(port_buffer, BUFFER_SIZE_MAX, BUFFER_SIZE_MAX); | |||
| } | |||
| LIB_EXPORT | |||
| size_t jack_midi_max_event_size(void* port_buffer) | |||
| { | |||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (buf && buf->IsValid()) { | |||
| return buf->MaxEventSize(); | |||
| } | |||
| @@ -106,24 +106,24 @@ size_t jack_midi_max_event_size(void* port_buffer) | |||
| } | |||
| LIB_EXPORT | |||
| jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size) | |||
| jack_event_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size) | |||
| { | |||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (! buf) { | |||
| jack_error("jack_midi_event_reserve: port buffer is set to NULL"); | |||
| jack_error("jack_event_reserve: port buffer is set to NULL"); | |||
| return 0; | |||
| } | |||
| if (! buf->IsValid()) { | |||
| jack_error("jack_midi_event_reserve: port buffer is invalid"); | |||
| jack_error("jack_event_reserve: port buffer is invalid"); | |||
| return 0; | |||
| } | |||
| if (time >= buf->nframes) { | |||
| jack_error("jack_midi_event_reserve: time parameter is out of range " | |||
| jack_error("jack_event_reserve: time parameter is out of range " | |||
| "(%lu >= %lu)", time, buf->nframes); | |||
| return 0; | |||
| } | |||
| if (buf->event_count && (buf->events[buf->event_count - 1].time > time)) { | |||
| jack_error("jack_midi_event_reserve: time parameter is earlier than " | |||
| jack_error("jack_event_reserve: time parameter is earlier than " | |||
| "last reserved event"); | |||
| return 0; | |||
| } | |||
| @@ -132,16 +132,16 @@ jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time | |||
| LIB_EXPORT | |||
| int jack_midi_event_write(void* port_buffer, | |||
| jack_nframes_t time, const jack_midi_data_t* data, size_t data_size) | |||
| jack_nframes_t time, const jack_event_data_t* data, size_t data_size) | |||
| { | |||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (!buf || !buf->IsValid()) { | |||
| return -EINVAL; | |||
| } | |||
| if (time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time)) { | |||
| return -EINVAL; | |||
| } | |||
| jack_midi_data_t* dest = buf->ReserveEvent(time, data_size); | |||
| jack_event_data_t* dest = buf->ReserveEvent(time, data_size); | |||
| if (!dest) { | |||
| return -ENOBUFS; | |||
| } | |||
| @@ -152,7 +152,7 @@ int jack_midi_event_write(void* port_buffer, | |||
| LIB_EXPORT | |||
| uint32_t jack_midi_get_lost_event_count(void* port_buffer) | |||
| { | |||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||
| JackEventBuffer *buf = (JackEventBuffer*)port_buffer; | |||
| if (buf && buf->IsValid()) { | |||
| return buf->lost_events; | |||
| } | |||
| @@ -198,16 +198,16 @@ int JackMidiDriver::ProcessWriteAsync() | |||
| return 0; | |||
| } | |||
| JackMidiBuffer* JackMidiDriver::GetInputBuffer(int port_index) | |||
| JackEventBuffer* JackMidiDriver::GetInputBuffer(int port_index) | |||
| { | |||
| assert(fCapturePortList[port_index]); | |||
| return (JackMidiBuffer*)fGraphManager->GetBuffer(fCapturePortList[port_index], fEngineControl->fBufferSize); | |||
| return (JackEventBuffer*)fGraphManager->GetBuffer(fCapturePortList[port_index], fEngineControl->fBufferSize); | |||
| } | |||
| JackMidiBuffer* JackMidiDriver::GetOutputBuffer(int port_index) | |||
| JackEventBuffer* JackMidiDriver::GetOutputBuffer(int port_index) | |||
| { | |||
| assert(fPlaybackPortList[port_index]); | |||
| return (JackMidiBuffer*)fGraphManager->GetBuffer(fPlaybackPortList[port_index], fEngineControl->fBufferSize); | |||
| return (JackEventBuffer*)fGraphManager->GetBuffer(fPlaybackPortList[port_index], fEngineControl->fBufferSize); | |||
| } | |||
| } // end of namespace | |||
| @@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #define __JackMidiDriver__ | |||
| #include "JackDriver.h" | |||
| #include "JackMidiPort.h" | |||
| #include "JackEventPort.h" | |||
| #include "JackLockedEngine.h" | |||
| #include "ringbuffer.h" | |||
| @@ -29,7 +29,7 @@ namespace Jack | |||
| { | |||
| /*! | |||
| \brief The base class for MIDI drivers: drivers with MIDI ports. | |||
| \brief The base class for event drivers: drivers with MIDI ports. | |||
| A concrete derived class will have to be defined with a real MIDI driver API, | |||
| either callback based one (like CoreMIDI..) ones or blocking ones (like ALSA MIDI). | |||
| @@ -41,8 +41,8 @@ class SERVER_EXPORT JackMidiDriver : public JackDriver | |||
| protected: | |||
| JackMidiBuffer* GetInputBuffer(int port_index); | |||
| JackMidiBuffer* GetOutputBuffer(int port_index); | |||
| JackEventBuffer* GetInputBuffer(int port_index); | |||
| JackEventBuffer* GetOutputBuffer(int port_index); | |||
| virtual int ProcessReadSync(); | |||
| virtual int ProcessWriteSync(); | |||
| @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| using Jack::JackMidiRawInputWriteQueue; | |||
| JackMidiRawInputWriteQueue:: | |||
| JackMidiRawInputWriteQueue(JackMidiWriteQueue *write_queue, | |||
| JackMidiRawInputWriteQueue(JackEventWriteQueue *write_queue, | |||
| size_t max_packet_data, size_t max_packets) | |||
| { | |||
| packet_queue = new JackMidiAsyncQueue(max_packet_data, max_packets); | |||
| std::unique_ptr<JackMidiAsyncQueue> packet_queue_ptr(packet_queue); | |||
| input_buffer = new jack_midi_data_t[max_packet_data]; | |||
| packet_queue = new JackEventAsyncQueue(max_packet_data, max_packets); | |||
| std::unique_ptr<JackEventAsyncQueue> packet_queue_ptr(packet_queue); | |||
| input_buffer = new jack_event_data_t[max_packet_data]; | |||
| Clear(); | |||
| expected_bytes = 0; | |||
| event_pending = false; | |||
| @@ -56,9 +56,9 @@ JackMidiRawInputWriteQueue::Clear() | |||
| unbuffered_bytes = 0; | |||
| } | |||
| Jack::JackMidiWriteQueue::EnqueueResult | |||
| Jack::JackEventWriteQueue::EnqueueResult | |||
| JackMidiRawInputWriteQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer) | |||
| jack_event_data_t *buffer) | |||
| { | |||
| return packet_queue->EnqueueEvent(time, size, buffer); | |||
| } | |||
| @@ -79,7 +79,7 @@ JackMidiRawInputWriteQueue::HandleBufferFailure(size_t unbuffered_bytes, | |||
| } | |||
| void | |||
| JackMidiRawInputWriteQueue::HandleEventLoss(jack_midi_event_t *event) | |||
| JackMidiRawInputWriteQueue::HandleEventLoss(jack_event_t *event) | |||
| { | |||
| jack_error("JackMidiRawInputWriteQueue::HandleEventLoss - A %d byte MIDI " | |||
| "event scheduled for frame '%d' could not be processed because " | |||
| @@ -96,7 +96,7 @@ JackMidiRawInputWriteQueue::HandleIncompleteMessage(size_t total_bytes) | |||
| } | |||
| void | |||
| JackMidiRawInputWriteQueue::HandleInvalidStatusByte(jack_midi_data_t byte) | |||
| JackMidiRawInputWriteQueue::HandleInvalidStatusByte(jack_event_data_t byte) | |||
| { | |||
| jack_error("JackMidiRawInputWriteQueue::HandleInvalidStatusByte - " | |||
| "Dropping invalid MIDI status byte '%x'.", (unsigned int) byte); | |||
| @@ -130,7 +130,7 @@ JackMidiRawInputWriteQueue::PrepareBufferedEvent(jack_nframes_t time) | |||
| bool | |||
| JackMidiRawInputWriteQueue::PrepareByteEvent(jack_nframes_t time, | |||
| jack_midi_data_t byte) | |||
| jack_event_data_t byte) | |||
| { | |||
| event_byte = byte; | |||
| PrepareEvent(time, 1, &event_byte); | |||
| @@ -139,7 +139,7 @@ JackMidiRawInputWriteQueue::PrepareByteEvent(jack_nframes_t time, | |||
| void | |||
| JackMidiRawInputWriteQueue::PrepareEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer) | |||
| jack_event_data_t *buffer) | |||
| { | |||
| event.buffer = buffer; | |||
| event.size = size; | |||
| @@ -174,7 +174,7 @@ JackMidiRawInputWriteQueue::Process(jack_nframes_t boundary_frame) | |||
| bool | |||
| JackMidiRawInputWriteQueue::ProcessByte(jack_nframes_t time, | |||
| jack_midi_data_t byte) | |||
| jack_event_data_t byte) | |||
| { | |||
| if (byte >= 0xf8) { | |||
| // Realtime | |||
| @@ -269,7 +269,7 @@ JackMidiRawInputWriteQueue::ProcessByte(jack_nframes_t time, | |||
| } | |||
| void | |||
| JackMidiRawInputWriteQueue::RecordByte(jack_midi_data_t byte) | |||
| JackMidiRawInputWriteQueue::RecordByte(jack_event_data_t byte) | |||
| { | |||
| if (total_bytes < input_buffer_size) { | |||
| input_buffer[total_bytes] = byte; | |||
| @@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #ifndef __JackMidiRawInputWriteQueue__ | |||
| #define __JackMidiRawInputWriteQueue__ | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackMidiWriteQueue.h" | |||
| #include "JackEventAsyncQueue.h" | |||
| #include "JackEventWriteQueue.h" | |||
| namespace Jack { | |||
| @@ -33,22 +33,22 @@ namespace Jack { | |||
| * MIDI bytes that must be parsed. | |||
| */ | |||
| class SERVER_EXPORT JackMidiRawInputWriteQueue: public JackMidiWriteQueue { | |||
| class SERVER_EXPORT JackMidiRawInputWriteQueue: public JackEventWriteQueue { | |||
| private: | |||
| jack_midi_event_t event; | |||
| jack_midi_data_t event_byte; | |||
| jack_event_t event; | |||
| jack_event_data_t event_byte; | |||
| bool event_pending; | |||
| size_t expected_bytes; | |||
| jack_midi_data_t *input_buffer; | |||
| jack_event_data_t *input_buffer; | |||
| size_t input_buffer_size; | |||
| jack_midi_event_t *packet; | |||
| JackMidiAsyncQueue *packet_queue; | |||
| jack_midi_data_t status_byte; | |||
| jack_event_t *packet; | |||
| JackEventAsyncQueue *packet_queue; | |||
| jack_event_data_t status_byte; | |||
| size_t total_bytes; | |||
| size_t unbuffered_bytes; | |||
| JackMidiWriteQueue *write_queue; | |||
| JackEventWriteQueue *write_queue; | |||
| void | |||
| Clear(); | |||
| @@ -57,17 +57,17 @@ namespace Jack { | |||
| PrepareBufferedEvent(jack_nframes_t time); | |||
| bool | |||
| PrepareByteEvent(jack_nframes_t time, jack_midi_data_t byte); | |||
| PrepareByteEvent(jack_nframes_t time, jack_event_data_t byte); | |||
| void | |||
| PrepareEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer); | |||
| jack_event_data_t *buffer); | |||
| bool | |||
| ProcessByte(jack_nframes_t time, jack_midi_data_t byte); | |||
| ProcessByte(jack_nframes_t time, jack_event_data_t byte); | |||
| void | |||
| RecordByte(jack_midi_data_t byte); | |||
| RecordByte(jack_event_data_t byte); | |||
| bool | |||
| WriteEvent(jack_nframes_t boundary_frame); | |||
| @@ -91,7 +91,7 @@ namespace Jack { | |||
| */ | |||
| virtual void | |||
| HandleEventLoss(jack_midi_event_t *event); | |||
| HandleEventLoss(jack_event_t *event); | |||
| /** | |||
| * Override this method to specify what happens when an incomplete MIDI | |||
| @@ -107,7 +107,7 @@ namespace Jack { | |||
| */ | |||
| virtual void | |||
| HandleInvalidStatusByte(jack_midi_data_t byte); | |||
| HandleInvalidStatusByte(jack_event_data_t byte); | |||
| /** | |||
| * Override this method to specify what happens when a sysex end byte | |||
| @@ -120,7 +120,7 @@ namespace Jack { | |||
| public: | |||
| using JackMidiWriteQueue::EnqueueEvent; | |||
| using JackEventWriteQueue::EnqueueEvent; | |||
| /** | |||
| * Called to create a new raw input write queue. The `write_queue` | |||
| @@ -132,7 +132,7 @@ namespace Jack { | |||
| * written to the write queue. | |||
| */ | |||
| JackMidiRawInputWriteQueue(JackMidiWriteQueue *write_queue, | |||
| JackMidiRawInputWriteQueue(JackEventWriteQueue *write_queue, | |||
| size_t max_packet_data=4096, | |||
| size_t max_packets=1024); | |||
| @@ -140,7 +140,7 @@ namespace Jack { | |||
| EnqueueResult | |||
| EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer); | |||
| jack_event_data_t *buffer); | |||
| /** | |||
| * Returns the maximum size event that can be enqueued right *now*. | |||
| @@ -29,13 +29,13 @@ using Jack::JackMidiRawOutputWriteQueue; | |||
| #define STILL_TIME(c, b) ((! (b)) || ((c) < (b))) | |||
| JackMidiRawOutputWriteQueue:: | |||
| JackMidiRawOutputWriteQueue(JackMidiSendQueue *send_queue, size_t non_rt_size, | |||
| JackMidiRawOutputWriteQueue(JackEventSendQueue *send_queue, size_t non_rt_size, | |||
| size_t max_non_rt_messages, size_t max_rt_messages) | |||
| { | |||
| non_rt_queue = new JackMidiAsyncQueue(non_rt_size, max_non_rt_messages); | |||
| std::unique_ptr<JackMidiAsyncQueue> non_rt_ptr(non_rt_queue); | |||
| rt_queue = new JackMidiAsyncQueue(max_rt_messages, max_rt_messages); | |||
| std::unique_ptr<JackMidiAsyncQueue> rt_ptr(rt_queue); | |||
| non_rt_queue = new JackEventAsyncQueue(non_rt_size, max_non_rt_messages); | |||
| std::unique_ptr<JackEventAsyncQueue> non_rt_ptr(non_rt_queue); | |||
| rt_queue = new JackEventAsyncQueue(max_rt_messages, max_rt_messages); | |||
| std::unique_ptr<JackEventAsyncQueue> rt_ptr(rt_queue); | |||
| non_rt_event = 0; | |||
| rt_event = 0; | |||
| running_status = 0; | |||
| @@ -69,18 +69,18 @@ JackMidiRawOutputWriteQueue::DequeueRealtimeEvent() | |||
| } | |||
| } | |||
| Jack::JackMidiWriteQueue::EnqueueResult | |||
| Jack::JackEventWriteQueue::EnqueueResult | |||
| JackMidiRawOutputWriteQueue::EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer) | |||
| jack_event_data_t *buffer) | |||
| { | |||
| JackMidiAsyncQueue *queue = (size == 1) && (*buffer >= 0xf8) ? rt_queue : | |||
| JackEventAsyncQueue *queue = (size == 1) && (*buffer >= 0xf8) ? rt_queue : | |||
| non_rt_queue; | |||
| return queue->EnqueueEvent(time, size, buffer); | |||
| } | |||
| void | |||
| JackMidiRawOutputWriteQueue::HandleWriteQueueBug(jack_nframes_t time, | |||
| jack_midi_data_t byte) | |||
| jack_event_data_t byte) | |||
| { | |||
| jack_error("JackMidiRawOutputWriteQueue::HandleWriteQueueBug - **BUG** " | |||
| "The write queue told us that it couldn't enqueue a 1-byte " | |||
| @@ -123,7 +123,7 @@ JackMidiRawOutputWriteQueue::Process(jack_nframes_t boundary_frame) | |||
| bool | |||
| JackMidiRawOutputWriteQueue::SendByte(jack_nframes_t time, | |||
| jack_midi_data_t byte) | |||
| jack_event_data_t byte) | |||
| { | |||
| switch (send_queue->EnqueueEvent(time, 1, &byte)) { | |||
| case BUFFER_TOO_SMALL: | |||
| @@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #ifndef __JackMidiRawOutputWriteQueue__ | |||
| #define __JackMidiRawOutputWriteQueue__ | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackMidiSendQueue.h" | |||
| #include "JackEventAsyncQueue.h" | |||
| #include "JackEventSendQueue.h" | |||
| namespace Jack { | |||
| @@ -44,18 +44,18 @@ namespace Jack { | |||
| */ | |||
| class SERVER_EXPORT JackMidiRawOutputWriteQueue: | |||
| public JackMidiWriteQueue { | |||
| public JackEventWriteQueue { | |||
| private: | |||
| jack_midi_event_t *non_rt_event; | |||
| jack_event_t *non_rt_event; | |||
| jack_nframes_t non_rt_event_time; | |||
| JackMidiAsyncQueue *non_rt_queue; | |||
| jack_midi_event_t *rt_event; | |||
| JackEventAsyncQueue *non_rt_queue; | |||
| jack_event_t *rt_event; | |||
| jack_nframes_t rt_event_time; | |||
| JackMidiAsyncQueue *rt_queue; | |||
| jack_midi_data_t running_status; | |||
| JackMidiSendQueue *send_queue; | |||
| JackEventAsyncQueue *rt_queue; | |||
| jack_event_data_t running_status; | |||
| JackEventSendQueue *send_queue; | |||
| void | |||
| DequeueNonRealtimeEvent(); | |||
| @@ -64,7 +64,7 @@ namespace Jack { | |||
| DequeueRealtimeEvent(); | |||
| bool | |||
| SendByte(jack_nframes_t time, jack_midi_data_t byte); | |||
| SendByte(jack_nframes_t time, jack_event_data_t byte); | |||
| bool | |||
| SendNonRTBytes(jack_nframes_t boundary_frame); | |||
| @@ -78,11 +78,11 @@ namespace Jack { | |||
| */ | |||
| virtual void | |||
| HandleWriteQueueBug(jack_nframes_t time, jack_midi_data_t byte); | |||
| HandleWriteQueueBug(jack_nframes_t time, jack_event_data_t byte); | |||
| public: | |||
| using JackMidiWriteQueue::EnqueueEvent; | |||
| using JackEventWriteQueue::EnqueueEvent; | |||
| /** | |||
| * Called to create a new raw write queue. The `send_queue` argument | |||
| @@ -95,7 +95,7 @@ namespace Jack { | |||
| * the non-realtime queue. | |||
| */ | |||
| JackMidiRawOutputWriteQueue(JackMidiSendQueue *send_queue, | |||
| JackMidiRawOutputWriteQueue(JackEventSendQueue *send_queue, | |||
| size_t non_rt_size=4096, | |||
| size_t max_non_rt_messages=1024, | |||
| size_t max_rt_messages=128); | |||
| @@ -104,7 +104,7 @@ namespace Jack { | |||
| EnqueueResult | |||
| EnqueueEvent(jack_nframes_t time, size_t size, | |||
| jack_midi_data_t *buffer); | |||
| jack_event_data_t *buffer); | |||
| /** | |||
| * The `Process()` method should be called each time the | |||
| @@ -23,14 +23,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #include "JackMidiUtil.h" | |||
| #include "JackTime.h" | |||
| jack_midi_data_t | |||
| Jack::ApplyRunningStatus(size_t *size, jack_midi_data_t **buffer, | |||
| jack_midi_data_t running_status) | |||
| jack_event_data_t | |||
| Jack::ApplyRunningStatus(size_t *size, jack_event_data_t **buffer, | |||
| jack_event_data_t running_status) | |||
| { | |||
| // Stolen and modified from alsa/midi_pack.h | |||
| jack_midi_data_t status = **buffer; | |||
| jack_event_data_t status = **buffer; | |||
| if ((status >= 0x80) && (status < 0xf0)) { | |||
| if (status == running_status) { | |||
| (*buffer)++; | |||
| @@ -44,9 +44,9 @@ Jack::ApplyRunningStatus(size_t *size, jack_midi_data_t **buffer, | |||
| return running_status; | |||
| } | |||
| jack_midi_data_t | |||
| Jack::ApplyRunningStatus(jack_midi_event_t *event, | |||
| jack_midi_data_t running_status) | |||
| jack_event_data_t | |||
| Jack::ApplyRunningStatus(jack_event_t *event, | |||
| jack_event_data_t running_status) | |||
| { | |||
| return ApplyRunningStatus(&(event->size), &(event->buffer), | |||
| running_status); | |||
| @@ -78,7 +78,7 @@ Jack::GetLastFrame() | |||
| } | |||
| int | |||
| Jack::GetMessageLength(jack_midi_data_t status_byte) | |||
| Jack::GetMessageLength(jack_event_data_t status_byte) | |||
| { | |||
| switch (status_byte & 0xf0) { | |||
| case 0x80: | |||
| @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #ifndef __JackMidiUtil__ | |||
| #define __JackMidiUtil__ | |||
| #include "JackMidiPort.h" | |||
| #include "JackEventPort.h" | |||
| namespace Jack { | |||
| @@ -41,17 +41,17 @@ namespace Jack { | |||
| * message for each message that can be optimized. | |||
| */ | |||
| SERVER_EXPORT jack_midi_data_t | |||
| ApplyRunningStatus(size_t *size, jack_midi_data_t **buffer, | |||
| jack_midi_data_t running_status=0); | |||
| SERVER_EXPORT jack_event_data_t | |||
| ApplyRunningStatus(size_t *size, jack_event_data_t **buffer, | |||
| jack_event_data_t running_status=0); | |||
| /** | |||
| * A wrapper function for the above `ApplyRunningStatus` function. | |||
| */ | |||
| SERVER_EXPORT jack_midi_data_t | |||
| ApplyRunningStatus(jack_midi_event_t *event, | |||
| jack_midi_data_t running_status); | |||
| SERVER_EXPORT jack_event_data_t | |||
| ApplyRunningStatus(jack_event_t *event, | |||
| jack_event_data_t running_status); | |||
| /** | |||
| * Gets the estimated current time in frames. This function has the same | |||
| @@ -86,7 +86,7 @@ namespace Jack { | |||
| */ | |||
| SERVER_EXPORT int | |||
| GetMessageLength(jack_midi_data_t status_byte); | |||
| GetMessageLength(jack_event_data_t status_byte); | |||
| /** | |||
| * Gets the estimated time at which the given frame will occur. This | |||
| @@ -390,8 +390,8 @@ struct JackNetExtMaster : public JackNetMasterInterface { | |||
| } | |||
| for (int midi_port_index = 0; midi_port_index < midi_input; midi_port_index++) { | |||
| assert(((JackMidiBuffer**)midi_input_buffer)[midi_port_index]); | |||
| fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, ((JackMidiBuffer**)midi_input_buffer)[midi_port_index]); | |||
| assert(((JackEventBuffer**)midi_input_buffer)[midi_port_index]); | |||
| fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, ((JackEventBuffer**)midi_input_buffer)[midi_port_index]); | |||
| } | |||
| int res1 = SyncRecv(); | |||
| @@ -443,8 +443,8 @@ struct JackNetExtMaster : public JackNetMasterInterface { | |||
| } | |||
| for (int midi_port_index = 0; midi_port_index < midi_output; midi_port_index++) { | |||
| assert(((JackMidiBuffer**)midi_output_buffer)[midi_port_index]); | |||
| fNetMidiCaptureBuffer->SetBuffer(midi_port_index, ((JackMidiBuffer**)midi_output_buffer)[midi_port_index]); | |||
| assert(((JackEventBuffer**)midi_output_buffer)[midi_port_index]); | |||
| fNetMidiCaptureBuffer->SetBuffer(midi_port_index, ((JackEventBuffer**)midi_output_buffer)[midi_port_index]); | |||
| } | |||
| EncodeSyncPacket(frames); | |||
| @@ -481,8 +481,8 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf | |||
| float** fAudioCaptureBuffer; | |||
| float** fAudioPlaybackBuffer; | |||
| JackMidiBuffer** fMidiCaptureBuffer; | |||
| JackMidiBuffer** fMidiPlaybackBuffer; | |||
| JackEventBuffer** fMidiCaptureBuffer; | |||
| JackEventBuffer** fMidiPlaybackBuffer; | |||
| JackThread fThread; | |||
| @@ -567,9 +567,9 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf | |||
| } | |||
| if (fParams.fSendMidiChannels > 0) { | |||
| fMidiCaptureBuffer = new JackMidiBuffer*[fParams.fSendMidiChannels]; | |||
| fMidiCaptureBuffer = new JackEventBuffer*[fParams.fSendMidiChannels]; | |||
| for (int midi_port_index = 0; midi_port_index < fParams.fSendMidiChannels; midi_port_index++) { | |||
| fMidiCaptureBuffer[midi_port_index] = (JackMidiBuffer*)new float[fParams.fPeriodSize]; | |||
| fMidiCaptureBuffer[midi_port_index] = (JackEventBuffer*)new float[fParams.fPeriodSize]; | |||
| memset(fMidiCaptureBuffer[midi_port_index], 0, sizeof(float) * fParams.fPeriodSize); | |||
| fNetMidiCaptureBuffer->SetBuffer(midi_port_index, fMidiCaptureBuffer[midi_port_index]); | |||
| } | |||
| @@ -585,9 +585,9 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf | |||
| } | |||
| if (fParams.fReturnMidiChannels > 0) { | |||
| fMidiPlaybackBuffer = new JackMidiBuffer*[fParams.fReturnMidiChannels]; | |||
| fMidiPlaybackBuffer = new JackEventBuffer*[fParams.fReturnMidiChannels]; | |||
| for (int midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++) { | |||
| fMidiPlaybackBuffer[midi_port_index] = (JackMidiBuffer*)new float[fParams.fPeriodSize]; | |||
| fMidiPlaybackBuffer[midi_port_index] = (JackEventBuffer*)new float[fParams.fPeriodSize]; | |||
| memset(fMidiPlaybackBuffer[midi_port_index], 0, sizeof(float) * fParams.fPeriodSize); | |||
| fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, fMidiPlaybackBuffer[midi_port_index]); | |||
| } | |||
| @@ -453,14 +453,14 @@ namespace Jack | |||
| } | |||
| } | |||
| JackMidiBuffer* JackNetDriver::GetMidiInputBuffer(int port_index) | |||
| JackEventBuffer* JackNetDriver::GetMidiInputBuffer(int port_index) | |||
| { | |||
| return static_cast<JackMidiBuffer*>(fGraphManager->GetBuffer(fMidiCapturePortList[port_index], fEngineControl->fBufferSize)); | |||
| return static_cast<JackEventBuffer*>(fGraphManager->GetBuffer(fMidiCapturePortList[port_index], fEngineControl->fBufferSize)); | |||
| } | |||
| JackMidiBuffer* JackNetDriver::GetMidiOutputBuffer(int port_index) | |||
| JackEventBuffer* JackNetDriver::GetMidiOutputBuffer(int port_index) | |||
| { | |||
| return static_cast<JackMidiBuffer*>(fGraphManager->GetBuffer(fMidiPlaybackPortList[port_index], fEngineControl->fBufferSize)); | |||
| return static_cast<JackEventBuffer*>(fGraphManager->GetBuffer(fMidiPlaybackPortList[port_index], fEngineControl->fBufferSize)); | |||
| } | |||
| //transport--------------------------------------------------------------------------- | |||
| @@ -69,8 +69,8 @@ namespace Jack | |||
| void EncodeTransportData(); | |||
| void DecodeTransportData(); | |||
| JackMidiBuffer* GetMidiInputBuffer(int port_index); | |||
| JackMidiBuffer* GetMidiOutputBuffer(int port_index); | |||
| JackEventBuffer* GetMidiInputBuffer(int port_index); | |||
| JackEventBuffer* GetMidiOutputBuffer(int port_index); | |||
| void SaveConnections(int alias); | |||
| @@ -462,7 +462,7 @@ namespace Jack | |||
| //buffers | |||
| for (int midi_port_index = 0; midi_port_index < fParams.fSendMidiChannels; midi_port_index++) { | |||
| fNetMidiCaptureBuffer->SetBuffer(midi_port_index, | |||
| static_cast<JackMidiBuffer*>(jack_port_get_buffer(fMidiCapturePorts[midi_port_index], | |||
| static_cast<JackEventBuffer*>(jack_port_get_buffer(fMidiCapturePorts[midi_port_index], | |||
| fParams.fPeriodSize))); | |||
| } | |||
| for (int audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++) { | |||
| @@ -487,7 +487,7 @@ namespace Jack | |||
| for (int midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++) { | |||
| fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, | |||
| static_cast<JackMidiBuffer*>(jack_port_get_buffer(fMidiPlaybackPorts[midi_port_index], | |||
| static_cast<JackEventBuffer*>(jack_port_get_buffer(fMidiPlaybackPorts[midi_port_index], | |||
| fParams.fPeriodSize))); | |||
| } | |||
| for (int audio_port_index = 0; audio_port_index < fParams.fReturnAudioChannels; audio_port_index++) { | |||
| @@ -97,7 +97,7 @@ namespace Jack | |||
| fMaxBufsize = fNPorts * sizeof(sample_t) * params->fPeriodSize; | |||
| fMaxPcktSize = params->fMtu - sizeof(packet_header_t); | |||
| fBuffer = new char[fMaxBufsize]; | |||
| fPortBuffer = new JackMidiBuffer* [fNPorts]; | |||
| fPortBuffer = new JackEventBuffer* [fNPorts]; | |||
| for (int port_index = 0; port_index < fNPorts; port_index++) { | |||
| fPortBuffer[port_index] = NULL; | |||
| } | |||
| @@ -125,12 +125,12 @@ namespace Jack | |||
| return (res1) ? res2 + 1 : res2; | |||
| } | |||
| void NetMidiBuffer::SetBuffer(int index, JackMidiBuffer* buffer) | |||
| void NetMidiBuffer::SetBuffer(int index, JackEventBuffer* buffer) | |||
| { | |||
| fPortBuffer[index] = buffer; | |||
| } | |||
| JackMidiBuffer* NetMidiBuffer::GetBuffer(int index) | |||
| JackEventBuffer* NetMidiBuffer::GetBuffer(int index) | |||
| { | |||
| return fPortBuffer[index]; | |||
| } | |||
| @@ -155,14 +155,14 @@ namespace Jack | |||
| for (int port_index = 0; port_index < fNPorts; port_index++) { | |||
| char* write_pos = fBuffer + pos; | |||
| copy_size = sizeof(JackMidiBuffer) + fPortBuffer[port_index]->event_count * sizeof(JackMidiEvent); | |||
| copy_size = sizeof(JackEventBuffer) + fPortBuffer[port_index]->event_count * sizeof(JackEvent); | |||
| memcpy(fBuffer + pos, fPortBuffer[port_index], copy_size); | |||
| pos += copy_size; | |||
| memcpy(fBuffer + pos, | |||
| fPortBuffer[port_index] + (fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos), | |||
| fPortBuffer[port_index]->write_pos); | |||
| pos += fPortBuffer[port_index]->write_pos; | |||
| JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(write_pos); | |||
| JackEventBuffer* midi_buffer = reinterpret_cast<JackEventBuffer*>(write_pos); | |||
| MidiBufferHToN(midi_buffer, midi_buffer); | |||
| } | |||
| return pos; | |||
| @@ -174,9 +174,9 @@ namespace Jack | |||
| size_t copy_size; | |||
| for (int port_index = 0; port_index < fNPorts; port_index++) { | |||
| JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(fBuffer + pos); | |||
| JackEventBuffer* midi_buffer = reinterpret_cast<JackEventBuffer*>(fBuffer + pos); | |||
| MidiBufferNToH(midi_buffer, midi_buffer); | |||
| copy_size = sizeof(JackMidiBuffer) + reinterpret_cast<JackMidiBuffer*>(fBuffer + pos)->event_count * sizeof(JackMidiEvent); | |||
| copy_size = sizeof(JackEventBuffer) + reinterpret_cast<JackEventBuffer*>(fBuffer + pos)->event_count * sizeof(JackEvent); | |||
| memcpy(fPortBuffer[port_index], fBuffer + pos, copy_size); | |||
| pos += copy_size; | |||
| memcpy(fPortBuffer[port_index] + (fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos), | |||
| @@ -1270,7 +1270,7 @@ namespace Jack | |||
| jack_info("**********************************************"); | |||
| } | |||
| SERVER_EXPORT void MidiBufferHToN(JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer) | |||
| SERVER_EXPORT void MidiBufferHToN(JackEventBuffer* src_buffer, JackEventBuffer* dst_buffer) | |||
| { | |||
| dst_buffer->magic = htonl(src_buffer->magic); | |||
| dst_buffer->buffer_size = htonl(src_buffer->buffer_size); | |||
| @@ -1280,7 +1280,7 @@ namespace Jack | |||
| dst_buffer->lost_events = htonl(src_buffer->lost_events); | |||
| } | |||
| SERVER_EXPORT void MidiBufferNToH(JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer) | |||
| SERVER_EXPORT void MidiBufferNToH(JackEventBuffer* src_buffer, JackEventBuffer* dst_buffer) | |||
| { | |||
| dst_buffer->magic = ntohl(src_buffer->magic); | |||
| dst_buffer->buffer_size = ntohl(src_buffer->buffer_size); | |||
| @@ -17,7 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include "JackMidiPort.h" | |||
| #include "JackEventPort.h" | |||
| #include "JackTools.h" | |||
| #include "types.h" | |||
| #include "transport.h" | |||
| @@ -224,7 +224,7 @@ namespace Jack | |||
| \Brief Midi buffer and operations class | |||
| This class is a toolset to manipulate Midi buffers. | |||
| A JackMidiBuffer has a fixed size, which is the same than an audio buffer size. | |||
| A JackEventBuffer has a fixed size, which is the same than an audio buffer size. | |||
| An intermediate fixed size buffer allows to uninterleave midi data (from jack ports). | |||
| But for a big majority of the process cycles, this buffer is filled less than 1%, | |||
| Sending over a network 99% of useless data seems completely unappropriate. | |||
| @@ -245,7 +245,7 @@ namespace Jack | |||
| char* fBuffer; | |||
| char* fNetBuffer; | |||
| JackMidiBuffer** fPortBuffer; | |||
| JackEventBuffer** fPortBuffer; | |||
| size_t fCycleBytesSize; // needed size in bytes ofr an entire cycle | |||
| @@ -260,8 +260,8 @@ namespace Jack | |||
| size_t GetCycleSize(); | |||
| int GetNumPackets(int data_sizen, int max_size); | |||
| void SetBuffer(int index, JackMidiBuffer* buffer); | |||
| JackMidiBuffer* GetBuffer(int index); | |||
| void SetBuffer(int index, JackEventBuffer* buffer); | |||
| JackEventBuffer* GetBuffer(int index); | |||
| //utility | |||
| void DisplayEvents(); | |||
| @@ -492,8 +492,8 @@ namespace Jack | |||
| SERVER_EXPORT void SessionParamsNToH(session_params_t* src_params, session_params_t* dst_params); | |||
| SERVER_EXPORT void PacketHeaderHToN(packet_header_t* src_header, packet_header_t* dst_header); | |||
| SERVER_EXPORT void PacketHeaderNToH(packet_header_t* src_header, packet_header_t* dst_header); | |||
| SERVER_EXPORT void MidiBufferHToN(JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer); | |||
| SERVER_EXPORT void MidiBufferNToH(JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer); | |||
| SERVER_EXPORT void MidiBufferHToN(JackEventBuffer* src_buffer, JackEventBuffer* dst_buffer); | |||
| SERVER_EXPORT void MidiBufferNToH(JackEventBuffer* src_buffer, JackEventBuffer* dst_buffer); | |||
| SERVER_EXPORT void TransportDataHToN(net_transport_data_t* src_params, net_transport_data_t* dst_params); | |||
| SERVER_EXPORT void TransportDataNToH(net_transport_data_t* src_params, net_transport_data_t* dst_params); | |||
| //display session parameters | |||
| @@ -27,7 +27,7 @@ namespace Jack | |||
| static const JackPortType* gPortTypes[] = | |||
| { | |||
| &gAudioPortType, | |||
| &gMidiPortType, | |||
| &gMessagePortType, | |||
| }; | |||
| jack_port_type_id_t PORT_TYPES_MAX = sizeof(gPortTypes) / sizeof(gPortTypes[0]); | |||
| @@ -41,7 +41,7 @@ extern jack_port_type_id_t GetPortTypeId(const char* port_type); | |||
| extern const struct JackPortType* GetPortType(jack_port_type_id_t port_type_id); | |||
| extern const struct JackPortType gAudioPortType; | |||
| extern const struct JackPortType gMidiPortType; | |||
| extern const struct JackPortType gMessagePortType; | |||
| } // namespace Jack | |||
| @@ -0,0 +1,209 @@ | |||
| /* | |||
| Copyright (C) 2004 Ian Esten | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU Lesser General Public License as published by | |||
| the Free Software Foundation; either version 2.1 of the License, or | |||
| (at your option) any later version. | |||
| This program is distributed in the hope that it will be useful, | |||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| GNU Lesser General Public License for more details. | |||
| You should have received a copy of the GNU Lesser General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __JACK_EVENTPORT_H | |||
| #define __JACK_EVENTPORT_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #include <jack/weakmacros.h> | |||
| #include <jack/types.h> | |||
| #include <stdlib.h> | |||
| /** Type for raw event data contained in @ref jack_midi_event_t. */ | |||
| typedef unsigned char jack_midi_data_t; | |||
| /** A Jack event. */ | |||
| typedef struct _jack_midi_event | |||
| { | |||
| jack_nframes_t time; /**< Sample index at which event is valid */ | |||
| size_t size; /**< Number of bytes of data in \a buffer */ | |||
| jack_midi_data_t *buffer; /**< Raw event data */ | |||
| } jack_midi_event_t; | |||
| /** Type for raw event data contained in @ref jack_event_t. */ | |||
| typedef jack_midi_data_t jack_event_data_t; | |||
| typedef jack_midi_event_t jack_event_t; | |||
| /** | |||
| * @defgroup EVENTAPI Reading and writing event data | |||
| * @{ | |||
| */ | |||
| /** Get number of events in a port buffer. | |||
| * | |||
| * @param port_buffer Port buffer from which to retrieve event. | |||
| * @return number of events inside @a port_buffer | |||
| */ | |||
| uint32_t | |||
| jack_event_get_count(void* port_buffer) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** Get an event from an event port buffer. It is up to the caller to determine | |||
| * which protocol to interpret the data with. The port's type and the metadata | |||
| * API should suffice to do so. | |||
| * | |||
| * If the event represents MIDI data: | |||
| * | |||
| * Jack MIDI is normalised, the MIDI event returned by this function is | |||
| * guaranteed to be a complete MIDI event (the status byte will always be | |||
| * present, and no realtime events will interspered with the event). | |||
| * | |||
| * This rule does not apply to System Exclusive MIDI messages | |||
| * since they can be of arbitrary length. | |||
| * To maintain smooth realtime operation such events CAN be deliverd | |||
| * as multiple, non-normalised events. | |||
| * The maximum size of one event "chunk" depends on the MIDI backend in use. | |||
| * For example the midiseq driver will create chunks of 256 bytes. | |||
| * The first SysEx "chunked" event starts with 0xF0 and the last | |||
| * delivered chunk ends with 0xF7. | |||
| * To receive the full SysEx message, a caller of jack_midi_event_get() | |||
| * must concatenate chunks until a chunk ends with 0xF7. | |||
| * | |||
| * @param event Event structure to store retrieved event in. | |||
| * @param port_buffer Port buffer from which to retrieve event. | |||
| * @param event_index Index of event to retrieve. | |||
| * @return 0 on success, ENODATA if buffer is empty. | |||
| */ | |||
| int | |||
| jack_event_get(jack_event_t *event, | |||
| void *port_buffer, | |||
| uint32_t event_index) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** Clear an event buffer. | |||
| * | |||
| * This should be called at the beginning of each process cycle before calling | |||
| * @ref jack_event_reserve or @ref jack_event_write. This | |||
| * function may not be called on an input port's buffer. | |||
| * | |||
| * @param port_buffer Port buffer to clear (must be an output port buffer). | |||
| */ | |||
| void | |||
| jack_event_clear_buffer(void *port_buffer) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** Reset an event buffer (from data allocated outside of JACK). | |||
| * | |||
| * This should be called at the beginning of each process cycle before calling | |||
| * @ref jack_event_reserve or @ref jack_event_write. This | |||
| * function may not be called on an input port's buffer. | |||
| * | |||
| * @deprecated Please use jack_event_clear_buffer(). | |||
| * | |||
| * @param port_buffer Port buffer to reset. | |||
| */ | |||
| void | |||
| jack_event_reset_buffer(void *port_buffer) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; | |||
| /** Get the size of the largest event that can be stored by the port. | |||
| * | |||
| * This function returns the current space available, taking into account | |||
| * events already stored in the port. | |||
| * | |||
| * @param port_buffer Port buffer to check size of. | |||
| */ | |||
| size_t | |||
| jack_event_max_size(void* port_buffer) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** Allocate space for an event to be written to an event port buffer. | |||
| * | |||
| * Clients are to write the actual event data to be written starting at the | |||
| * pointer returned by this function. Clients must not write more than | |||
| * @a data_size bytes into this buffer. Clients may write arbitrary binary data, | |||
| * but should only write events using the protocol associated with the port. | |||
| * | |||
| * If this is a MIDI port, clients must write normalised | |||
| * MIDI data to the port - no running status and no (1-byte) realtime | |||
| * messages interspersed with other messages (realtime messages are fine | |||
| * when they occur on their own, like other messages). | |||
| * | |||
| * Events must be written in order, sorted by their sample offsets. | |||
| * JACK will not sort the events for you, and will refuse to store | |||
| * out-of-order events. | |||
| * | |||
| * @param port_buffer Buffer to write event to. | |||
| * @param time Sample offset of event. | |||
| * @param data_size Length of event's raw data in bytes. | |||
| * @return Pointer to the beginning of the reserved event's data buffer, or | |||
| * NULL on error (ie not enough space). | |||
| */ | |||
| jack_event_data_t* | |||
| jack_event_reserve(void *port_buffer, | |||
| jack_nframes_t time, | |||
| size_t data_size) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** Write an event into an event port buffer. | |||
| * | |||
| * This function is simply a wrapper for @ref jack_event_reserve | |||
| * which writes the event data into the space reserved in the buffer. | |||
| * | |||
| * Clients must not write more than | |||
| * @a data_size bytes into this buffer. Clients may write arbitrary binary data, | |||
| * but should only write events using the protocol associated with the port. | |||
| * If this is a MIDI port, clients must write normalised | |||
| * MIDI data to the port - no running status and no (1-byte) realtime | |||
| * messages interspersed with other messages (realtime messages are fine | |||
| * when they occur on their own, like other messages). | |||
| * | |||
| * Events must be written in order, sorted by their sample offsets. | |||
| * JACK will not sort the events for you, and will refuse to store | |||
| * out-of-order events. | |||
| * | |||
| * @param port_buffer Buffer to write event to. | |||
| * @param time Sample offset of event. | |||
| * @param data Message data to be written. | |||
| * @param data_size Length of @a data in bytes. | |||
| * @return 0 on success, ENOBUFS if there's not enough space in buffer for event. | |||
| */ | |||
| int | |||
| jack_event_write(void *port_buffer, | |||
| jack_nframes_t time, | |||
| const jack_event_data_t *data, | |||
| size_t data_size) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** Get the number of events that could not be written to @a port_buffer. | |||
| * | |||
| * This function returning a non-zero value implies @a port_buffer is full. | |||
| * Currently the only way this can happen is if events are lost on port mixdown | |||
| * (when multiple event output ports are connected to one input port). | |||
| * | |||
| * @param port_buffer Port to receive count for. | |||
| * @returns Number of events that could not be written to @a port_buffer. | |||
| */ | |||
| uint32_t | |||
| jack_event_get_lost_count(void *port_buffer) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /*@}*/ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __JACK_MIDIPORT_H */ | |||
| @@ -709,6 +709,13 @@ float jack_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @return the UUID of the jack_port_t | |||
| * | |||
| * @see jack_uuid_to_string() to convert into a string representation | |||
| */ | |||
| jack_uuid_t jack_port_uuid (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** | |||
| * Create a new port for the client. This is an object used for moving | |||
| * data of any type in or out of the client. Ports may be connected | |||
| @@ -723,9 +730,9 @@ float jack_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; | |||
| * The @a port_name must be unique among all ports owned by this client. | |||
| * If the name is not unique, the registration will fail. | |||
| * | |||
| * All ports have a type, which may be any non-NULL and non-zero | |||
| * length string, passed as an argument. Some port types are built | |||
| * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE. | |||
| * All ports have a type. It is strongly encouraged to use @ref jack_port_register_audio | |||
| * for signal channels and @ref jack_port_register_message for message (MIDI, OSC, …) | |||
| * channels instead of this method. | |||
| * | |||
| * @param client pointer to JACK client structure. | |||
| * @param port_name non-empty short name for the new port (not | |||
| @@ -744,6 +751,43 @@ jack_port_t * jack_port_register (jack_client_t *client, | |||
| unsigned long flags, | |||
| unsigned long buffer_size) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** | |||
| * Create a new message port as documented in @ref jack_port_register. Use the metadata API | |||
| * to specify what type of data this port is sending/receiving. The default is "PCM" for plain | |||
| * audio. To create a port containing voltage control instead of audio, you need to call | |||
| * @code | |||
| * jack_uuid_t uuid = jack_port_uuid(port); | |||
| * jack_set_property(client, uuid, JACK_METADATA_EVENT_TYPE, "VC", "text/plain"); | |||
| * @endcode | |||
| */ | |||
| inline jack_port_t * jack_port_register_audio (jack_client_t *client, | |||
| const char *port_name, | |||
| unsigned long flags, | |||
| unsigned long buffer_size) JACK_OPTIONAL_WEAK_EXPORT | |||
| { | |||
| return jack_port_register(client, port_name, JACK_DEFAULT_AUDIO_TYPE, flags, buffer_size); | |||
| } | |||
| /** | |||
| * Create a new message port as documented in @ref jack_port_register. Use the metadata API | |||
| * to specify which communication protocols this port understands. The default is "MIDI". To | |||
| * create an OSC port for example, you need to call | |||
| * @code | |||
| * jack_uuid_t uuid = jack_port_uuid(port); | |||
| * jack_set_property(client, uuid, JACK_METADATA_EVENT_TYPE, "OSC", "text/plain"); | |||
| * @endcode | |||
| */ | |||
| inline jack_port_t * jack_port_register_message (jack_client_t *client, | |||
| const char *port_name, | |||
| unsigned long flags, | |||
| unsigned long buffer_size) JACK_OPTIONAL_WEAK_EXPORT | |||
| { | |||
| return jack_port_register(client, port_name, JACK_DEFAULT_MESSAGE_TYPE, flags, buffer_size); | |||
| } | |||
| /** | |||
| * Remove the port from the client, disconnecting any existing | |||
| * connections. | |||
| @@ -773,13 +817,6 @@ int jack_port_unregister (jack_client_t *client, jack_port_t *port) JACK_OPTIONA | |||
| */ | |||
| void * jack_port_get_buffer (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** | |||
| * @return the UUID of the jack_port_t | |||
| * | |||
| * @see jack_uuid_to_string() to convert into a string representation | |||
| */ | |||
| jack_uuid_t jack_port_uuid (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; | |||
| /** | |||
| * @return the full name of the jack_port_t (including the @a | |||
| * "client_name:" prefix). | |||
| @@ -241,9 +241,20 @@ extern const char* JACK_METADATA_CONNECTED; | |||
| * OSC events is not a valid MIDI status byte, so MIDI clients that check the | |||
| * status byte will gracefully ignore OSC messages if the user makes an | |||
| * inappropriate connection. | |||
| * | |||
| * This property may contain values other than "MIDI" and "OSC" for custom (or | |||
| * newer) protocols. If it is not set, the contained data should be treated as "MIDI". | |||
| */ | |||
| extern const char* JACK_METADATA_EVENT_TYPES; | |||
| /** | |||
| * OSC allows for arbitrary paths and function names. A namespace is an interface | |||
| * that gives certain paths and functions a semantic meaning. Currently, the only | |||
| * standardized interface is "SYN" (<http://opensoundcontrol.org/implementation/syn-namespace>). | |||
| * Multiple namespaces (if supported) are specified as comma separated list. | |||
| */ | |||
| extern const char* JACK_METADATA_EVENT_OSC_NAMESPACE; | |||
| /** | |||
| * A value that should be shown when attempting to identify the | |||
| * specific hardware outputs of a client. Typical values might be | |||
| @@ -304,10 +315,11 @@ extern const char* JACK_METADATA_PORT_GROUP; | |||
| * The type of an audio signal. | |||
| * | |||
| * This property allows audio ports to be tagged with a "meaning". The value | |||
| * is a simple string. Currently, the only type is "CV", for "control voltage" | |||
| * ports. Hosts SHOULD be take care to not treat CV ports as audibile and send | |||
| * their output directly to speakers. In particular, CV ports are not | |||
| * necessarily periodic at all and may have very high DC. | |||
| * is a simple string. Currently, the only types are "PCM" for normal audio and | |||
| * "CV", for "control voltage" ports. Hosts SHOULD be take care to not treat CV ports | |||
| * as audibile and send their output directly to speakers. In particular, CV ports | |||
| * are not necessarily periodic at all and may have very high DC. Not setting this property | |||
| * implies the default value "PCM". | |||
| */ | |||
| extern const char* JACK_METADATA_SIGNAL_TYPE; | |||
| @@ -27,22 +27,9 @@ extern "C" { | |||
| #include <jack/weakmacros.h> | |||
| #include <jack/types.h> | |||
| #include <jack/eventport.h> | |||
| #include <stdlib.h> | |||
| /** Type for raw event data contained in @ref jack_midi_event_t. */ | |||
| typedef unsigned char jack_midi_data_t; | |||
| /** A Jack MIDI event. */ | |||
| typedef struct _jack_midi_event | |||
| { | |||
| jack_nframes_t time; /**< Sample index at which event is valid */ | |||
| size_t size; /**< Number of bytes of data in \a buffer */ | |||
| jack_midi_data_t *buffer; /**< Raw MIDI data */ | |||
| } jack_midi_event_t; | |||
| /** | |||
| * @defgroup MIDIAPI Reading and writing MIDI data | |||
| * @{ | |||
| @@ -194,4 +181,3 @@ jack_midi_get_lost_event_count(void *port_buffer) JACK_OPTIONAL_WEAK_EXPORT; | |||
| #endif /* __JACK_MIDIPORT_H */ | |||
| @@ -446,10 +446,11 @@ typedef void (*JackInfoShutdownCallback)(jack_status_t code, const char* reason, | |||
| /** | |||
| * Used for the type argument of jack_port_register() for default | |||
| * audio ports and midi ports. | |||
| * audio ports and event ports. | |||
| */ | |||
| #define JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio" | |||
| #define JACK_DEFAULT_MIDI_TYPE "8 bit raw midi" | |||
| #define JACK_DEFAULT_MESSAGE_TYPE "binary message data" | |||
| /** | |||
| * For convenience, use this typedef if you want to be able to change | |||
| @@ -56,7 +56,8 @@ def build(bld): | |||
| 'JackPort.cpp', | |||
| 'JackPortType.cpp', | |||
| 'JackAudioPort.cpp', | |||
| 'JackMidiPort.cpp', | |||
| 'JackEventPort.cpp', | |||
| 'JackEventAPI.cpp', | |||
| 'JackMidiAPI.cpp', | |||
| 'JackEngineControl.cpp', | |||
| 'JackShmMem.cpp', | |||
| @@ -239,17 +240,17 @@ def build(bld): | |||
| 'JackNetInterface.cpp', | |||
| 'JackArgParser.cpp', | |||
| 'JackRequestDecoder.cpp', | |||
| 'JackMidiAsyncQueue.cpp', | |||
| 'JackMidiAsyncWaitQueue.cpp', | |||
| 'JackMidiBufferReadQueue.cpp', | |||
| 'JackMidiBufferWriteQueue.cpp', | |||
| 'JackEventAsyncQueue.cpp', | |||
| 'JackEventAsyncWaitQueue.cpp', | |||
| 'JackEventBufferReadQueue.cpp', | |||
| 'JackEventBufferWriteQueue.cpp', | |||
| 'JackMidiRawInputWriteQueue.cpp', | |||
| 'JackMidiRawOutputWriteQueue.cpp', | |||
| 'JackMidiReadQueue.cpp', | |||
| 'JackMidiReceiveQueue.cpp', | |||
| 'JackMidiSendQueue.cpp', | |||
| 'JackEventReadQueue.cpp', | |||
| 'JackEventReceiveQueue.cpp', | |||
| 'JackEventSendQueue.cpp', | |||
| 'JackMidiUtil.cpp', | |||
| 'JackMidiWriteQueue.cpp', | |||
| 'JackEventWriteQueue.cpp', | |||
| 'JackMetadata.cpp', | |||
| ] | |||
| @@ -26,7 +26,9 @@ | |||
| #include <getopt.h> | |||
| #include <jack/jack.h> | |||
| #include <jack/metadata.h> | |||
| #include <jack/session.h> | |||
| #include <jack/types.h> | |||
| #define TRUE 1 | |||
| #define FALSE 0 | |||
| @@ -51,6 +53,8 @@ show_usage (char *my_name) | |||
| fprintf (stderr, "\nusage: %s [options] port1 port2\n", my_name); | |||
| fprintf (stderr, "Connects two JACK ports together.\n\n"); | |||
| fprintf (stderr, " -s, --server <name> Connect to the jack server named <name>\n"); | |||
| fprintf (stderr, " -u, --uuid Reference ports by their UUID instead of their name\n"); | |||
| fprintf (stderr, " -f, --force Force connect even if the ports may not be compatible\n"); | |||
| fprintf (stderr, " -v, --version Output version information and exit\n"); | |||
| fprintf (stderr, " -h, --help Display this help message\n\n"); | |||
| fprintf (stderr, "For more information see http://jackaudio.org/\n"); | |||
| @@ -73,6 +77,7 @@ main (int argc, char *argv[]) | |||
| char portA[300]; | |||
| char portB[300]; | |||
| int use_uuid=0; | |||
| int force_connect=0; | |||
| int connecting, disconnecting; | |||
| int port1_flags, port2_flags; | |||
| int rc = 1; | |||
| @@ -82,10 +87,11 @@ main (int argc, char *argv[]) | |||
| { "help", 0, 0, 'h' }, | |||
| { "version", 0, 0, 'v' }, | |||
| { "uuid", 0, 0, 'u' }, | |||
| { "force", 0, 0, 'f' }, | |||
| { 0, 0, 0, 0 } | |||
| }; | |||
| while ((c = getopt_long (argc, argv, "s:hvu", long_options, &option_index)) >= 0) { | |||
| while ((c = getopt_long (argc, argv, "s:fhvu", long_options, &option_index)) >= 0) { | |||
| switch (c) { | |||
| case 's': | |||
| server_name = (char *) malloc (sizeof (char) * strlen(optarg)); | |||
| @@ -95,6 +101,9 @@ main (int argc, char *argv[]) | |||
| case 'u': | |||
| use_uuid = 1; | |||
| break; | |||
| case 'f': | |||
| force_connect = 1; | |||
| break; | |||
| case 'h': | |||
| show_usage (my_name); | |||
| return 1; | |||
| @@ -218,6 +227,45 @@ main (int argc, char *argv[]) | |||
| */ | |||
| if (connecting) { | |||
| if (!force_connect) { | |||
| int fail = 0; | |||
| /* Get the port type to know which proprty to query. */ | |||
| const char* src_port_type = jack_port_type(src_port); | |||
| const char* dst_port_type = jack_port_type(dst_port); | |||
| /* Get src's port content */ | |||
| char* src_type; | |||
| if (strcmp(src_port_type, JACK_DEFAULT_AUDIO_TYPE) == 0) | |||
| jack_get_property(jack_port_uuid(src_port), JACK_METADATA_SIGNAL_TYPE, &src_type, NULL); | |||
| else if (strcmp(src_port_type, JACK_DEFAULT_MESSAGE_TYPE) == 0) | |||
| jack_get_property(jack_port_uuid(src_port), JACK_METADATA_EVENT_TYPES, &src_type, NULL); | |||
| else | |||
| fail = 1; | |||
| /* Get src's port content */ | |||
| char* dst_type; | |||
| if (strcmp(dst_port_type, JACK_DEFAULT_AUDIO_TYPE) == 0) | |||
| jack_get_property(jack_port_uuid(dst_port), JACK_METADATA_SIGNAL_TYPE, &dst_type, NULL); | |||
| else if (strcmp(dst_port_type, JACK_DEFAULT_MESSAGE_TYPE) == 0) | |||
| jack_get_property(jack_port_uuid(dst_port), JACK_METADATA_EVENT_TYPES, &dst_type, NULL); | |||
| else | |||
| fail = 1; | |||
| /* Finally compare the ports */ | |||
| if (!fail) | |||
| // TODO this does not handle if multiple content types are supported. | |||
| fail = strcmp(src_type, dst_type); | |||
| jack_free(src_type); | |||
| jack_free(dst_type); | |||
| if (fail) { | |||
| fprintf (stderr, "cannot connect ports, since they may have different kinds of data. Run with --force to connect them anyways.\n"); | |||
| goto exit; | |||
| } | |||
| } | |||
| if (jack_connect(client, jack_port_name(src_port), jack_port_name(dst_port))) { | |||
| fprintf (stderr, "cannot connect client, already connected?\n"); | |||
| goto exit; | |||
| @@ -22,8 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include "JackALSARawMidiPort.h" | |||
| #include "JackALSARawMidiReceiveQueue.h" | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackMidiBufferWriteQueue.h" | |||
| #include "JackMidi.h" | |||
| #include "JackMidiRawInputWriteQueue.h" | |||
| namespace Jack { | |||
| @@ -22,8 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include "JackALSARawMidiPort.h" | |||
| #include "JackALSARawMidiSendQueue.h" | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackMidiBufferReadQueue.h" | |||
| #include "JackMidi.h" | |||
| #include "JackMidiRawOutputWriteQueue.h" | |||
| namespace Jack { | |||
| @@ -21,6 +21,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include "JackError.h" | |||
| #include "JackMidiUtil.h" | |||
| /* Somehow the compiler doesn't accept my typedef in JackMidi.h */ | |||
| typedef jack_event_data_t jack_midi_data_t; | |||
| typedef jack_event_t jack_midi_event_t; | |||
| using Jack::JackALSARawMidiReceiveQueue; | |||
| JackALSARawMidiReceiveQueue:: | |||
| @@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include <alsa/asoundlib.h> | |||
| #include "JackMidiReceiveQueue.h" | |||
| #include "JackMidi.h" | |||
| namespace Jack { | |||
| @@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include <alsa/asoundlib.h> | |||
| #include "JackMidiSendQueue.h" | |||
| #include "JackMidi.h" | |||
| namespace Jack { | |||
| @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #define __JackFFADOMidiInputPort__ | |||
| #include "JackFFADOMidiReceiveQueue.h" | |||
| #include "JackMidiBufferWriteQueue.h" | |||
| #include "JackMidi.h" | |||
| #include "JackMidiRawInputWriteQueue.h" | |||
| namespace Jack { | |||
| @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #define __JackFFADOMidiOutputPort__ | |||
| #include "JackFFADOMidiSendQueue.h" | |||
| #include "JackMidiBufferReadQueue.h" | |||
| #include "JackMidi.h" | |||
| #include "JackMidiRawOutputWriteQueue.h" | |||
| namespace Jack { | |||
| @@ -20,6 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #include "JackFFADOMidiReceiveQueue.h" | |||
| #include "JackMidiUtil.h" | |||
| /* Somehow the compiler doesn't accept my typedef in JackMidi.h */ | |||
| typedef jack_event_data_t jack_midi_data_t; | |||
| typedef jack_event_t jack_midi_event_t; | |||
| using Jack::JackFFADOMidiReceiveQueue; | |||
| JackFFADOMidiReceiveQueue::JackFFADOMidiReceiveQueue() | |||
| @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #ifndef __JackFFADOMidiReceiveQueue__ | |||
| #define __JackFFADOMidiReceiveQueue__ | |||
| #include "JackMidiReceiveQueue.h" | |||
| #include "JackMidi.h" | |||
| namespace Jack { | |||
| @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| #ifndef __JackFFADOMidiSendQueue__ | |||
| #define __JackFFADOMidiSendQueue__ | |||
| #include "JackMidiSendQueue.h" | |||
| #include "JackMidi.h" | |||
| namespace Jack { | |||
| @@ -21,8 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #define __JackCoreMidiInputPort__ | |||
| #include "JackCoreMidiPort.h" | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackMidiBufferWriteQueue.h" | |||
| #include "JackMidi.h" | |||
| namespace Jack { | |||
| @@ -23,8 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include <semaphore.h> | |||
| #include "JackCoreMidiPort.h" | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackMidiBufferReadQueue.h" | |||
| #include "JackMidi.h" | |||
| #include "JackThread.h" | |||
| namespace Jack { | |||
| @@ -28,6 +28,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include "JackTime.h" | |||
| #include "JackError.h" | |||
| /* Somehow the compiler doesn't accept my typedef in JackMidi.h */ | |||
| typedef jack_event_data_t jack_midi_data_t; | |||
| typedef jack_event_t jack_midi_event_t; | |||
| using Jack::JackCoreMidiOutputPort; | |||
| JackCoreMidiOutputPort::JackCoreMidiOutputPort(double time_ratio, | |||
| @@ -20,8 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #ifndef __JackWinMMEOutputPort__ | |||
| #define __JackWinMMEOutputPort__ | |||
| #include "JackMidiAsyncQueue.h" | |||
| #include "JackMidiBufferReadQueue.h" | |||
| #include "JackMidi.h" | |||
| #include "JackThread.h" | |||
| #include "JackWinMMEPort.h" | |||