Draft
Conversation
Contributor
|
// Disable stack checking for iOS/tvOS/visionOS targets to avoid ___chkstk_darwin dependency
// which is only available on macOS, not iOS
if target.contains("apple-ios") || target.contains("apple-tvos") || target.contains("apple-visionos") {
build.flag("-fno-stack-check");
} |
Contributor
|
Swift → Rust experiment Starting point:
Rust APIs:
pub struct AudioBufferBytes {
pub data: Vec<u8>,
}var writer = createWriter()
write(value, into: &writer)
return RustBuffer(bytes: writer) // here comes the copy
let frameCount = audioBuffer.frames
let channelBuffer = audioBuffer.rawBuffer(forChannel: 0)
// Arithmetics...
try resampler.pushFromPtr(dataPtr: UInt64(bitPattern: Int64(Int(bitPattern: channelBuffer))), len: UInt32(frameCount * MemoryLayout<Float>.size))Conclusion: it boils down to using #[derive(uniffi::Record)]
pub struct AudioBuffer {
/// Pointer value as u64 (points to Float32 data in Swift memory)
pub pointer: u64,
/// Length in bytes
pub len: u32,
}
impl AudioBuffer {
/// Get the pointer as *const u8
pub fn as_ptr(&self) -> *const u8 {
self.pointer as *const u8
}
/// Get length in bytes
pub fn byte_len(&self) -> usize {
self.len as usize
}
} |
Contributor
|
Rust → Swift experiment I think the assumption is that we #[uniffi::export]
pub fn free_rust_audio_buffer(buffer: RustAudioBuffer) {
unsafe {
if buffer.pointer != 0 {
let capacity = buffer.sample_capacity();
let len = buffer.sample_len();
let ptr = buffer.pointer as *mut i16;
let _ = Vec::from_raw_parts(ptr, len, capacity);
}
}
} |
Makes clear what comes from uniffi
Allows client to access the version specified in Cargo.toml
Expose high-level interface for audio resampling powered by soxr-sys.
afb7041 to
59f37df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.