Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

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

Closed
sunnystormy opened this issue Sep 29, 2016 · 2 comments

Comments

@sunnystormy
Copy link

sunnystormy commented Sep 29, 2016

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!

@jpernst
Copy link
Owner

jpernst commented Sep 29, 2016

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.

@jpernst jpernst closed this as completed Sep 29, 2016
@sunnystormy
Copy link
Author

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!

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

No branches or pull requests

2 participants