1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Keep track of all allocated sources

This commit is contained in:
Chris Robinson 2012-12-12 01:32:16 -08:00
parent e82c4afd50
commit 973b5faf25
2 changed files with 9 additions and 6 deletions

View File

@ -504,8 +504,9 @@ void OpenAL_Output::init(const std::string &devname)
ALuint src = 0;
alGenSources(1, &src);
throwALerror();
mFreeSources.push_back(src);
mSources.push_back(src);
}
mFreeSources.insert(mFreeSources.begin(), mSources.begin(), mSources.end());
}
catch(std::exception &e)
{
@ -521,11 +522,10 @@ void OpenAL_Output::deinit()
{
mStreamThread->removeAll();
while(!mFreeSources.empty())
{
alDeleteSources(1, &mFreeSources.front());
mFreeSources.pop_front();
}
mFreeSources.clear();
if(mSources.size() > 0)
alDeleteSources(mSources.size(), &mSources[0]);
mSources.clear();
mBufferRefs.clear();
mUnusedBuffers.clear();

View File

@ -21,6 +21,9 @@ namespace MWSound
ALCdevice *mDevice;
ALCcontext *mContext;
typedef std::vector<ALuint> IDVec;
IDVec mSources;
typedef std::deque<ALuint> IDDq;
IDDq mFreeSources;
IDDq mUnusedBuffers;