Playing 3D sounds in 2.1 crashes

I tried upgrading FMod from version 1.10 to 2.1. Normal sounds work find, however playing any 3D sounds causes an immediate crash. This is the code I use

Blockquote
FMOD_RESULT result;
if (type == normal3D || !IsPlaying())
{
result = FMOD_System_PlaySound(
m_pSoundManager->m_pSystem, m_pFModSound, 0, true, &m_pChannel);
paused = true;
if (result != FMOD_OK)
{
throw RacException(“FMOD System_PlaySound error:”, FMOD_ErrorString(result));
}
result = FMOD_Channel_Set3DMinMaxDistance(m_pChannel, minDist, 10000.0f);
racAssert(result == FMOD_OK);
}
racAssert(m_pChannel != NULL);
FMOD_VECTOR fmPos;
fmPos.x = x;
fmPos.y = z;
fmPos.z = -y;
result = FMOD_Channel_Set3DAttributes(m_pChannel, &fmPos, &fmVelocity);
racAssert(result == FMOD_OK);
if (paused)
{
result = FMOD_Channel_SetPaused(m_pChannel, false);
racAssert(result == FMOD_OK);
}
The crash comes after FMOD_Channel_SetPaused, “Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call”

This code worked fine in version 1.10

Also, I notice that FMOD_Channel_Set3DAttributes has changed in new version, previously it had 4 parameters

1 Like

I have been looking at this a bit more and see that it’s the FMOD_Channel_Set3DAttributes function that causes the crash. If I remove that call then eveything works fine.

Hi, I wonder which compiler you are using? That type of error is usually a marshalling or calling convention issue, it may be to do with a wrapper for a non MS compiler that hasnt been adjusted for the parameter list change.

Just checking up on this with a new theory, because i’ve scanned all our files and there are no set3DAttributes mixups with 3 or 4 parameters, everything looks correct.

I’m leaning towards you have a mixed fmod header with a different version of the fmod binary/dll. Have you made sure you have fully upgraded fmod and there are no old files being included?

You can also call System_GetVersion at runtime to double check against FMOD_VERSION in the fmod header file.

I use both visual studio and GCC. Using the GCC version does not cause any problems and FMOD_Channel_Set3DAttributes has 4 parameters, back the way it used to be.
The problem is only when I build with visual studio.
System_GetVersion returns 131330 for the visual studio version and 69648 for GCC version

I just realised that I forgot to copy the new fmod.dll to exe directory and that’s what was causing the crash.

ok, you mentioned 2 version numbers, so there was obviously a clash of dlls somewhere. 69648 = 0x11010 = 1.10.10 and 131330 = 0x20102 = 2.01.02

Yes, the GCC was linked to an older version. That was my mistake, sorry. Thanks for the help anyways.