Jack2 1.9.12

JackFFADOMidiSendQueue.cpp
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 #include <cassert>
21
22 #include "JackFFADOMidiSendQueue.h"
23 #include "JackMidiUtil.h"
24
25 using Jack::JackFFADOMidiSendQueue;
26
27 JackFFADOMidiSendQueue::JackFFADOMidiSendQueue()
28 {
29 // Empty
30 }
31
32 Jack::JackMidiWriteQueue::EnqueueResult
33 JackFFADOMidiSendQueue::EnqueueEvent(jack_nframes_t time, size_t size,
34 jack_midi_data_t *buffer)
35 {
36 assert(size == 1);
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;
41 }
42 if (index >= length) {
43 return BUFFER_FULL;
44 }
45 output_buffer[index] = 0x01000000 | ((uint32_t) *buffer);
46 index += 8;
47 return OK;
48 }
49
50 jack_nframes_t
51 JackFFADOMidiSendQueue::GetNextScheduleFrame()
52 {
53 return last_frame + index;
54 }
55
56 void
57 JackFFADOMidiSendQueue::ResetOutputBuffer(uint32_t *output_buffer,
58 jack_nframes_t length)
59 {
60 index = 0;
61 last_frame = GetLastFrame();
62 this->length = length;
63 this->output_buffer = output_buffer;
64 }
Jack::JackFFADOMidiSendQueue::EnqueueEvent
EnqueueResult EnqueueEvent(jack_nframes_t time, size_t size, jack_midi_data_t *buffer)
Definition: JackFFADOMidiSendQueue.cpp:33
Jack::JackFFADOMidiSendQueue
Definition: JackFFADOMidiSendQueue.h:27
Jack::JackFFADOMidiSendQueue::GetNextScheduleFrame
jack_nframes_t GetNextScheduleFrame()
Definition: JackFFADOMidiSendQueue.cpp:51