Sound Sync Point and callback

I’m creating a sync point on a sound

// add a sync point so we get a callback before the end
unsigned int length = 0;
result = sound->getLength(&length, FMOD_TIMEUNIT_MS);
const char *name = "sound-end";
FMOD_SYNCPOINT *syncpoint;
result = sound->addSyncPoint(length - 1, FMOD_TIMEUNIT_MS, name, &syncpoint);
if (result != FMOD_OK) {
    printf("fmod:: Error setting sound sync point because: %s\n", FMOD_ErrorString(result));
}

then setting a callback for the channel

// set the channelcontrol callback for notifications
    result = channel->setCallback(&channelControlCallback);
    if (result != FMOD_OK) {
        printf("fmod:: Error setting channel control callback because: %s - %s\n", FMOD_ErrorString(result),
             url);
    }

here’s the callback

FMOD_RESULT F_CALLBACK channelControlCallback(FMOD_CHANNELCONTROL *channelcontrol, FMOD_CHANNELCONTROL_TYPE controltype, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype, void *commanddata1, void *commanddata2) {

if (controltype == FMOD_CHANNELCONTROL_CHANNEL && callbacktype == FMOD_CHANNELCONTROL_CALLBACK_END) {
    FMOD::Channel *channel = reinterpret_cast<FMOD::Channel *>(channelcontrol);
    echoes_sound_data *userdata;
    FMOD_RESULT result;
    result = channel->getUserData((void **)&userdata);
    if (result != FMOD_OK) {
        printf("fmod:: Error getting userdata in callback because: %s\n", FMOD_ErrorString(result));
        return FMOD_OK;
    }
    if (userdata != nullptr) {
        playerDidEnd(userdata->context);
    }
}

if (controltype == FMOD_CHANNELCONTROL_CHANNEL && callbacktype == FMOD_CHANNELCONTROL_CALLBACK_SYNCPOINT) {
    FMOD::Channel *channel = reinterpret_cast<FMOD::Channel *>(channelcontrol);
    echoes_sound_data *userdata;
    FMOD_RESULT result;
    result = channel->getUserData((void **)&userdata);
    int sync_point_index = *((int *)commanddata1);
    if (result != FMOD_OK) {
        printf("fmod:: Error getting userdata in callback because: %s\n", FMOD_ErrorString(result));
        return FMOD_OK;
    }
    if (userdata != nullptr) {
        playerDidEnd(userdata->context);
    }
}

return FMOD_OK;
}

The sounds plays fine, however, the callback gets called with FMOD_CHANNELCONTROL_CALLBACK_END immediately, but never at the end of the sound. The FMOD_CHANNELCONTROL_CALLBACK_SYNCPOINT never gets called.

I’m sure it’s something obvious I’m missing, but I can’t see it. Any help would be greatly appreciated!

That all seems fine to me, I pasted this into our play_sound example with a few modifications to remove your userdata and it worked fine. Perhaps try the same on your end?

Oh! So I did set it up correctly… I will see if I can reproduce your play_sound example test. Thanks! I’ll come back if I figure it out.