Jack2 1.9.8
|
00001 /* 00002 Copyright (C) 2010 Devin Anderson 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published by 00006 the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 */ 00019 00020 #ifndef __JackMidiRawInputWriteQueue__ 00021 #define __JackMidiRawInputWriteQueue__ 00022 00023 #include "JackMidiAsyncQueue.h" 00024 #include "JackMidiWriteQueue.h" 00025 00026 namespace Jack { 00027 00036 class SERVER_EXPORT JackMidiRawInputWriteQueue: public JackMidiWriteQueue { 00037 00038 private: 00039 00040 jack_midi_event_t event; 00041 jack_midi_data_t event_byte; 00042 bool event_pending; 00043 size_t expected_bytes; 00044 jack_midi_data_t *input_buffer; 00045 size_t input_buffer_size; 00046 jack_midi_event_t *packet; 00047 JackMidiAsyncQueue *packet_queue; 00048 jack_midi_data_t status_byte; 00049 size_t total_bytes; 00050 size_t unbuffered_bytes; 00051 JackMidiWriteQueue *write_queue; 00052 00053 void 00054 Clear(); 00055 00056 bool 00057 PrepareBufferedEvent(jack_nframes_t time); 00058 00059 bool 00060 PrepareByteEvent(jack_nframes_t time, jack_midi_data_t byte); 00061 00062 void 00063 PrepareEvent(jack_nframes_t time, size_t size, 00064 jack_midi_data_t *buffer); 00065 00066 bool 00067 ProcessByte(jack_nframes_t time, jack_midi_data_t byte); 00068 00069 void 00070 RecordByte(jack_midi_data_t byte); 00071 00072 bool 00073 WriteEvent(jack_nframes_t boundary_frame); 00074 00075 protected: 00076 00083 virtual void 00084 HandleBufferFailure(size_t unbuffered_bytes, size_t total_bytes); 00085 00093 virtual void 00094 HandleEventLoss(jack_midi_event_t *event); 00095 00101 virtual void 00102 HandleIncompleteMessage(size_t total_bytes); 00103 00109 virtual void 00110 HandleInvalidStatusByte(jack_midi_data_t byte); 00111 00118 virtual void 00119 HandleUnexpectedSysexEnd(size_t total_bytes); 00120 00121 public: 00122 00123 using JackMidiWriteQueue::EnqueueEvent; 00124 00135 JackMidiRawInputWriteQueue(JackMidiWriteQueue *write_queue, 00136 size_t max_packet_data=4096, 00137 size_t max_packets=1024); 00138 00139 ~JackMidiRawInputWriteQueue(); 00140 00141 EnqueueResult 00142 EnqueueEvent(jack_nframes_t time, size_t size, 00143 jack_midi_data_t *buffer); 00144 00149 size_t 00150 GetAvailableSpace(); 00151 00170 jack_nframes_t 00171 Process(jack_nframes_t boundary_frame=0); 00172 00173 }; 00174 00175 } 00176 00177 #endif