[DMUSIC] Fix for PostMessageToProcessMsgThread (RESEND)

Christian Costa titan.costa at wanadoo.fr
Mon Jan 10 14:02:13 CST 2005


Hi,

It seems this patch has been lost, so here it is again.

Changelog:
Wait until the thread has created its message queue before posting a 
message otherwise
it will be lost.

Christian Costa   titan.costa at wanadoo.fr
 
-------------- next part --------------
Index: dlls/dmime/performance.c
===================================================================
RCS file: /home/wine/wine/dlls/dmime/performance.c,v
retrieving revision 1.19
diff -u -r1.19 performance.c
--- dlls/dmime/performance.c	3 Jan 2005 14:56:42 -0000	1.19
+++ dlls/dmime/performance.c	9 Jan 2005 07:58:18 -0000
@@ -146,10 +146,20 @@
 
 static BOOL PostMessageToProcessMsgThread(IDirectMusicPerformance8Impl* This, UINT iMsg) {
   if (FALSE == This->procThreadTicStarted && PROCESSMSG_EXIT != iMsg) {
+    BOOL res;
     This->procThread = CreateThread(NULL, 0, ProcessMsgThread, This, 0, &This->procThreadId);
     if (NULL == This->procThread) return FALSE;
     SetThreadPriority(This->procThread, THREAD_PRIORITY_TIME_CRITICAL);
     This->procThreadTicStarted = TRUE;
+    while(1) {
+      res = PostThreadMessageA(This->procThreadId, iMsg, 0, 0);
+      /* Let the thread creates its message queue (with MsgWaitForMultipleObjects call) by yielding and retrying */
+      if (!res && (GetLastError() == ERROR_INVALID_THREAD_ID))
+	Sleep(0);
+      else
+	break;
+    }
+    return res;
   }
   return PostThreadMessageA(This->procThreadId, iMsg, 0, 0);
 }


More information about the wine-patches mailing list