Callback for FMOD_CHANNELCONTROL_CALLBACK_SYNCPOINT (LInux)[Ubuntu x86 64bit]

Hello,

I am playing a .wav sound with embedded markers that were created in SoundForge, and I would like to receive a callback for every time the marker is encountered.

I set up a callback for FMOD_CHANNELCONTROL_CALLBACK_SYNCPOINT (please see the code below). The callback gets triggered, however I am having two issues with it:

  1. I would like to retrieve the index of the marker. I am attempting to do so by casting void *commanddata1 to int (as suggested in the API reference - please see my code below), however I get a crash when attempting to print out the index int value.

2.From the point the callback gets triggered for the first time, it seems to be triggered continuously every frame - I was expecting it would be only triggered once when every marker is encountered?

Thank you for your help.


FMOD_RESULT F_CALLBACK AudioEngine::SoundPlayingCallback(FMOD_CHANNELCONTROL *chanControl, FMOD_CHANNELCONTROL_TYPE controlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType, void *commanddata1, void *commanddata2)
{
    //attempt to get the index of the marker
    int cindex = *((int *)commandData1);
    
    if (controlType == FMOD_CHANNELCONTROL_CHANNEL)
    {
        FMOD::Channel *channel = (FMOD::Channel *)chanControl;
        // Channel specific functions here...
        switch (callbackType)
        {
            case FMOD_CHANNELCONTROL_CALLBACK_SYNCPOINT:
                //printing out the cindex causes the crash
                cout << "channel playing syncpoint callback, index: " << cindex << endl;
                break;
            case FMOD_CHANNELCONTROL_CALLBACK_END:
                cout << "channel playing end callback" << endl;
                break;
        }
    }
    else
    {
        FMOD::ChannelGroup *group = (FMOD::ChannelGroup *)chanControl;
        // ChannelGroup specific functions here...
    }

    // ChannelControl generic functions here...
}

It should trigger once if it contains 1 sync point. I’d have to see the wav file probably to determine what is going on there.

The commandData1 doc says ‘cast to int’. You cast it to ‘int *’ and dereferenced it, you’re probably dereferencing null or 0x1 or something like that.

regards,