On 21 November 2013 22:40, Sean P. DeNigris <sean@clipperadams.com> wrote:
I'm wrapping the FMOD cross-platform audio library. The code is MIT and lives at http://smalltalkhub.com/#!/~SeanDeNigris/FMOD
======== Problem #1: ========
I'm calling into the FMOD library with: primStoreIsPlaying: channelHandle in: isPlayingHandle <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
"FMOD_RESULT FMOD_Channel_IsPlaying( FMOD_CHANNEL *channel, bool *isplaying);"
^ self nbCall: #(FMOD_RESULT FMOD_Channel_IsPlaying(NBExternalAddress channel, NBExternalAddress isPlayingHandle)).
I call the above with: isPlaying | isPlaying | isPlaying := NBExternalAddress new. self primStoreIsPlaying: channel in: isPlaying. ^ isPlaying value > 0.
isPlaying is always 0. The method works directly from C with: int isPlaying = 1; while (isPlaying) { FMOD_Channel_IsPlaying(channel, &isPlaying); }
I also tried changing the callout signature to "... bool* isPlayingHandle)" and passing "isPlaying := true." instead of using the NBExternalAddress stuff.
err.. again, you must pass an address where value will be stored,
^ self nbCall: #(FMOD_RESULT FMOD_Channel_IsPlaying(
NBExternalAddress channel, NBExternalAddress * isPlayingHandle)).
otherwise you passing NULL pointer, and i quite surprised it not segfaults when you call it like that (looks like they have a check in the library ) you can also use NBExternalTypeValue for that: boolValueClass := NBExternalTypeValue ofType: 'bool'. "sure thing, creating anonymous class for each call is overkill, this should be done once, somewhere else" boolValue := boolValueClass new. self callTheThingWith: boolValue. boolValue value ifTrue: [... blah] (and this will work, assuming you have bool* in signature for this argument). I have a few more questions, but this is the most pressing as it's holding
up any further development.
Thanks!
----- Cheers, Sean -- View this message in context: http://forum.world.st/NativeBoost-Questions-while-wrapping-FMOD-tp4724116.ht... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
-- Best regards, Igor Stasenko.