0
0

Hello, I’m attempting to trigger a callback off a syncpoint set up in a sound. I’m using the C API, but C++ for the rest of the application. I’m using MinGW+gcc as my dev environment. My sound load looks like this:

[code:1rmhz8z9]
FMOD_SOUND* snd;
FMOD_RESULT result = FMOD_System_CreateStream(system, filename, FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &snd);
FMOD_SYNCPOINT* sync_pt;
FMOD_Sound_AddSyncPoint(snd, 0, FMOD_TIMEUNIT_MS, "beat0", &sync_pt);
[/code:1rmhz8z9]

Later in the code (same thread) I play the sound and attempt to attach the callback this way:
[code:1rmhz8z9]
FMOD_RESULT result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, snd, false, &channel);
ERRCHECK(result);
result = FMOD_Channel_SetCallback(channel, myCallback);
ERRCHECK(result);
[/code:1rmhz8z9]

My callback code is from the documentation sample, just set up as debug for now

[code:1rmhz8z9]
FMOD_RESULT F_CALLBACK myCallback(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2)
{
if (type == FMOD_CHANNEL_CALLBACKTYPE_SYNCPOINT) {
printf("SYNC\n");
}
}
[/code:1rmhz8z9]

The result of the System_PlaySound is FMOD_OK, however the ERRCHECK print from the SetCallback is
"FMOD error! (36) An invalid object handle was used. "

I’m quite stumped by this, since both the channel and the callback seem valid. Maybe I’m misunderstanding the time at which to setup the callback? Any input appreciated.

Thanks,
Anton

  • You must to post comments
0
0

Yeah, you always have to check those FMOD_RESULTs. I’m glad to hear you got it working. :)

  • You must to post comments
0
0

Apologies, FMOD isn’t at fault here. I had a stale version of the library’s dll in the working directory and at some point the IDE decided to use that instead of whats in MinGW’s bin directory. Doing a proper init of the library caught the bug, as it spewed all sorts of archaic version/linker errors which made me suspect some sort of mismatch.

Quite a bang-head-on-wall experience, but that should teach me to skip proper error handling…

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.