0
0

Hi

Trying to upgrade to 4.03.06 today (from 4.03.00), and I found that most of my sounds were all of a sudden not loading. We use a custom filesystem, and do all sound loads nonblocking. However, I was able to write this small program which demonstrates the problem we’re having. Turns out it’s related to asynch loads, rather than filesystem.

[code:4rrit8ph]static void sPlayIfPossible(FMOD::System * pSystem, FMOD::Sound * pSound, FMOD::Channel ** pChannel, const char * pszName, int nCount)
{
FMOD_OPENSTATE eState;
pSound->getOpenState(&eState, 0, 0);
if(!*pChannel && eState == FMOD_OPENSTATE_READY)
{
cout << "Playing " << pszName << " at " << nCount << endl;
pSystem->playSound(FMOD_CHANNEL_FREE, pSound, false, pChannel);
}
}

int main(int argc, char* argv[])
{
FMOD::System * pSystem = NULL;
FMOD::Sound * pSound = NULL;
FMOD::Sound * pSound2 = NULL;
FMOD::Channel * pChannel = NULL;
FMOD::Channel * pChannel2 = NULL;

FMOD::System_Create(&amp;pSystem);
pSystem-&gt;init(512, FMOD_INITFLAGS(FMOD_INIT_NORMAL | FMOD_INIT_DSOUND_HRTFFULL), NULL);

char szPath[ 128 ];
strcpy_s(szPath, 128, &quot;test.wav&quot;);
char szPath2[ 128 ];
strcpy_s(szPath2, 128, &quot;test2.wav&quot;);

int nMode = FMOD_DEFAULT | FMOD_LOOP_NORMAL | FMOD_2D | FMOD_SOFTWARE | FMOD_CREATESAMPLE | FMOD_NONBLOCKING;

FMOD_RESULT res = FMOD_OK;
res = pSystem-&gt;createSound(szPath, nMode, NULL, &amp;pSound);
res = pSystem-&gt;createSound(szPath2, nMode, NULL, &amp;pSound2);

int nCount = 0;
while(1)
{
    sPlayIfPossible(pSystem, pSound, &amp;pChannel, &quot;One&quot;, nCount);
    /*
    if(pChannel &amp;&amp; !pSound2)
    {
        res = pSystem-&gt;createSound(szPath2, nMode, NULL, &amp;pSound2);
    }
    // */
    sPlayIfPossible(pSystem, pSound2, &amp;pChannel2, &quot;Two&quot;, nCount);
    pSystem-&gt;update();
    nCount++;
}

return 0;

}
[/code:4rrit8ph]

That commented out block in the while() loop makes it “work” properly. The behavior that I’m seeing is that all loads are queued up properly, but only one load is serviced at a time. Once that load has completed, any further loads that happen AFTER it’s completed get queued up the same, but it actually causes the previously queued up loads to occur. Whew!

Confusing, but hopefully the sample program will make it clear what’s happening and you can fix it.

Thank you!

  • Guy
  • You must to post comments
0
0

Sweet, thanks!

I’ll give that a try tomorrow at work and see what happens. (Don’t have the code here on my home PC to test it out on.)

  • Guy
  • You must to post comments
0
0

Just tested it here and it seems to be working no problems. I’ll hold off on upgrading us until the official .07 build, though.

Thanks, Brett!

  • Guy
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.