nandi/jolt-nativepublic Fork 0
fa4ecdfed6a830e6099d5fab9be24ef72ea1923b
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

asio_stub_bindings.rs · 205 lines · 4.6 KBRust Blame HistoryRaw
Lift freeq's AV media plane out of sleek 90f8b89 nandi 19d ago1// Stub bindings for docs.rs
2// These are minimal type and function definitions to allow documentation generation
3// without requiring the actual ASIO SDK.
4
5use std::os::raw::{c_char, c_double, c_void};
6
7// On Windows (the only platform where ASIO actually runs), c_long is i32.
8// On non-Windows platforms (for docs.rs and local testing), redefine c_long as i32 to match.
9#[cfg(target_os = "windows")]
10use std::os::raw::c_long;
11#[cfg(not(target_os = "windows"))]
12type c_long = i32;
13
14pub type ASIOBool = c_long;
15pub type ASIOError = c_long;
16pub type ASIOSampleRate = c_double;
17
18#[repr(C)]
19#[derive(Debug, Copy, Clone)]
20pub struct ASIOSamples {
21 pub hi: u32,
22 pub lo: u32,
23}
24
25#[repr(C)]
26#[derive(Debug, Copy, Clone)]
27pub struct ASIOTimeStamp {
28 pub hi: u32,
29 pub lo: u32,
30}
31
32#[repr(C)]
33#[derive(Debug, Copy, Clone)]
34pub struct ASIODriverInfo {
35 pub asioVersion: c_long,
36 pub driverVersion: c_long,
37 pub name: [c_char; 32],
38 pub errorMessage: [c_char; 124],
39 pub sysRef: *mut c_void,
40}
41
42#[repr(C)]
43#[derive(Debug, Copy, Clone)]
44pub struct ASIOChannelInfo {
45 pub channel: c_long,
46 pub isInput: ASIOBool,
47 pub isActive: ASIOBool,
48 pub channelGroup: c_long,
49 pub type_: c_long,
50 pub name: [c_char; 32],
51}
52
53#[repr(C)]
54#[derive(Debug, Copy, Clone)]
55pub struct ASIOBufferInfo {
56 pub isInput: ASIOBool,
57 pub channelNum: c_long,
58 pub buffers: [*mut c_void; 2],
59}
60
61#[repr(C)]
62#[derive(Debug, Copy, Clone)]
63pub struct ASIOCallbacks {
64 pub bufferSwitch: *const c_void,
65 pub sampleRateDidChange: *const c_void,
66 pub asioMessage: *const c_void,
67 pub bufferSwitchTimeInfo: *const c_void,
68}
69
70#[repr(C)]
71#[derive(Debug, Copy, Clone)]
72pub struct AsioTimeInfo {
73 pub speed: c_double,
74 pub systemTime: ASIOTimeStamp,
75 pub samplePosition: ASIOSamples,
76 pub sampleRate: ASIOSampleRate,
77 pub flags: c_long,
78 pub reserved: [c_char; 12],
79}
80
81#[repr(C)]
82#[derive(Debug, Copy, Clone)]
83pub struct ASIOTimeCode {
84 pub speed: c_double,
85 pub timeCodeSamples: ASIOSamples,
86 pub flags: c_long,
87 pub future: [c_char; 64],
88}
89
90#[repr(C)]
91#[derive(Debug, Copy, Clone)]
92pub struct ASIOTime {
93 pub reserved: [c_long; 4],
94 pub timeInfo: AsioTimeInfo,
95 pub timeCode: ASIOTimeCode,
96}
97
98#[repr(transparent)]
99#[derive(Debug, Copy, Clone)]
100pub struct AsioTimeInfoFlags(pub u32);
101
102impl AsioTimeInfoFlags {
103 pub const kSystemTimeValid: Self = Self(1);
104 pub const kSamplePositionValid: Self = Self(1 << 1);
105}
106
107impl std::ops::BitOr for AsioTimeInfoFlags {
108 type Output = Self;
109 fn bitor(self, rhs: Self) -> Self {
110 Self(self.0 | rhs.0)
111 }
112}
113
114#[repr(transparent)]
115#[derive(Debug, Copy, Clone)]
116pub struct ASIOTimeCodeFlags(pub u32);
117
118// Stub functions (will never be called on docs.rs)
119#[no_mangle]
120pub unsafe extern "C" fn ASIOInit(_info: *mut ASIODriverInfo) -> ASIOError {
121 0
122}
123#[no_mangle]
124pub unsafe extern "C" fn ASIOExit() -> ASIOError {
125 0
126}
127#[no_mangle]
128pub unsafe extern "C" fn ASIOStart() -> ASIOError {
129 0
130}
131#[no_mangle]
132pub unsafe extern "C" fn ASIOStop() -> ASIOError {
133 0
134}
135#[no_mangle]
136pub unsafe extern "C" fn ASIOGetChannels(_ins: *mut c_long, _outs: *mut c_long) -> ASIOError {
137 0
138}
139#[no_mangle]
140pub unsafe extern "C" fn ASIOGetLatencies(
141 _in_latency: *mut c_long,
142 _out_latency: *mut c_long,
143) -> ASIOError {
144 0
145}
146#[no_mangle]
147pub unsafe extern "C" fn ASIOGetChannelInfo(_info: *mut ASIOChannelInfo) -> ASIOError {
148 0
149}
150#[no_mangle]
151pub unsafe extern "C" fn ASIOCreateBuffers(
152 _infos: *mut ASIOBufferInfo,
153 _num: c_long,
154 _size: c_long,
155 _callbacks: *mut ASIOCallbacks,
156) -> ASIOError {
157 0
158}
159#[no_mangle]
160pub unsafe extern "C" fn ASIODisposeBuffers() -> ASIOError {
161 0
162}
163#[no_mangle]
164pub unsafe extern "C" fn ASIOGetBufferSize(
165 _min: *mut c_long,
166 _max: *mut c_long,
167 _pref: *mut c_long,
168 _gran: *mut c_long,
169) -> ASIOError {
170 0
171}
172#[no_mangle]
173pub unsafe extern "C" fn ASIOGetSamplePosition(
174 _pos: *mut ASIOSamples,
175 _stamp: *mut ASIOTimeStamp,
176) -> ASIOError {
177 0
178}
179#[no_mangle]
180pub unsafe extern "C" fn ASIOOutputReady() -> ASIOError {
181 0
182}
183
184#[no_mangle]
185pub unsafe extern "C" fn get_driver_names(_names: *mut *mut c_char, _max: c_long) -> c_long {
186 0
187}
188#[no_mangle]
189pub unsafe extern "C" fn load_asio_driver(_name: *mut c_char) -> bool {
190 false
191}
192#[no_mangle]
193pub unsafe extern "C" fn remove_current_driver() {}
194#[no_mangle]
195pub unsafe extern "C" fn get_sample_rate(_rate: *mut c_double) -> ASIOError {
196 0
197}
198#[no_mangle]
199pub unsafe extern "C" fn set_sample_rate(_rate: c_double) -> ASIOError {
200 0
201}
202#[no_mangle]
203pub unsafe extern "C" fn can_sample_rate(_rate: c_double) -> ASIOError {
204 0
205}