[ros-kernel] mmTaskCreate patch - For you sound junkys

Filip Navara xnavara at volny.cz
Wed Jul 14 19:27:19 CEST 2004


Steven Edwards wrote:

>If you are interested in getting sound working on ReactOS this patch
>will let you load the Wine Winmm.dll under Windows NT 4. Our winmm.dll
>needs to be resync'd with winehq so this patch will apply cleanly but
>anyone wanting to work on sound could go ahead and hack it in. I would
>recommend  trying to load Windows mmdrv.dll under ReactOS with our
>wimmm.dll to see if you can get working sound.
>
>Thanks
>Steven
>  
>
Here is more correct version of that patch. It's against the ReactOS 
CVS. I can produce one against Wine CVS on request.

Regards,
Filip

-------------- next part --------------
Index: include/mmddk.h
===================================================================
--- include/mmddk.h	(revision 1)
+++ include/mmddk.h	(working copy)
@@ -449,6 +449,16 @@
 BOOL		 	WINAPI	DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
 					       UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
 
+typedef void (*LPTASKCALLBACK)(DWORD dwInst);
+
+#define TASKERR_NOTASKSUPPORT 1
+#define TASKERR_OUTOFMEMORY   2
+MMRESULT WINAPI mmTaskCreate(LPTASKCALLBACK, HANDLE*, DWORD);
+void     WINAPI mmTaskBlock(HANDLE);
+BOOL     WINAPI mmTaskSignal(HANDLE);
+void     WINAPI mmTaskYield(void);
+HANDLE   WINAPI mmGetCurrentTask(void);
+
 #ifdef __WINESRC__
 #define  WAVE_DIRECTSOUND               0x0080
 #endif
Index: winmm/winmm.spec
===================================================================
--- winmm/winmm.spec	(revision 1)
+++ winmm/winmm.spec	(working copy)
@@ -135,6 +135,7 @@
 @ stdcall mmioStringToFOURCCW(wstr long)
 @ stdcall mmioWrite(long ptr long)
 @ stdcall mmsystemGetVersion()
+@ stdcall mmTaskCreate(ptr ptr long)
 @ stdcall sndPlaySoundA(ptr long)
 @ stdcall sndPlaySoundW(ptr long)
 @ stdcall timeBeginPeriod(long)
Index: winmm/winmm.c
===================================================================
--- winmm/winmm.c	(revision 1)
+++ winmm/winmm.c	(working copy)
@@ -102,8 +102,9 @@
 	 * inside WINMM_IData */
         CloseHandle(WINMM_IData->psStopEvent);
         CloseHandle(WINMM_IData->psLastEvent);
+        WINMM_IData->cs.DebugInfo = NULL;
         DeleteCriticalSection(&WINMM_IData->cs);
-	HeapFree(GetProcessHeap(), 0, WINMM_IData);
+        HeapFree(GetProcessHeap(), 0, WINMM_IData);
         WINMM_IData = NULL;
     }
 }
@@ -3176,3 +3177,44 @@
 
     return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
 }
+
+struct mm_starter
+{
+    LPTASKCALLBACK      cb;
+    DWORD               client;
+    HANDLE              event;
+};
+
+DWORD WINAPI mmTaskRun(void* pmt)
+{
+    struct mm_starter mms;
+
+    memcpy(&mms, pmt, sizeof(struct mm_starter));
+    HeapFree(GetProcessHeap(), 0, pmt);
+    mms.cb(mms.client);
+    if (mms.event) SetEvent(mms.event);
+    return 0;
+}
+
+MMRESULT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD client)
+{
+    HANDLE               h;
+    struct mm_starter   *mms;
+
+    mms = HeapAlloc(GetProcessHeap(), 0, sizeof(struct mm_starter));
+    if (mms == NULL) { return TASKERR_OUTOFMEMORY; }
+
+    mms->cb = cb;
+    mms->client = client;
+    if (ph) {
+        mms->event = CreateEvent(NULL, FALSE, FALSE, NULL);
+    } else {
+        mms->event = NULL;
+    }
+
+    h = CreateThread(0, 0, mmTaskRun, (LPVOID)&mms, 0, NULL);
+    if (!h) return TASKERR_OUTOFMEMORY;
+    if (ph) *ph = mms->event;
+    CloseHandle(h);
+    return 0;
+}


More information about the Ros-kernel mailing list