0
0

I’ve got an end callback that stop the current sound and restart it.

When the callback is called and re-play the stereo.ogg : this crash FMOD Ex. For lot of musics, all is going well. But for few musics (especially some ogg files), this crashing FMOD Ex.

What does I am doing wrong ?

[code:viaeebzb]
FMOD_RESULT F_CALLBACK endcallback(FMOD_CHANNEL *c, FMOD_CHANNEL_CALLBACKTYPE type, int command, unsigned int commanddata1, unsigned int commanddata2)
{
//Stop current sound
result = channel->stop();
ERRCHECK(result);
result = sound->release();
ERRCHECK(result);

//Play stereo.ogg
FMOD_RESULT result = gSystem->createStream("../media/stereo.ogg", FMOD_SOFTWARE, 0, &gSound);
ERRCHECK(result);
result = gSound->setMode(FMOD_LOOP_OFF);
ERRCHECK(result);

result = gSystem->playSound(FMOD_CHANNEL_FREE, gSound, false, &gChannel);
ERRCHECK(result);

result = gChannel->setCallback(FMOD_CHANNEL_CALLBACKTYPE_END, &endcallback, 0);
ERRCHECK(result);

return FMOD_OK;

}[/code:viaeebzb]

The full c++ test file can be found here [url:viaeebzb]http://jerome.jouvie.free.fr/downloads/endcallbacktest.cpp[/url:viaeebzb]

  • You must to post comments
0
0

the issue is that you are freeing a sound from a callback and fmod internally is still pointing to data in that sound, so move your sound release out of the callback.

  • You must to post comments
0
0

[quote="brett":1zgr08dv]the issue is that you are freeing a sound from a callback and fmod internally is still pointing to data in that sound, so move your sound release out of the callback.[/quote:1zgr08dv]
Thanks, I will try it 😀

Something remains strange, this works with the majority of musics (about 90-95%), this issue only occures with few musics (in particular, some ogg files).
Notice also that the ‘crash’ don’t occures in the callback, but at the next call of system->update (just after the callback was called).

[size=84:1zgr08dv]Note: If I remember, releasing a sound in a callback in a very old version of FMOD Ex was working fine.[/size:1zgr08dv]

  • You must to post comments
0
0

Beeing able to unload the song would be kewl… what other need would be for the callback then unloading the old song, and starting a new one.

Using the PostMessage api should be a workaround…?

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.