From 319b19203aca10c0f241faf2ff89ec300c3aba4c Mon Sep 17 00:00:00 2001 From: dmitrykos Date: Fri, 26 Aug 2016 22:31:45 +0300 Subject: [PATCH] wasapi: replaced InterlockedCompareExchange with InterlockedOr and added clarifying comment why Interlocked API is used --- src/hostapi/wasapi/pa_win_wasapi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c index be3115a..e865c7b 100644 --- a/src/hostapi/wasapi/pa_win_wasapi.c +++ b/src/hostapi/wasapi/pa_win_wasapi.c @@ -1367,7 +1367,8 @@ static HRESULT ActivateAudioInterface_WINRT(const PaWasapiDeviceInfo *deviceInfo IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error); // Wait in busy loop for async operation to complete - while (SUCCEEDED(hr) && !InterlockedCompareExchange(&handlerImpl->done, FALSE, FALSE)) + // Use Interlocked API here to ensure that ->done variable is read every time through the loop + while (SUCCEEDED(hr) && !InterlockedOr(&handlerImpl->done, 0)) { Sleep(1); } -- 2.43.0