1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! The C surface over Bela's `Midi` class.
//!
//! Unlike the rest of this crate, these declarations are not generated:
//! the C they describe is `shim/midi.h` in this crate, compiled by
//! `build.rs` and linked into device binaries alongside
//! `libbelaextra`. That header is the contract, this module mirrors it
//! by hand, and the two have to be edited together.
//!
//! Bela ships a C surface of its own in `libraries/Midi/Midi_c.h`,
//! which the shim replaces rather than extends; `docs/midi.md` in the
//! repository records why, along with what the class does on the audio
//! thread and what it does not report.
//!
//! Off the device target the shim is not compiled, so these symbols do
//! not resolve. Declaring them anyway keeps the module compiling
//! everywhere the rest of the crate does.
//!
//! Every function takes a `midi` from [`bela_midi_new`] that has not
//! been deleted, and a non-null `port` or `buf` where it takes one.
//! Nothing checks; [`bela_midi_delete`] is the one that also accepts
//! null.
use ;
use ;
/// An opened `Midi` object, as an opaque pointee.
///
/// Deliberately not a description of the C++ class: nothing on this
/// side may depend on its layout, and the shim is what allocates it.
///
/// The marker is what the nomicon asks of an opaque type: a bare
/// zero-length array would make this `Send`, `Sync` and `Unpin`, and
/// the object behind it is none of those — it owns a thread that reads
/// the port, and its address is in the C++ object's own members.
/// Bytes of the longest message [`bela_midi_get_message`] writes: a
/// status byte and two data bytes.
pub const BELA_MIDI_MESSAGE_MAX: usize = 3;
/// No port has the name that was given.
///
/// The names are [`bela_midi_list_ports`]'s, which carry the
/// subdevice. Far outside the `errno` range on purpose: `-1` would be
/// this and `EPERM` at once.
pub const BELA_MIDI_NO_SUCH_PORT: c_int = -1000;
/// That direction of this object is already open.
///
/// Bela's `inputEnabled` and `outputEnabled` are set once and never
/// cleared, so a second open cannot be judged by them; it is refused
/// rather than allowed to leak an ALSA handle and start a second
/// reader thread.
pub const BELA_MIDI_ALREADY_OPEN: c_int = -1001;
unsafe extern "C"