My game using UE4.26.2 , fmod:2.01.10, need udpate banks in DLC on Android mobile device.
When my banks download finish , will do follow setps:
- start a new empty level,
2 called UnloadRuntimeBanks method, - delay 0.3 seconds
- called ReloadRuntimeBanks
the result is the app will blocking, look like enter infiniti loop state.
I add some debug log , found that perform “StudioSystem[Type]->flushCommands();” in FFMODStudioModule::LoadBanks().
Please tell me what should i do in my case.
The fllow is my Code:
void FFMODStudioModule::UnLoadRuntimeBanks()
{
if (StudioSystem[EFMODSystemContext::Auditioning])
{
// We currently don't tear down auditioning system but we do stop the playing event.
if (AuditioningInstance)
{
AuditioningInstance->stop(FMOD_STUDIO_STOP_IMMEDIATE);
AuditioningInstance = nullptr;
}
// Also make sure banks are finishing loading so they aren't grabbing file handles.
StudioSystem[EFMODSystemContext::Auditioning]->flushCommands();
}
EFMODSystemContext::Type Type = EFMODSystemContext::Runtime;
// Unload all events and banks to remove warning spam when using split banks
if (StudioSystem[Type])
{
int bankCount;
verifyfmod(StudioSystem[Type]->getBankCount(&bankCount));
if (bankCount > 0)
{
TArray<FMOD::Studio::Bank *> bankArray;
TArray<FMOD::Studio::EventDescription *> eventArray;
TArray<FMOD::Studio::EventInstance *> instanceArray;
bankArray.SetNumUninitialized(bankCount, false);
verifyfmod(StudioSystem[Type]->getBankList(bankArray.GetData(), bankCount, &bankCount));
for (int i = 0; i < bankCount; i++)
{
int eventCount;
verifyfmod(bankArray[i]->getEventCount(&eventCount));
if (eventCount > 0)
{
eventArray.SetNumUninitialized(eventCount, false);
verifyfmod(bankArray[i]->getEventList(eventArray.GetData(), eventCount, &eventCount));
for (int j = 0; j < eventCount; j++)
{
int instanceCount;
verifyfmod(eventArray[j]->getInstanceCount(&instanceCount));
if (instanceCount > 0)
{
instanceArray.SetNumUninitialized(instanceCount, false);
verifyfmod(eventArray[j]->getInstanceList(instanceArray.GetData(), instanceCount, &instanceCount));
for (int k = 0; k < instanceCount; k++)
{
verifyfmod(instanceArray[k]->stop(FMOD_STUDIO_STOP_IMMEDIATE));
verifyfmod(instanceArray[k]->release());
}
}
}
}
}
for (int i = 0; i < bankCount; i++)
{
FMOD_STUDIO_LOADING_STATE state;
bankArray[i]->getSampleLoadingState(&state);
if (state == FMOD_STUDIO_LOADING_STATE_LOADED)
{
verifyfmod(bankArray[i]->unloadSampleData());
}
bankArray[i]->unload();
}
}
}
}
void FFMODStudioModule::ReloadRuntimeBanks()
{
EFMODSystemContext::Type Type = EFMODSystemContext::Runtime;
LoadBanks(EFMODSystemContext::Runtime);
}