electronstudio / raylib-python-cffi

Python CFFI bindings for Raylib
http://electronstudio.github.io/raylib-python-cffi
Eclipse Public License 2.0
142 stars 29 forks source link

FFI music stream mismatch between cdef and C compiler #99

Closed EzraMoore65 closed 1 year ago

EzraMoore65 commented 1 year ago

When loading a music stream using pyray, an error occurs with the following output

pyray.load_music_stream(filepath)

for (c_arg, arg) in zip(ffi.typeof(a).args, args): ffi.error: struct Music: wrong size for field 'looping' (cdef says 4, but C compiler says 1). fix it or use "...;" as the last field in the cdef for struct Music to make it flexible

I compared this to the following issue, but the issue listed in that ticket seems to be related to linux as a system issue, whereas I am using windows and not able to replicate the issue in C, C#, lua, or Go. I've ensure that init_audio_device has been called and that the music stream is not being loaded until after the audio device has been initialized. After asking the raylib discord they recommended that an issue be made. Several different filetypes were experimented with include mp3, ogg, and wav, all of which produce the same error.

System info if it helps:

electronstudio commented 1 year ago

The Windows C compiler doen't have a proper boolean type, it uses ints instead, which confuses CFFI. To work around this, I replaced all the bools with ints. Now it seems if the compiler might have been fixed, and is producing proper booleans. I will try removing the workaround.

electronstudio commented 1 year ago

That seems to have fixed it. Update to raylib==4.2.1.2

EzraMoore65 commented 1 year ago

Yes, just tested and the issue is resolved. Thanks for your help and quick response time.