From 29e0af5ef052a3602f9b7935d6002c6d2ae5e8cb Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 9 Feb 2014 18:55:51 -0800 Subject: Fix a race condition in the mmdevapi message queue thread --- Alc/backends/mmdevapi.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Alc') diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index 32c4d7ef..b93ff667 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -600,6 +600,12 @@ static DWORD CALLBACK MMDevApiMsgProc(void *ptr) CoUninitialize(); + /* HACK: Force Windows to create a message queue for this thread before + * returning success, otherwise PostThreadMessage may fail if it gets + * called before GetMessage. + */ + PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); + TRACE("Message thread initialization complete\n"); req->result = S_OK; SetEvent(req->FinishedEvt); -- cgit v1.2.3