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.
22 #include "JackFFADOMidiSendQueue.h"
23 #include "JackMidiUtil.h"
25 using Jack::JackFFADOMidiSendQueue
;
27 JackFFADOMidiSendQueue::JackFFADOMidiSendQueue()
32 Jack::JackMidiWriteQueue::EnqueueResult
33 JackFFADOMidiSendQueue::EnqueueEvent(jack_nframes_t time
, size_t size
,
34 jack_midi_data_t
*buffer
)
37 jack_nframes_t relative_time
= (time
< last_frame
) ? 0 : time
- last_frame
;
38 if (index
< relative_time
) {
39 index
= (relative_time
% 8) ?
40 (relative_time
& (~ ((jack_nframes_t
) 7))) + 8 : relative_time
;
42 if (index
>= length
) {
45 output_buffer
[index
] = 0x01000000 | ((uint32_t) *buffer
);
51 JackFFADOMidiSendQueue::GetNextScheduleFrame()
53 return last_frame
+ index
;
57 JackFFADOMidiSendQueue::ResetOutputBuffer(uint32_t *output_buffer
,
58 jack_nframes_t length
)
61 last_frame
= GetLastFrame();
62 this->length
= length
;
63 this->output_buffer
= output_buffer
;