From e4ff49d5580823e6317b233eae752f0024bd57e5 Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Wed, 10 Mar 2021 07:43:54 -0800 Subject: [PATCH] wasapi: ensure that wasapi context structure is zeroed before filling it I had a situation where I was doing: ma_backend backends[] = { ma_backend_jack, ma_backend_wasapi, }; ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), &contextConfig, &context); And since JACK was unavailable, it fell back to WASAPI. When this happened, the WASAPI commandIndex and commandCount variables were already stomped on by the JACK backend initialization, but the WASAPI backend assumes they are zero-initialized. Signed-off-by: Steven Noonan --- miniaudio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/miniaudio.h b/miniaudio.h index d7b5c113..5166f93f 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -16257,6 +16257,8 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_ return result; } + MA_ZERO_OBJECT(&pContext->wasapi); + /* Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread than the one that retrieved it with GetService(). This can result in a deadlock in two