FMOD: access violation

Started by
3 comments, last by Dave Hunt 18 years, 4 months ago
Hi, can anyone see any problems with the following code: The code converts CD TMSF position information to seconds. The code compiles cleanly. for ( count = 0; count < from.track; count++ ) { FMOD::Sound* pSound = NULL; res = pCD->getSubSound(count,&pSound); res = pSound->getLength(&ms,FMOD_TIMEUNIT_MS); seconds = ms / 1000; totalseconds += seconds; * res = pSound->release(); } tmpseconds = from.seconds; from.seconds = totalseconds + tmpseconds; I get an access violation at * , on the second iteration of the loop. tHANKS Mark
Advertisement
Why are you dereferencing res on the release() call? It should just be
res = pSound->release();

(without the '*').

that asterisk was put there to mark the line that was causing the error,
which in hindsight was a misleading thing to do.

Mark.
I don't have the FMOD API in front of me, but the
pCD->getSubSound(count,&pSound);
portion looks suspect to me. You are passing the address of a pointer to the getSubSound function. Normally the only place that you see that sort of double indirection is in COM or in some call-back implementations.

It's more likely that you meant to pass in pSound itself as such:
pCD->getSubSound(count, pSound);
We are the music makers and we are the dreamers of the dreams. - WonkaAsking Smart Questions | BookPool
Quote:Original post by MarkyMark

that asterisk was put there to mark the line that was causing the error,
which in hindsight was a misleading thing to do.

Mark.


Well, that's very different, then. ;)

Is it possible that count has exceeded the actual number of subsounds? I'm not sure what getSubSound does to pSound when count is greater than the number of subsounds. It could be that it leaves it alone. In which case, you would be releasing the same sound twice. You might check the count with a call to getNumSubSounds().

@Scrime - the getSubSound call is correct. The API returns a pointer to a sound object in the specified pointer (to a pointer).

This topic is closed to new replies.

Advertisement