nandi/jolt-nativepublic Fork 0
dce285fb5a5ec1f331b8afa7b2bdc4ed5e1bbd46
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.

Build under buck2, with the toolchain pinned rather than found 460541b · on dce285fb5a5ec1f331b8afa7b2bdc4ed5e1bbd46 · nandi · 19d ago
asio_stub_bindings.rs · 205 lines · 4.6 KBRust Blame HistoryRaw
  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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Stub bindings for docs.rs
// These are minimal type and function definitions to allow documentation generation
// without requiring the actual ASIO SDK.

use std::os::raw::{c_char, c_double, c_void};

// On Windows (the only platform where ASIO actually runs), c_long is i32.
// On non-Windows platforms (for docs.rs and local testing), redefine c_long as i32 to match.
#[cfg(target_os = "windows")]
use std::os::raw::c_long;
#[cfg(not(target_os = "windows"))]
type c_long = i32;

pub type ASIOBool = c_long;
pub type ASIOError = c_long;
pub type ASIOSampleRate = c_double;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOSamples {
    pub hi: u32,
    pub lo: u32,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOTimeStamp {
    pub hi: u32,
    pub lo: u32,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIODriverInfo {
    pub asioVersion: c_long,
    pub driverVersion: c_long,
    pub name: [c_char; 32],
    pub errorMessage: [c_char; 124],
    pub sysRef: *mut c_void,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOChannelInfo {
    pub channel: c_long,
    pub isInput: ASIOBool,
    pub isActive: ASIOBool,
    pub channelGroup: c_long,
    pub type_: c_long,
    pub name: [c_char; 32],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOBufferInfo {
    pub isInput: ASIOBool,
    pub channelNum: c_long,
    pub buffers: [*mut c_void; 2],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOCallbacks {
    pub bufferSwitch: *const c_void,
    pub sampleRateDidChange: *const c_void,
    pub asioMessage: *const c_void,
    pub bufferSwitchTimeInfo: *const c_void,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct AsioTimeInfo {
    pub speed: c_double,
    pub systemTime: ASIOTimeStamp,
    pub samplePosition: ASIOSamples,
    pub sampleRate: ASIOSampleRate,
    pub flags: c_long,
    pub reserved: [c_char; 12],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOTimeCode {
    pub speed: c_double,
    pub timeCodeSamples: ASIOSamples,
    pub flags: c_long,
    pub future: [c_char; 64],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOTime {
    pub reserved: [c_long; 4],
    pub timeInfo: AsioTimeInfo,
    pub timeCode: ASIOTimeCode,
}

#[repr(transparent)]
#[derive(Debug, Copy, Clone)]
pub struct AsioTimeInfoFlags(pub u32);

impl AsioTimeInfoFlags {
    pub const kSystemTimeValid: Self = Self(1);
    pub const kSamplePositionValid: Self = Self(1 << 1);
}

impl std::ops::BitOr for AsioTimeInfoFlags {
    type Output = Self;
    fn bitor(self, rhs: Self) -> Self {
        Self(self.0 | rhs.0)
    }
}

#[repr(transparent)]
#[derive(Debug, Copy, Clone)]
pub struct ASIOTimeCodeFlags(pub u32);

// Stub functions (will never be called on docs.rs)
#[no_mangle]
pub unsafe extern "C" fn ASIOInit(_info: *mut ASIODriverInfo) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOExit() -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOStart() -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOStop() -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOGetChannels(_ins: *mut c_long, _outs: *mut c_long) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOGetLatencies(
    _in_latency: *mut c_long,
    _out_latency: *mut c_long,
) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOGetChannelInfo(_info: *mut ASIOChannelInfo) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOCreateBuffers(
    _infos: *mut ASIOBufferInfo,
    _num: c_long,
    _size: c_long,
    _callbacks: *mut ASIOCallbacks,
) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIODisposeBuffers() -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOGetBufferSize(
    _min: *mut c_long,
    _max: *mut c_long,
    _pref: *mut c_long,
    _gran: *mut c_long,
) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOGetSamplePosition(
    _pos: *mut ASIOSamples,
    _stamp: *mut ASIOTimeStamp,
) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn ASIOOutputReady() -> ASIOError {
    0
}

#[no_mangle]
pub unsafe extern "C" fn get_driver_names(_names: *mut *mut c_char, _max: c_long) -> c_long {
    0
}
#[no_mangle]
pub unsafe extern "C" fn load_asio_driver(_name: *mut c_char) -> bool {
    false
}
#[no_mangle]
pub unsafe extern "C" fn remove_current_driver() {}
#[no_mangle]
pub unsafe extern "C" fn get_sample_rate(_rate: *mut c_double) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn set_sample_rate(_rate: c_double) -> ASIOError {
    0
}
#[no_mangle]
pub unsafe extern "C" fn can_sample_rate(_rate: c_double) -> ASIOError {
    0
}