Jack2: JackMidiRawInputWriteQueue.h Source File

Jack2 1.9.12

JackMidiRawInputWriteQueue.h
1 /*
2 Copyright (C) 2010 Devin Anderson
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __JackMidiRawInputWriteQueue__
21 #define __JackMidiRawInputWriteQueue__
22
23 #include "JackMidiAsyncQueue.h"
24 #include "JackMidiWriteQueue.h"
25
26 namespace Jack {
27
36 class SERVER_EXPORT JackMidiRawInputWriteQueue: public JackMidiWriteQueue {
37
38 private:
39
40 jack_midi_event_t event;
41 jack_midi_data_t event_byte;
42 bool event_pending;
43 size_t expected_bytes;
44 jack_midi_data_t *input_buffer;
45 size_t input_buffer_size;
46 jack_midi_event_t *packet;
47 JackMidiAsyncQueue *packet_queue;
48 jack_midi_data_t status_byte;
49 size_t total_bytes;
50 size_t unbuffered_bytes;
51 JackMidiWriteQueue *write_queue;
52
53 void
54 Clear();
55
56 bool
57 PrepareBufferedEvent(jack_nframes_t time);
58
59 bool
60 PrepareByteEvent(jack_nframes_t time, jack_midi_data_t byte);
61
62 void
63 PrepareEvent(jack_nframes_t time, size_t size,
64 jack_midi_data_t *buffer);
65
66 bool
67 ProcessByte(jack_nframes_t time, jack_midi_data_t byte);
68
69 void
70 RecordByte(jack_midi_data_t byte);
71
72 bool
73 WriteEvent(jack_nframes_t boundary_frame);
74
75 protected:
76
83 virtual void
84 HandleBufferFailure(size_t unbuffered_bytes, size_t total_bytes);
85
93 virtual void
94 HandleEventLoss(jack_midi_event_t *event);
95
101 virtual void
102 HandleIncompleteMessage(size_t total_bytes);
103
109 virtual void
110 HandleInvalidStatusByte(jack_midi_data_t byte);
111
118 virtual void
119 HandleUnexpectedSysexEnd(size_t total_bytes);
120
121 public:
122
123 using JackMidiWriteQueue::EnqueueEvent;
124
135 JackMidiRawInputWriteQueue(JackMidiWriteQueue *write_queue,
136 size_t max_packet_data=4096,
137 size_t max_packets=1024);
138
139 ~JackMidiRawInputWriteQueue();
140
141 EnqueueResult
142 EnqueueEvent(jack_nframes_t time, size_t size,
143 jack_midi_data_t *buffer);
144
149 size_t
150 GetAvailableSpace();
151
170 jack_nframes_t
171 Process(jack_nframes_t boundary_frame=0);
172
173 };
174
175 }
176
177 #endif
Jack::JackMidiAsyncQueue
Definition: JackMidiAsyncQueue.h:40
Jack::JackMidiRawInputWriteQueue
Definition: JackMidiRawInputWriteQueue.h:36
Jack::JackMidiWriteQueue
Definition: JackMidiWriteQueue.h:32
jack_midi_event_t
Definition: JackMidiPort.h:33
Jack::JackMidiWriteQueue::EnqueueEvent
virtual EnqueueResult EnqueueEvent(jack_nframes_t time, size_t size, jack_midi_data_t *buffer)=0