createSound() crashing on createSoundInternal()

Hey guys,
I’m getting a crash attempting to create a sound with in-memory data:

FMOD_CREATESOUNDEXINFO createSoundEXInfo;
memset(&createSoundEXInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createSoundEXInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
createSoundEXInfo.length = uiSampleLen - uiOffset;
createSoundEXInfo.numchannels = 1;
createSoundEXInfo.defaultfrequency = 11025;
createSoundEXInfo.format = FMOD_SOUND_FORMAT_PCM8;
createSoundEXInfo.suggestedsoundtype = FMOD_SOUND_TYPE_RAW;
const char *pSoundData = (const char *)(ptr + uiOffset);
int iFlags = FMOD_2D | FMOD_OPENMEMORY;
if (bLoop)
{
    iFlags |= FMOD_LOOP_NORMAL;
}
FMOD_RESULT result = mp_pFMODStudioCoreSystem->createSound(pOffsetSoundData, iFlags, &createSoundEXInfo, &mp_pSound);

Am I missing parameters to the FMOD_CREATESOUNDEXINFO structure? The sound data is correct 8-bit PCM, mono 11.025 kHz data, etc.

Call stack (probably not helpful):

FMOD::SystemI::createSoundInternal (0x8190ACC)
FMOD::SystemI::createSound (0x810BEF8)
FMOD::System::createSound (0x8105798)

It’s corrupting the stack.
Here’s the logged output:

[LOG] SystemI::createSoundInternal             : Create data=0x20944f7388, mode=0x00000808
[LOG] SystemI::createSoundInternal             : exinfo->cbsize             = 224
[LOG] SystemI::createSoundInternal             : exinfo->length             = 41154
[LOG] SystemI::createSoundInternal             : exinfo->numchannels        = 1
[LOG] SystemI::createSoundInternal             : exinfo->defaultfrequency   = 11025
[LOG] SystemI::createSoundInternal             : exinfo->format             = 1
[LOG] SystemI::createSoundInternal             : exinfo->suggestedsoundtype = 12
[ERR] CodecOggVorbis::openInternal             : failed to open as ogg
[ERR] CodecMOD::openInternal                   : 'M.K.' etc ID check failed [■■■■]
[ERR] CodecS3M::openInternal                   : 'SCRM' ID check failed [■■■■]
[ERR] CodecXM::openInternal                    : 'Extended Module: ' ID check failed [■■■■]
[ERR] CodecIT::openInternal                    : 'IMPM' etc ID check failed [■■■■]
[ERR] CodecMIDI::openInternal                  : 'HThd' ID check failed [■■■■]

… it crashes here.

Shouldn’t the suggestedSoundType variable make FMOD open the data as RAW PCM data?

This is on version 0x00020011.

Matt

Instead of suggestedSoundType, try using FMOD_OPENRAW with FMOD::System::createSound().

Hey Matthew,
That totally did it :). May I ask why what I did wouldn’t work? E.g. the suggested format

Matt

Firstly, it should not crash, can you confirm whether it crashed or simply return FMOD_ERR_FORMAT?
I did a quick test using your settings and I get the error.

The reason what you did didn’t work was because suggestedSoundType is a hint for the codec scanner, however there is no way to uniquely identify RAW audio (i.e. there is no unique ID at the start of the file). So for RAW we require the createSound flag to specifically say that’s what you are providing, there is no need to set the suggestedSoundType for this case.

Hey Matt,
It was a stack corruption crash. This was on the Switch, btw. I haven’t tried PC or other consoles, but it sounds like this may be part of the detection code with my rogue FMOD_SOUND_TYPE_RAW.

Let me know if that helps at all!

Thanks again for the support!

Matt

Thanks for the details, unfortunately (fortunately?) I am unable to get it to crash with your setup (even on Switch). I can confirm the exact same exinfo parameters going on, however I get FMOD_ERR_FORMAT. If you’re willing to share the asset I could test with that too.

Hey Matt,
Could you PM offline?

Matt

Done, I’ve sent you an email.