Hi! I would like to have a simple example code to implement syncpoints for an audio file along with setting up callbacks for the same(FMOD Core api, Android).
What I tried is,
FMOD_SYNCPOINT **point = nullptr;
result = sound->addSyncPoint(1154, FMOD_TIMEUNIT_MS, "Good", point);
ERRCHECK(result);
Until here, everything works fine and a syncpoint is created. But ,
char *name = NULL;
FMOD_SYNCPOINT **point2 = NULL;
sound->getSyncPoint(0, point2);
result = sound->getSyncPointInfo(*point2, name, 64, 0, FMOD_TIMEUNIT_MS);
this leads to app crashing.
Even setting callback like this,
result = channel->setCallback(mycallback);
ERRCHECK(result);
throws an error – an invalid object handle was used.
My callback function is as follows–
FMOD_RESULT F_CALLBACK mycallback(FMOD_CHANNELCONTROL *chanControl, FMOD_CHANNELCONTROL_TYPE controlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType, void *commandData1, void *commandData2)
{
if (controlType == FMOD_CHANNELCONTROL_CHANNEL)
{
FMOD::Channel *pChannel = (FMOD::Channel *)chanControl;
if(callbackType == FMOD_CHANNELCONTROL_CALLBACK_SYNCPOINT){
FMOD::Sound *sound;
pChannel->getCurrentSound(&sound);
}
}
else
{
FMOD::ChannelGroup *group = (FMOD::ChannelGroup *)chanControl;
// ChannelGroup specific functions here...
}
return FMOD_OK;
}
I request, to please provide me with a brief sample code to solve these errors or a brief code containing complete implementation of syncpoints along with setting a callback to a channel.
Thanx, in advance.