mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 19:45:34 +00:00
Don't hold a list of all sound sources
This commit is contained in:
parent
fe36cc1de7
commit
3b7edae7c3
2 changed files with 11 additions and 11 deletions
|
@ -637,9 +637,8 @@ void OpenAL_Output::init(const std::string &devname)
|
||||||
ALuint src = 0;
|
ALuint src = 0;
|
||||||
alGenSources(1, &src);
|
alGenSources(1, &src);
|
||||||
throwALerror();
|
throwALerror();
|
||||||
mSources.push_back(src);
|
mFreeSources.push_back(src);
|
||||||
}
|
}
|
||||||
mFreeSources.insert(mFreeSources.begin(), mSources.begin(), mSources.end());
|
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -655,11 +654,9 @@ void OpenAL_Output::deinit()
|
||||||
{
|
{
|
||||||
mStreamThread->removeAll();
|
mStreamThread->removeAll();
|
||||||
|
|
||||||
std::cerr<< "There are "<<mActiveSounds.size()<<" active sources at close" <<std::endl;
|
for(size_t i = 0;i < mFreeSources.size();i++)
|
||||||
|
alDeleteSources(1, &mFreeSources[i]);
|
||||||
mFreeSources.clear();
|
mFreeSources.clear();
|
||||||
if(mSources.size() > 0)
|
|
||||||
alDeleteSources(mSources.size(), &mSources[0]);
|
|
||||||
mSources.clear();
|
|
||||||
|
|
||||||
mBufferRefs.clear();
|
mBufferRefs.clear();
|
||||||
mUnusedBuffers.clear();
|
mUnusedBuffers.clear();
|
||||||
|
@ -893,7 +890,7 @@ void OpenAL_Output::updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3
|
||||||
|
|
||||||
void OpenAL_Output::pauseSounds(int types)
|
void OpenAL_Output::pauseSounds(int types)
|
||||||
{
|
{
|
||||||
IDVec sources;
|
std::vector<ALuint> sources;
|
||||||
SoundVec::const_iterator iter = mActiveSounds.begin();
|
SoundVec::const_iterator iter = mActiveSounds.begin();
|
||||||
while(iter != mActiveSounds.end())
|
while(iter != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
|
@ -912,12 +909,15 @@ void OpenAL_Output::pauseSounds(int types)
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
if(sources.size() > 0)
|
if(sources.size() > 0)
|
||||||
|
{
|
||||||
alSourcePausev(sources.size(), &sources[0]);
|
alSourcePausev(sources.size(), &sources[0]);
|
||||||
|
throwALerror();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenAL_Output::resumeSounds(int types)
|
void OpenAL_Output::resumeSounds(int types)
|
||||||
{
|
{
|
||||||
IDVec sources;
|
std::vector<ALuint> sources;
|
||||||
SoundVec::const_iterator iter = mActiveSounds.begin();
|
SoundVec::const_iterator iter = mActiveSounds.begin();
|
||||||
while(iter != mActiveSounds.end())
|
while(iter != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
|
@ -936,7 +936,10 @@ void OpenAL_Output::resumeSounds(int types)
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
if(sources.size() > 0)
|
if(sources.size() > 0)
|
||||||
|
{
|
||||||
alSourcePlayv(sources.size(), &sources[0]);
|
alSourcePlayv(sources.size(), &sources[0]);
|
||||||
|
throwALerror();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,6 @@ namespace MWSound
|
||||||
ALCdevice *mDevice;
|
ALCdevice *mDevice;
|
||||||
ALCcontext *mContext;
|
ALCcontext *mContext;
|
||||||
|
|
||||||
typedef std::vector<ALuint> IDVec;
|
|
||||||
IDVec mSources;
|
|
||||||
|
|
||||||
typedef std::deque<ALuint> IDDq;
|
typedef std::deque<ALuint> IDDq;
|
||||||
IDDq mFreeSources;
|
IDDq mFreeSources;
|
||||||
IDDq mUnusedBuffers;
|
IDDq mUnusedBuffers;
|
||||||
|
|
Loading…
Reference in a new issue