From 6502311563596f41ffba685cac482dc19f83c369 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 10 Dec 2012 13:09:41 +0100 Subject: [PATCH] Changed: Additional checks for streaming buffers in OpenAL --- code/nel/src/sound/driver/openal/buffer_al.cpp | 5 ++--- code/nel/src/sound/driver/openal/source_al.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/nel/src/sound/driver/openal/buffer_al.cpp b/code/nel/src/sound/driver/openal/buffer_al.cpp index 63a0a19d9..b63e39fa2 100644 --- a/code/nel/src/sound/driver/openal/buffer_al.cpp +++ b/code/nel/src/sound/driver/openal/buffer_al.cpp @@ -120,7 +120,7 @@ bool CBufferAL::unlock(uint size) // Error handling if (alGetError() == AL_NO_ERROR) - _IsLoaded = true; + _IsLoaded = true; // ->lock() set it to false return _IsLoaded; } @@ -161,8 +161,7 @@ bool CBufferAL::fill(const uint8 *src, uint size) alBufferData(_BufferName, _SampleFormat, src, size, _Frequency); // Error handling - if (alGetError() == AL_NO_ERROR) - _IsLoaded = true; + _IsLoaded = (alGetError() == AL_NO_ERROR); return _IsLoaded; } diff --git a/code/nel/src/sound/driver/openal/source_al.cpp b/code/nel/src/sound/driver/openal/source_al.cpp index 154bcebe1..a1b0af152 100644 --- a/code/nel/src/sound/driver/openal/source_al.cpp +++ b/code/nel/src/sound/driver/openal/source_al.cpp @@ -162,6 +162,13 @@ void CSourceAL::submitStreamingBuffer(IBuffer *buffer) CBufferAL *bufferAL = static_cast(buffer); ALuint bufferName = bufferAL->bufferName(); nlassert(bufferName); + + if (!bufferAL->isBufferLoaded()) + { + nlwarning("AL: Streaming buffer was not loaded, skipping buffer. This should not happen."); + return; + } + alSourceQueueBuffers(_Source, 1, &bufferName); alTestError(); _QueuedBuffers.push(bufferAL);