1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-02 20:43:35 +00:00

Source: Stop, then unqueue buffers

Doing it the other way around is illegal; you may not unqueue unprocessed buffers, so we need to stop first.
This commit is contained in:
Nevyn Bengtsson 2020-01-05 21:26:14 +01:00
parent b3fb31f5a4
commit 1db932d856

View file

@ -281,15 +281,15 @@ void lovrSourceStop(Source* source) {
case SOURCE_STREAM: {
// Stop the source
alSourceStop(source->id);
alSourcei(source->id, AL_BUFFER, AL_NONE);
// Empty the buffers
int count = 0;
alGetSourcei(source->id, AL_BUFFERS_QUEUED, &count);
alSourceUnqueueBuffers(source->id, count, NULL);
// Stop the source
alSourceStop(source->id);
alSourcei(source->id, AL_BUFFER, AL_NONE);
// Rewind the decoder
if (!lovrAudioStreamIsRaw(source->stream)) {
lovrAudioStreamRewind(source->stream);