Fixed: ugly fix to not crash when we cannot create a buffer #1116

This commit is contained in:
vl 2011-06-01 00:04:11 +02:00
parent 23f89c8d90
commit d2bc4b288a

View file

@ -890,15 +890,22 @@ void CSourceAL::setStreamingBuffersMax(uint buffers)
unqueueBuffers();
removeBuffers();
for(uint i = 0; i < _BuffersMax; ++i)
{
// create a new buffer
CBufferAL *buffer = static_cast<CBufferAL*>(_SoundDriver->createBuffer());
// use StorageSoftware because buffers will be reused
// deleting and recreating them is a waste of time
buffer->setStorageMode(IBuffer::StorageSoftware);
_Buffers[buffer->bufferName()] = buffer;
}
for(uint i = 0; i < _BuffersMax; ++i)
{
try {
// create a new buffer
CBufferAL *buffer = static_cast<CBufferAL*>(_SoundDriver->createBuffer());
// use StorageSoftware because buffers will be reused
// deleting and recreating them is a waste of time
buffer->setStorageMode(IBuffer::StorageSoftware);
_Buffers[buffer->bufferName()] = buffer;
} catch(ESoundDriverGenBuf &e) {
nlwarning("Cannot create %d buffers. openal fails after %d buffers", buffers, i);
_BuffersMax = i;
_BuffersName.resize(i);
break;
}
}
}
/// Set the default size for streaming buffers