Per this thread, there are some discrepancies in features between the Lua and C APIs as it pertains to the audio subsystem.
There may be other cases where differences exist, but the user is particularly interested in these:
-
Lua
playdate.sound.sampleplayer:setLoopCallback()
accepts userdata arguments. - C
playdate->sound->sampleplayer->setLoopCallback()
does appear to be implemented inpd_api_sound.h
, but is not documented in Inside Playdate with C. It does not accept userdata arguments. -
Lua
playdate.sound.sampleplayer:setFinishCallback()
accepts userdata arguments. -
C
playdate->sound->sampleplayer->setFinishCallback()
does not accept userdata arguments.
Ideally, the C version of the callback functions would be changed to accept a void *context
argument like playdate->sound->addSource()
, although this comes with the caveat in that it would cause existing programs to fail to compile. This approach will keep the API from getting bloated with afterthoughts.
The bloated-afterthought alternatives include either making a setFoobarCallbackEx()
variant of each function that does accept a userdata argument, or implementing setUserData(SoundSource *, void *)
and getUserData(SoundSource *)
functions within playdate->sound
.