jpernst / alto

Idiomatic Rust bindings for OpenAL 1.1 and extensions (including EFX).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FFI needs to be updated to allow the correct types to be passed into methods.

sunnystormy opened this issue · comments

I've updated my code to reflect the changes in this repo. If you look at the types of data I'm passing into the ffi, you'll see that it doesn't match.

I glanced at my C++ code to verify that I was passing the right data into the methods, and everything looks right. There may still #need to be some kinks worked out in the ffi before it becomes fully functional.

Look at my audionode-rs repo to see my updates and compare.

Thank you!

Here are the issues I've found in your lib:

  • You can't pass a rust string to a C api, you'll need to use the CString suite from the stdlib
  • al devices and contexts are pointers to opaque types. You can never have a naked ALCDevice, it will always be behind a pointer, so just store the pointer.
  • You attempt to pass 0 where a pointer is expected. Rust does not support implicit conversions of that kind, so you'll need to ust std::ptr::null()
  • A rust reference also does not implicitly convert to a pointer, you'll need to cast it.
  • Your data and format args are reversed for alBufferData
  • When attempting to pass arrays to the FFI functions, you'll need to pass their address, not the array itself

Double checking with the openal guide, the ffi bindings appear to be correct.

Good to know. I'll comb over everything again and make sure the right changes are implemented. I suppose there's still a bit of a learning curve for me switching over to the "Rust" way. Thanks again for all of your help!