ScummVM API documentation
MidiEventQueue.h
1 /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
2  * Copyright (C) 2011-2022 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
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, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MT32EMU_MIDI_EVENT_QUEUE_H
19 #define MT32EMU_MIDI_EVENT_QUEUE_H
20 
21 #include "globals.h"
22 #include "Types.h"
23 
24 namespace MT32Emu {
25 
37 public:
38  class SysexDataStorage;
39 
40  struct MidiEvent {
41  const Bit8u *sysexData;
42  union {
43  Bit32u sysexLength;
44  Bit32u shortMessageData;
45  };
46  Bit32u timestamp;
47  };
48 
49  explicit MidiEventQueue(
50  // Must be a power of 2
51  Bit32u ringBufferSize,
52  Bit32u storageBufferSize
53  );
54  ~MidiEventQueue();
55  void reset();
56  bool pushShortMessage(Bit32u shortMessageData, Bit32u timestamp);
57  bool pushSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp);
58  const volatile MidiEvent *peekMidiEvent();
59  void dropMidiEvent();
60  inline bool isEmpty() const;
61 
62 private:
63  SysexDataStorage &sysexDataStorage;
64 
65  MidiEvent * const ringBuffer;
66  const Bit32u ringBufferMask;
67  volatile Bit32u startPosition;
68  volatile Bit32u endPosition;
69 };
70 
71 } // namespace MT32Emu
72 
73 #endif // #ifndef MT32EMU_MIDI_EVENT_QUEUE_H
Definition: Analog.h:26
Definition: MidiEventQueue.h:36
Definition: MidiEventQueue.h:40