Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capi using cargo c #50

Merged
merged 3 commits into from Jun 30, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

wip: Draft C-API

  • Loading branch information...
lu-zero committed Jun 23, 2019
commit 557cb4ce35beedf6d6bfaa481f29936094a71669
@@ -6,7 +6,7 @@
// at your option. Please see the LICENSE file
// attached to this source distribution for details.

#![forbid(unsafe_code)]
#![cfg_attr(not(cargo_c), forbid(unsafe_code))]
#![cfg_attr(test, deny(warnings))]

/*!
@@ -250,3 +250,76 @@ fn print_f64_slice(arr :&[f64]) {
de => panic!("impossible value {}", de),
}
}

#[cfg(cargo_c)]
pub mod capi {
use std::os::raw::c_int;

/// Main Decoder State
///
/// It is created by `lewton_context_from_extradata` by passing a xiph-laced extradate bundle
pub struct LewtonContext {

}

/// A multichannel vector of samples
///
/// It is produced by `lewton_decode_packet`
///
/// Use `lewton_samples_count` to retrieve the number of samples available in each channel
/// Use `lewton_samples_channels` to retrieve the number of channels
/// Use `lewton_samples_for_channel_f32` to retrieve a reference to the data present in the
/// channel
///
/// use `lewton_samples_drop()` to deallocate the memory
pub struct LewtonSamples {

}

/// Create a LewtonContext from an extradata buffer
///
/// Returns either NULL or a newly allocated LewtonContext
#[no_mangle]
pub unsafe extern "C" fn lewton_context_from_extradata(data: *const u8, len: usize) -> *mut LewtonContext {
unimplemented!()
}

/// Reset the Decoder to support seeking.
#[no_mangle]
pub unsafe extern "C" fn lewton_context_reset(ctx: *mut LewtonContext) {
unimplemented!()
}

/// Decode a packet to LewtonSamples when possible
///
/// Returns 0 on success, non-zero if no samples can be produced
#[no_mangle]
pub unsafe extern "C" fn lewton_decode_packet(ctx: *mut LewtonContext,
pkt: *const u8, len: usize, sample_out: *mut *mut LewtonSamples) -> c_int {
unimplemented!()
}

/// Provide the number of samples present in each channel
#[no_mangle]
pub unsafe extern "C" fn lewton_samples_count(ctx: *const LewtonSamples) -> usize {
unimplemented!()
}

/// Provide a reference to the channel sample data
pub unsafe extern "C" fn lewton_samples_f32(samples: *mut LewtonSamples, channel: usize) -> *const f32 {
unimplemented!()
}

#[no_mangle]
pub unsafe extern "C" fn lewton_samples_drop(samples: *mut *mut LewtonSamples) {
unimplemented!()
}

#[no_mangle]
pub unsafe extern "C" fn lewton_context_drop(ctx: *mut *mut LewtonContext) {
unimplemented!()
}
}

#[cfg(cargo_c)]
pub use capi::*;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.