From 7d4e3688e1101ade56bb0769dcb28686dbc4d6e4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 13 Aug 2015 16:01:31 -0700 Subject: Wait for the OpenSL buffer queue to empty when stopping --- Alc/backends/opensl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Alc/backends/opensl.c') diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c index 1043359c..7b8fdb25 100644 --- a/Alc/backends/opensl.c +++ b/Alc/backends/opensl.c @@ -25,7 +25,7 @@ #include "alMain.h" #include "alu.h" - +#include "threads.h" #include #include @@ -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; -- cgit v1.2.3