Merge pull request #15735 from MrCapone/v3

AudioEngine-linux fix: add map contains IDs of preloaded files
This commit is contained in:
minggo 2016-06-01 21:34:15 +08:00
commit 1d42bae8c5
2 changed files with 10 additions and 0 deletions

View File

@ -261,6 +261,8 @@ void AudioEngineImpl::uncache(const std::string& path)
}
mapSound.erase(it);
}
if (mapId.find(path) != mapId.end())
mapId.erase(path);
}
void AudioEngineImpl::uncacheAll()
@ -272,6 +274,7 @@ void AudioEngineImpl::uncacheAll()
}
}
mapSound.clear();
mapId.clear();
}
int AudioEngineImpl::preload(const std::string& filePath, std::function<void(bool isSuccess)> callback)
@ -291,6 +294,11 @@ int AudioEngineImpl::preload(const std::string& filePath, std::function<void(boo
}
int id = static_cast<int>(mapChannelInfo.size()) + 1;
if (mapId.find(filePath) == mapId.end())
mapId.insert({filePath, id});
else
id = mapId.at(filePath);
auto& chanelInfo = mapChannelInfo[id];
chanelInfo.sound = sound;
chanelInfo.id = id;

View File

@ -93,6 +93,8 @@ private:
};
std::map<int, ChannelInfo> mapChannelInfo;
std::map<std::string, int> mapId;
std::map<std::string, FMOD::Sound *> mapSound;