Home » Questions » What happens when a codec is used to create a sound?

0

0

I’m trying to use FMOD_System_CreateCodec to register my own codec. The open callback is getting called, it sets numsubsounds, waveformat and so on, returns FMOD_OK, and I’ve verified that the SoundCreate callback gets called aswell (it just prints a message confirming it got called and returns FMOD_OK) – but then, mysteriously, FMOD_SoundCreate still fails with FMOD_ERR_FORMAT. What can cause that to happen?

I think I just discovered what it was – I went back to the rawcodec example and changing FMOD_TIMEUNIT_PCMBYTES to FMOD_TIMEUNIT_MODORDER as the time unit to support in the codec description (as I had done in my own one) causes the same thing. Is this expected? I assumed that the time units to support were kinda arbitrary, in what way are they used internally?

I have another question now (sorry for being impatient :D). If I have a codec that decodes sound of no known length, but it CAN terminate (reach a point at which it knows it will just generate silence forever), what is the correct way to tell FMOD of this in the read callback? I tried returning FMOD_ERR_FILE_EOF, which does seem to stop the callback from being called again, but the channel keeps on playing and needs to get explicitly stopped.