Module: wine Branch: master Commit: b6c7eda2d3d61ab81e9d9ad8c543f603f5f32593 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b6c7eda2d3d61ab81e9d9ad8c5...
Author: Eric Pouech eric.pouech@orange.fr Date: Sat Oct 17 12:10:05 2009 +0200
winmm: Get rid of WINE_TIMER_IS32 internal flag.
---
dlls/winmm/mmsystem.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++--- dlls/winmm/time.c | 22 ++---------- dlls/winmm/winemm.h | 4 -- 3 files changed, 85 insertions(+), 27 deletions(-)
diff --git a/dlls/winmm/mmsystem.c b/dlls/winmm/mmsystem.c index 3b36f8b..0b4a694 100644 --- a/dlls/winmm/mmsystem.c +++ b/dlls/winmm/mmsystem.c @@ -38,6 +38,7 @@ #include "wownt32.h" #include "winnls.h"
+#include "wine/list.h" #include "wine/winuser16.h" #include "winemm.h" #include "winemm16.h" @@ -51,6 +52,15 @@ static LPWINE_DRIVER DRIVER_OpenDriver16(LPCWSTR, LPCWSTR, LPARAM); static LRESULT DRIVER_CloseDriver16(HDRVR16, LPARAM, LPARAM); static LRESULT DRIVER_SendMessage16(HDRVR16, UINT, LPARAM, LPARAM);
+static CRITICAL_SECTION mmdrv_cs; +static CRITICAL_SECTION_DEBUG mmdrv_critsect_debug = +{ + 0, 0, &mmdrv_cs, + { &mmdrv_critsect_debug.ProcessLocksList, &mmdrv_critsect_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": mmsystem_mmdrv_cs") } +}; +static CRITICAL_SECTION mmdrv_cs = { &mmdrv_critsect_debug, -1, 0, 0, 0, 0 }; + /* ################################################### * # LIBRARY # * ################################################### @@ -2371,17 +2381,66 @@ MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize) return 0; }
+struct timer_entry { + struct list entry; + UINT id; + LPTIMECALLBACK16 func16; + DWORD user; +}; + +static struct list timer_list = LIST_INIT(timer_list); + +static void CALLBACK timeCB3216(UINT id, UINT uMsg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2) +{ + struct timer_entry* te = (void*)user; + WORD args[8]; + DWORD ret; + + args[7] = LOWORD(id); + args[6] = LOWORD(uMsg); + args[5] = HIWORD(te->user); + args[4] = LOWORD(te->user); + args[3] = HIWORD(dw1); + args[2] = LOWORD(dw2); + args[1] = HIWORD(dw2); + args[0] = LOWORD(dw2); + WOWCallback16Ex((DWORD)te->func16, WCB16_PASCAL, sizeof(args), args, &ret); +} + /************************************************************************** * timeSetEvent [MMSYSTEM.602] */ MMRESULT16 WINAPI timeSetEvent16(UINT16 wDelay, UINT16 wResol, LPTIMECALLBACK16 lpFunc, DWORD dwUser, UINT16 wFlags) { - if (wFlags & WINE_TIMER_IS32) - WARN("Unknown windows flag... wine internally used.. ooch\n"); + MMRESULT16 id; + struct timer_entry* te;
- return TIME_SetEventInternal(wDelay, wResol, (LPTIMECALLBACK)lpFunc, - dwUser, wFlags & ~WINE_TIMER_IS32); + switch (wFlags & (TIME_CALLBACK_EVENT_SET|TIME_CALLBACK_EVENT_PULSE)) + { + case TIME_CALLBACK_EVENT_SET: + case TIME_CALLBACK_EVENT_PULSE: + id = timeSetEvent(wDelay, wResol, (LPTIMECALLBACK)lpFunc, dwUser, wFlags); + break; + case TIME_CALLBACK_FUNCTION: + te = HeapAlloc(GetProcessHeap(), 0, sizeof(*te)); + if (!te) return 0; + te->func16 = lpFunc; + te->user = dwUser; + id = te->id = timeSetEvent(wDelay, wResol, timeCB3216, (DWORD_PTR)te, wFlags); + if (id) + { + EnterCriticalSection(&mmdrv_cs); + list_add_tail(&timer_list, &te->entry); + LeaveCriticalSection(&mmdrv_cs); + } + else HeapFree(GetProcessHeap(), 0, te); + break; + default: + id = 0; + break; + } + return id; }
/************************************************************************** @@ -2389,7 +2448,24 @@ MMRESULT16 WINAPI timeSetEvent16(UINT16 wDelay, UINT16 wResol, LPTIMECALLBACK16 */ MMRESULT16 WINAPI timeKillEvent16(UINT16 wID) { - return timeKillEvent(wID); + MMRESULT16 ret = timeKillEvent(wID); + struct timer_entry* te; + + if (ret == TIMERR_NOERROR) + { + EnterCriticalSection(&mmdrv_cs); + LIST_FOR_EACH_ENTRY(te, &timer_list, struct timer_entry, entry) + { + if (wID == te->id) + { + list_remove(&te->entry); + HeapFree(GetProcessHeap(), 0, te); + break; + } + } + LeaveCriticalSection(&mmdrv_cs); + } + return ret; }
/************************************************************************** diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c index 8c64ac8..fcf31f0 100644 --- a/dlls/winmm/time.c +++ b/dlls/winmm/time.c @@ -179,8 +179,7 @@ static int TIME_MMSysTimeCallback(void) if (flags & TIME_KILL_SYNCHRONOUS) EnterCriticalSection(&TIME_cbcrst); LeaveCriticalSection(&WINMM_cs);
- if (flags & WINE_TIMER_IS32) func(id, 0, user, 0, 0); - else if (pFnCallMMDrvFunc16) pFnCallMMDrvFunc16((DWORD_PTR)func, id, 0, user, 0, 0); + func(id, 0, user, 0, 0);
EnterCriticalSection(&WINMM_cs); if (flags & TIME_KILL_SYNCHRONOUS) LeaveCriticalSection(&TIME_cbcrst); @@ -301,10 +300,10 @@ MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize) }
/************************************************************************** - * TIME_SetEventInternal [internal] + * timeSetEvent [WINMM.@] */ -WORD TIME_SetEventInternal(UINT wDelay, UINT wResol, - LPTIMECALLBACK lpFunc, DWORD_PTR dwUser, UINT wFlags) +MMRESULT WINAPI timeSetEvent(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc, + DWORD_PTR dwUser, UINT wFlags) { WORD wNewID = 0; LPWINE_TIMERENTRY lpNewTimer; @@ -351,19 +350,6 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol, }
/************************************************************************** - * timeSetEvent [WINMM.@] - */ -MMRESULT WINAPI timeSetEvent(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc, - DWORD_PTR dwUser, UINT wFlags) -{ - if (wFlags & WINE_TIMER_IS32) - WARN("Unknown windows flag... wine internally used.. ooch\n"); - - return TIME_SetEventInternal(wDelay, wResol, lpFunc, - dwUser, wFlags|WINE_TIMER_IS32); -} - -/************************************************************************** * timeKillEvent [WINMM.@] */ MMRESULT WINAPI timeKillEvent(UINT wID) diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index 22bf222..97403e5 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -151,8 +151,6 @@ typedef struct tagWINE_MCIDRIVER { struct tagWINE_MCIDRIVER*lpNext; } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
-#define WINE_TIMER_IS32 0x80 - struct IOProcList { struct IOProcList*pNext; /* Next item in linked list */ @@ -220,8 +218,6 @@ UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType, LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
-WORD TIME_SetEventInternal(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc, - DWORD_PTR dwUser, UINT wFlags); void TIME_MMTimeStop(void);
/* Global variables */