Jack2
1.9.10
|
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 #include <cassert> 00021 00022 #include "JackFFADOMidiSendQueue.h" 00023 #include "JackMidiUtil.h" 00024 00025 using Jack::JackFFADOMidiSendQueue; 00026 00027 JackFFADOMidiSendQueue::JackFFADOMidiSendQueue() 00028 { 00029 // Empty 00030 } 00031 00032 Jack::JackMidiWriteQueue::EnqueueResult 00033 JackFFADOMidiSendQueue::EnqueueEvent(jack_nframes_t time, size_t size, 00034 jack_midi_data_t *buffer) 00035 { 00036 assert(size == 1); 00037 jack_nframes_t relative_time = (time < last_frame) ? 0 : time - last_frame; 00038 if (index < relative_time) { 00039 index = (relative_time % 8) ? 00040 (relative_time & (~ ((jack_nframes_t) 7))) + 8 : relative_time; 00041 } 00042 if (index >= length) { 00043 return BUFFER_FULL; 00044 } 00045 output_buffer[index] = 0x01000000 | ((uint32_t) *buffer); 00046 index += 8; 00047 return OK; 00048 } 00049 00050 jack_nframes_t 00051 JackFFADOMidiSendQueue::GetNextScheduleFrame() 00052 { 00053 return last_frame + index; 00054 } 00055 00056 void 00057 JackFFADOMidiSendQueue::ResetOutputBuffer(uint32_t *output_buffer, 00058 jack_nframes_t length) 00059 { 00060 index = 0; 00061 last_frame = GetLastFrame(); 00062 this->length = length; 00063 this->output_buffer = output_buffer; 00064 }