ALStream: Fix sometimes not unqueuing all buffers before play

Very rarely rogue buffers would remain and play on loop on song
switch because we only ever cleared processed, not queued, buffers
from the source.

The correct way to completely clear a source's queue is to
simply attach a null buffer to it.
This commit is contained in:
Jonas Kulla 2014-07-31 03:39:36 +02:00
parent d7e0429ea6
commit 80937d0d06
3 changed files with 7 additions and 13 deletions

View File

@ -133,6 +133,11 @@ namespace Source
return buffer; return buffer;
} }
inline void clearQueue(Source::ID id)
{
attachBuffer(id, Buffer::ID(0));
}
inline ALint getInteger(Source::ID id, ALenum prop) inline ALint getInteger(Source::ID id, ALenum prop)
{ {
ALint value; ALint value;

View File

@ -57,8 +57,7 @@ ALStream::~ALStream()
{ {
close(); close();
clearALQueue(); AL::Source::clearQueue(alSrc);
AL::Source::del(alSrc); AL::Source::del(alSrc);
for (int i = 0; i < STREAM_BUFS; ++i) for (int i = 0; i < STREAM_BUFS; ++i)
@ -228,7 +227,7 @@ void ALStream::stopStream()
void ALStream::startStream(float offset) void ALStream::startStream(float offset)
{ {
clearALQueue(); AL::Source::clearQueue(alSrc);
preemptPause = false; preemptPause = false;
streamInited = false; streamInited = false;
@ -292,15 +291,6 @@ void ALStream::checkStopped()
state = Stopped; state = Stopped;
} }
void ALStream::clearALQueue()
{
/* Unqueue all buffers */
ALint queuedBufs = AL::Source::getProcBufferCount(alSrc);
while (queuedBufs--)
AL::Source::unqueueBuffer(alSrc);
}
/* thread func */ /* thread func */
void ALStream::streamData() void ALStream::streamData()
{ {

View File

@ -112,7 +112,6 @@ private:
void resumeStream(); void resumeStream();
void checkStopped(); void checkStopped();
void clearALQueue();
/* thread func */ /* thread func */
void streamData(); void streamData();