2 * Copyright (C) 2007-2016 David Robillard <d@drobilla.net>
3 * Copyright (C) 2007-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
5 * Copyright (C) 2009 Hans Baier <hansfbaier@googlemail.com>
6 * Copyright (C) 2014-2016 Robin Gareus <robin@gareus.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef __ardour_rt_midi_buffer_h__
24 #define __ardour_rt_midi_buffer_h__
28 #include <glibmm/threads.h>
30 #include "evoral/Event.hpp"
31 #include "evoral/EventSink.hpp"
32 #include "ardour/types.h"
37 class MidiStateTracker;
40 class LIBARDOUR_API RTMidiBuffer : public Evoral::EventSink<samplepos_t>
43 typedef samplepos_t TimeType;
45 RTMidiBuffer (size_t capacity);
50 size_t size() const { return _size; }
52 uint32_t write (TimeType time, Evoral::EventType type, uint32_t size, const uint8_t* buf);
53 uint32_t read (MidiBuffer& dst, samplepos_t start, samplepos_t end, MidiStateTracker& tracker, samplecnt_t offset = 0);
58 samplepos_t timestamp;
72 /* The main store. Holds Items (timestamp+up to 3 bytes of data OR
73 * offset into secondary storage below)
80 /* secondary blob storage. Holds Blobs (arbitrary size + data) */
82 uint32_t alloc_blob (uint32_t size);
83 uint32_t store_blob (uint32_t size, uint8_t const * data);
85 uint32_t _pool_capacity;
88 mutable Glib::Threads::RWLock _lock;
93 #endif // __ardour_rt_midi_buffer_h__