Sign in to follow this  
MarkyMark

FMOD: access violation

Recommended Posts

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

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this