| Lift freeq's AV media plane out of sleek 90f8b89 nandi 19d ago | 1 | // 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 | |
| 5 | use 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")] |
| 10 | use std::os::raw::c_long; |
| 11 | #[cfg(not(target_os = "windows"))] |
| 12 | type c_long = i32; |
| 13 | |
| 14 | pub type ASIOBool = c_long; |
| 15 | pub type ASIOError = c_long; |
| 16 | pub type ASIOSampleRate = c_double; |
| 17 | |
| 18 | #[repr(C)] |
| 19 | #[derive(Debug, Copy, Clone)] |
| 20 | pub struct ASIOSamples { |
| 21 | pub hi: u32, |
| 22 | pub lo: u32, |
| 23 | } |
| 24 | |
| 25 | #[repr(C)] |
| 26 | #[derive(Debug, Copy, Clone)] |
| 27 | pub struct ASIOTimeStamp { |
| 28 | pub hi: u32, |
| 29 | pub lo: u32, |
| 30 | } |
| 31 | |
| 32 | #[repr(C)] |
| 33 | #[derive(Debug, Copy, Clone)] |
| 34 | pub 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)] |
| 44 | pub 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)] |
| 55 | pub 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)] |
| 63 | pub 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)] |
| 72 | pub 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)] |
| 83 | pub 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)] |
| 92 | pub 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)] |
| 100 | pub struct AsioTimeInfoFlags(pub u32); |
| 101 | |
| 102 | impl AsioTimeInfoFlags { |
| 103 | pub const kSystemTimeValid: Self = Self(1); |
| 104 | pub const kSamplePositionValid: Self = Self(1 << 1); |
| 105 | } |
| 106 | |
| 107 | impl 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)] |
| 116 | pub struct ASIOTimeCodeFlags(pub u32); |
| 117 | |
| 118 | // Stub functions (will never be called on docs.rs) |
| 119 | #[no_mangle] |
| 120 | pub unsafe extern "C" fn ASIOInit(_info: *mut ASIODriverInfo) -> ASIOError { |
| 121 | 0 |
| 122 | } |
| 123 | #[no_mangle] |
| 124 | pub unsafe extern "C" fn ASIOExit() -> ASIOError { |
| 125 | 0 |
| 126 | } |
| 127 | #[no_mangle] |
| 128 | pub unsafe extern "C" fn ASIOStart() -> ASIOError { |
| 129 | 0 |
| 130 | } |
| 131 | #[no_mangle] |
| 132 | pub unsafe extern "C" fn ASIOStop() -> ASIOError { |
| 133 | 0 |
| 134 | } |
| 135 | #[no_mangle] |
| 136 | pub unsafe extern "C" fn ASIOGetChannels(_ins: *mut c_long, _outs: *mut c_long) -> ASIOError { |
| 137 | 0 |
| 138 | } |
| 139 | #[no_mangle] |
| 140 | pub 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] |
| 147 | pub unsafe extern "C" fn ASIOGetChannelInfo(_info: *mut ASIOChannelInfo) -> ASIOError { |
| 148 | 0 |
| 149 | } |
| 150 | #[no_mangle] |
| 151 | pub 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] |
| 160 | pub unsafe extern "C" fn ASIODisposeBuffers() -> ASIOError { |
| 161 | 0 |
| 162 | } |
| 163 | #[no_mangle] |
| 164 | pub 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] |
| 173 | pub unsafe extern "C" fn ASIOGetSamplePosition( |
| 174 | _pos: *mut ASIOSamples, |
| 175 | _stamp: *mut ASIOTimeStamp, |
| 176 | ) -> ASIOError { |
| 177 | 0 |
| 178 | } |
| 179 | #[no_mangle] |
| 180 | pub unsafe extern "C" fn ASIOOutputReady() -> ASIOError { |
| 181 | 0 |
| 182 | } |
| 183 | |
| 184 | #[no_mangle] |
| 185 | pub unsafe extern "C" fn get_driver_names(_names: *mut *mut c_char, _max: c_long) -> c_long { |
| 186 | 0 |
| 187 | } |
| 188 | #[no_mangle] |
| 189 | pub unsafe extern "C" fn load_asio_driver(_name: *mut c_char) -> bool { |
| 190 | false |
| 191 | } |
| 192 | #[no_mangle] |
| 193 | pub unsafe extern "C" fn remove_current_driver() {} |
| 194 | #[no_mangle] |
| 195 | pub unsafe extern "C" fn get_sample_rate(_rate: *mut c_double) -> ASIOError { |
| 196 | 0 |
| 197 | } |
| 198 | #[no_mangle] |
| 199 | pub unsafe extern "C" fn set_sample_rate(_rate: c_double) -> ASIOError { |
| 200 | 0 |
| 201 | } |
| 202 | #[no_mangle] |
| 203 | pub unsafe extern "C" fn can_sample_rate(_rate: c_double) -> ASIOError { |
| 204 | 0 |
| 205 | } |