initial fixes to get build to work without new JACK MIDI, and to get it running with...
[ardour.git] / libs / midi++2 / midi++ / jackcompat.h
1 /* JACK MIDI API compatibility hacks.
2  * Copyright (C) 2007 Nedko Arnaudov <nedko@arnaudov.name>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17
18 #ifndef JACK_COMPAT_H
19 #define JACK_COMPAT_H
20
21 #define JACK_MIDI_NEEDS_NFRAMES
22
23 #if defined(JACK_MIDI_NEEDS_NFRAMES)
24
25 static jack_nframes_t
26 jack_midi_get_event_count_compat(
27   void * port_buffer)
28 {
29 #if defined(HAVE_OLD_JACK_MIDI)
30   return jack_midi_port_get_info(port_buffer, 0)->event_count;
31 #else
32   return jack_midi_get_event_count(port_buffer, 0);
33 #endif
34 }
35
36 #define jack_midi_get_event_count jack_midi_get_event_count_compat
37
38 static int
39 jack_midi_event_get_compat(
40   jack_midi_event_t * event,
41   void * port_buffer,
42   jack_nframes_t event_index)
43 {
44   return jack_midi_event_get(event, port_buffer, event_index, 0);
45 }
46
47 static int
48 jack_midi_event_write_compat(void                   *port_buffer,
49                              jack_nframes_t          time,
50                              const jack_midi_data_t *data,
51                              size_t                  data_size)
52 {
53         return jack_midi_event_write (port_buffer, time, data, data_size, 0);
54 }
55
56 static void 
57 jack_midi_clear_buffer_compat(void* buf)
58 {
59         jack_midi_clear_buffer (buf, 0);
60 }
61
62 #define jack_midi_event_get jack_midi_event_get_compat
63 #define jack_midi_event_write jack_midi_event_write_compat
64 #define jack_midi_clear_buffer jack_midi_clear_buffer_compat
65
66 #else
67
68 #if defined(HAVE_OLD_JACK_MIDI)
69 #error "Old (0.102.20) JACK MIDI API needs nframes (autotools probably gone mad)"
70 #endif
71
72 #endif  /* #if defined(JACK_MIDI_NEEDS_NFRAMES) */
73
74 #endif /* JACK_COMPAT_H */