• Advertisement
Sign in to follow this  

FMOD: access violation

This topic is 4465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Why are you dereferencing res on the release() call? It should just be

res = pSound->release();

(without the '*').

Share this post


Link to post
Share on other sites

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

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
Sign in to follow this  

  • Advertisement