2 Copyright (C) 2010 Devin Anderson
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __JackMidiAsyncWaitQueue__
21 #define __JackMidiAsyncWaitQueue__
23 #include "JackMidiAsyncQueue.h"
28 * This is an asynchronous wait queue that allows a thread to wait for a
29 * message, either indefinitely or for a specified time. This is one
30 * example of a way that the `JackMidiAsyncQueue` class can be extended so
31 * that process threads can interact with non-process threads to send MIDI
34 * XXX: As of right now, this code hasn't been tested. Also, note the
35 * warning in the JackMidiAsyncWaitQueue.cpp about semaphore wait
39 class SERVER_EXPORT JackMidiAsyncWaitQueue
: public JackMidiAsyncQueue
{
43 JackSynchro semaphore
;
47 using JackMidiAsyncQueue::EnqueueEvent
;
50 * Creates a new asynchronous MIDI wait message queue. The queue can
51 * store up to `max_messages` MIDI messages and up to `max_bytes` of
52 * MIDI data before it starts rejecting messages.
55 JackMidiAsyncWaitQueue(size_t max_bytes
=4096,
56 size_t max_messages
=1024);
58 ~JackMidiAsyncWaitQueue();
61 * Dequeues and returns a MIDI event. Returns '0' if there are no MIDI
62 * events available right now.
69 * Waits a specified time for a MIDI event to be available, or
70 * indefinitely if the time is negative. Returns the MIDI event, or
71 * '0' if time runs out and no MIDI event is available.
75 DequeueEvent(long usecs
);
78 * Waits until the specified frame for a MIDI event to be available.
79 * Returns the MIDI event, or '0' if time runs out and no MIDI event is
84 DequeueEvent(jack_nframes_t frame
);
87 * Enqueues the MIDI event specified by the arguments. The return
88 * value indicates whether or not the event was successfully enqueued.
92 EnqueueEvent(jack_nframes_t time
, size_t size
,
93 jack_midi_data_t
*buffer
);