Wait for the OpenSL buffer queue to empty when stopping

This commit is contained in:
Chris Robinson
2015-08-13 16:01:31 -07:00
parent f134fbac5c
commit 7d4e3688e1
+10 -1
View File
@@ -25,7 +25,7 @@
#include "alMain.h"
#include "alu.h"
#include "threads.h"
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
@@ -379,6 +379,15 @@ static void opensl_stop_playback(ALCdevice *Device)
result = VCALL0(bufferQueue,Clear)();
PRINTERR(result, "bufferQueue->Clear");
}
if(SL_RESULT_SUCCESS == result)
{
SLAndroidSimpleBufferQueueState state;
do {
althrd_yield();
result = VCALL(bufferQueue,GetState)(&state);
} while(SL_RESULT_SUCCESS == result && state.count > 0);
PRINTERR(result, "bufferQueue->GetState");
}
free(data->buffer);
data->buffer = NULL;