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

[Do not merge] Partial work on #137. Only struct PaHostApiTypeId ported for now. #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

clicketyclack
Copy link
Contributor

Did an initial run with bindgen + ported over a small section of the resulting ffi.rs. I.e. only the (Pa)HostApiTypeId enum. Then I fixed breakage such that the devices.rs, hosts.rs and sine.rs examples seem to work.

The existing solution defines a bunch of consts in ffi.rs with a wrapping enum in types.rs. Running bindgen creates an enum right in ffi.rs, giving us two enums with basically the same members.

Since bindgen does the enum stuff, I guess we might as well drop the enum in types.rs altogether? Haven't tried doing that to see what breaks yet.

Looking at the generated .rs, naming and types change a bit. See DeviceInfo struct below. So fixing this issue will break a lot of API. Don't know if RustAudio has a policy on that.

$ diff -y ffi-regen.rs src/ffi.rs
(... snip ...)
pub type PaTime = f64;                                        |
pub type PaSampleFormat = ::std::os::raw::c_ulong;            | #[derive(Clone, Copy, Debug)]
#[repr(C)]                                                      #[repr(C)]
#[derive(Copy, Clone)]                                        | pub struct C_PaDeviceInfo {
#[derive(Debug)]                                              |     pub struct_version: i32,
pub struct PaDeviceInfo {                                     |     pub name: *const c_char,
    pub structVersion: ::std::os::raw::c_int,                 |     pub host_api: HostApiIndex,
    pub name: *const ::std::os::raw::c_char,                  |     pub max_input_channels: i32,
    pub hostApi: PaHostApiIndex,                              |     pub max_output_channels: i32,
    pub maxInputChannels: ::std::os::raw::c_int,              |     pub default_low_input_latency: Time,
    pub maxOutputChannels: ::std::os::raw::c_int,             |     pub default_low_output_latency: Time,
    pub defaultLowInputLatency: PaTime,                       |     pub default_high_input_latency: Time,
    pub defaultLowOutputLatency: PaTime,                      |     pub default_high_output_latency: Time,
    pub defaultHighInputLatency: PaTime,                      |     pub default_sample_rate: c_double
    pub defaultHighOutputLatency: PaTime,                     <
    pub defaultSampleRate: f64,                               <
}                                                             <
(... snip ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant