0
0

During application shutdown we first verify all streams have stopped, before shutting down FMOD. This was traditionally done to prevent a crash when FMOD shutdown (many years back), but nowadays it is probably only useful to allow streaming audio to fade out and stop gracefully before shutting down the sound system.

This is the code we use to detect if any streams are active, the problem is ‘streamsinuse’ sometimes remains at a value of 2, even though no streams are audible, and we’ve called stop on all streams (FMOD::Event objects). This is a pretty rare condition in general, but there are ways to make it 100% reproduceable.

[code:1ubx5qyu]
FMOD_EVENT_SYSTEMINFO info;
memset(&info, 0, sizeof(info));

info.maxwavebanks = MAX_WAVE_BANKS;
info.wavebankinfo = &m_waveBankInfo[0];

if (GetEventSystem().getInfo(&info) == FMOD_OK)
{
assert(info.maxwavebanks < MAX_WAVE_BANKS);
for (int i = 0; i < info.maxwavebanks; ++i )
{
const FMOD_EVENT_WAVEBANKINFO & waveBankInfo = info.wavebankinfo[i];

  if (waveBankInfo.streamsinuse &gt; 0)
  {
    return true;
  }
}

}

return false;
[/code:1ubx5qyu]

What’s more, the offending wave bank is not even a streamed wave bank, in FMOD designer it has ‘Bank Type’ set to ‘Load into Memory’. It returns a type of 0 (=stream from disk) from the getInfo method, I’m not sure why (as other in-memory banks return the correct type). The streamrefcnt is 395, with maxstreams around 15, though I’m not sure this information is of any use.

The other thing is that the instant memory wave bank has streamsinuse set to 4, while our actual streaming wave bank has streamsinuse set to 2, for a total of 6 active streams. Our game is structured to never play more than 4 streams at a time, so the data returned from the getInfo method seems to be wrong.

Anyone know why streamsinuse is nonzero for an in-memory wave bank? Is there a better way to detect whether all streams have finished playing, than by scanning the wave bank states? While I guess it’s possible we didn’t call stop on one of the FMOD::Event objects, it seems somewhat unlikely – we’ve never had an issue in the game where some rogue sound remains active.

Cheers

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.