This commit is contained in:
2025-09-30 20:27:07 -06:00
parent f73df7e0b8
commit d8a5ab465e
13 changed files with 285 additions and 7 deletions

View File

@@ -31,6 +31,8 @@ pub enum CallAbiTable {
ListDir = 6,
ReadFile = 7,
FileLen = 8,
AudioBufferReady = 9,
SendAudioBuffer = 10,
}
pub type PrintAbi = extern "C" fn(ptr: *const u8, len: usize);
@@ -145,3 +147,27 @@ pub fn file_len(file: &str) -> usize {
f(file.as_ptr(), file.len())
}
}
pub type AudioBufferReady = extern "C" fn() -> bool;
#[allow(unused)]
pub fn audio_buffer_ready() -> bool {
unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::AudioBufferReady as usize];
let f: AudioBufferReady = core::mem::transmute(ptr);
f()
}
}
pub const AUDIO_BUFFER_LEN: usize = 1024;
pub type SendAudioBuffer = extern "C" fn(ptr: *const u8, len: usize);
#[allow(unused)]
pub fn send_audio_buffer(buf: &[u8; AUDIO_BUFFER_LEN]) {
unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::SendAudioBuffer as usize];
let f: SendAudioBuffer = core::mem::transmute(ptr);
f(buf.as_ptr(), buf.len())
}
}