On 25 November 2013 21:53, Sean P. DeNigris <sean@clipperadams.com> wrote:
Sean P. DeNigris wrote
> I'm wrapping the FMOD cross-platform audio library
> [snip]
> I have a few more questions

========
Problem #1:
========

I have the following callout:
�� �� �� �� <primitive: #primitiveNativeCall module: #NativeBoostPlugin>

�� �� �� �� "FMOD_RESULT FMOD_System_Init(
�� �� �� �� �� �� �� �� FMOD_SYSTEM *system,
�� �� �� �� �� �� �� �� int maxchannels,
�� �� �� �� �� �� �� �� FMOD_INITFLAGS flags,
�� �� �� �� �� �� �� �� void *extradriverdata);"

�� �� �� �� ^ self nbCall: #(FMOD_RESULT System_Init(NBExternalAddress system, 32, 0,
nil)).

It works fine on Mac. On Windows, it returns some crazy error code that is
not listed in the API.

However, if I wrap the FMOD DLL in another DLL that just forwards all calls:
�� FMOD_RESULT System_Init(FMOD_SYSTEM *system, int maxchannels,
FMOD_INITFLAGS flags, void *extradriverdata)
�� {
�� �� �� �� return FMOD_System_Init(system, maxchannels, flags, extradriverdata);
�� }
When I call out to the wrapper DLL, it works! Does that provide a clue as to
what's going wrong when calling from NB?

��
This seems like a calling convention issue. By default, unless you specify, NB using
cdecl calling convention, but on windows, many libs (especially kernel) using stdcall convention.
Check how the library is built and which call convention it uses.
Or just try changing it and see if it solves the problem.
��
Other info:
- Other dll functions succeed, so there is communication with the library.
In fact, if I proceed past that first error, a sound starts to play... but
then the VM crashes...

========
Problem #2:
========
(much less important)

I wanted to be able to bundle the DLL with the image so one doesn't have to
copy it into the VM folder. If I use the full path for the wrapper DLL
described above, it is found, but when it calls fmodL.dll, which is in the
same directory, it can't be found. I could only get it to work if at least
fmodL.dll is in the VM plugins folder. Is there a way to specify more search
locations for dynamic libraries from the image side?

No, you can do it yourself in a form of:
��self nbCall: ... module: (self searchAndLoadLibrary)


Thanks!



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/NativeBoost-Questions-while-wrapping-FMOD-tp4724116p4725188.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Best regards,
Igor Stasenko.