- Timestamp:
- Oct 13, 2003, 11:18:38 AM (22 years ago)
- Location:
- trunk/src/winmm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/winmm/os2timer.cpp
r9916 r10269 1 /* $Id: os2timer.cpp,v 1.2 1 2003-03-06 15:42:33sandervl Exp $ */1 /* $Id: os2timer.cpp,v 1.22 2003-10-13 09:18:37 sandervl Exp $ */ 2 2 3 3 /* … … 239 239 OS2Timer::OS2Timer() : TimerSem(0), TimerHandle(0), hTimerThread(0), 240 240 clientCallback(NULL), TimerStatus(Stopped), fFatal(FALSE), 241 next(NULL), timerID(0) 241 next(NULL), timerID(0), refCount(0) 242 242 { 243 243 dprintf(("WINMM:OS2Timer: OS2Timer::OS2Timer(%08xh)\n", … … 266 266 return; // terminate thread 267 267 } 268 269 270 //hTimerThread = _beginthread(TimerHlpHandler, NULL, 0x4000, (void *)this); 268 269 //increase reference count for creation 270 addRef(); 271 272 //increase reference count since the thread will access the object 273 addRef(); 271 274 hTimerThread = CreateThread(NULL, 272 275 0x4000, … … 392 395 TimerStatus = InActive; 393 396 } 397 //****************************************************************************** 398 //****************************************************************************** 399 #ifdef DEBUG 400 LONG OS2Timer::addRef() 401 { 402 //// dprintf2(("addRef %x -> refcount %x", this, refCount+1)); 403 return InterlockedIncrement(&refCount); 404 }; 405 #endif 406 /******************************************************************************/ 407 //****************************************************************************** 408 LONG OS2Timer::release() 409 { 410 #ifdef DEBUG 411 if(refCount-1 < 0) { 412 DebugInt3(); 413 } 414 #endif 415 if(InterlockedDecrement(&refCount) == 0) { 416 dprintf2(("marked for deletion -> delete now")); 417 delete this; 418 return 0; 419 } 420 return refCount; 421 } 394 422 /******************************************************************************/ 395 423 //****************************************************************************** … … 414 442 clientCallback)); 415 443 416 DosWaitEventSem(TimerSem, SEM_INDEFINITE_WAIT); 417 DosResetEventSem(TimerSem, &Count); 444 rc = DosWaitEventSem(TimerSem, SEM_INDEFINITE_WAIT); 445 if(rc) { 446 dprintf(("DosWaitEventSem failed with %d", rc)); 447 DebugInt3(); 448 } 449 rc = DosResetEventSem(TimerSem, &Count); 450 if(rc) { 451 dprintf(("DosResetEventSem failed with %d", rc)); 452 DebugInt3(); 453 } 418 454 if(!fFatal) 419 455 { … … 434 470 if (clientCallback != NULL) 435 471 { 436 selTIB = SetWin32TIB(); 437 clientCallback((UINT)timerID, 0, userData, 0, 0); 438 SetFS(selTIB); 472 clientCallback((UINT)timerID, 0, userData, 0, 0); 439 473 } 440 474 break; … … 462 496 463 497 DosCloseEventSem(TimerSem); 498 499 //release object 500 release(); 464 501 465 502 // mark this thread as terminated … … 474 511 return 0; 475 512 } 476 477 478 513 //****************************************************************************** 479 514 //****************************************************************************** -
trunk/src/winmm/os2timer.h
r9901 r10269 1 /* $Id: os2timer.h,v 1.1 2 2003-03-05 14:48:45sandervl Exp $ */1 /* $Id: os2timer.h,v 1.13 2003-10-13 09:18:37 sandervl Exp $ */ 2 2 3 3 #ifndef __OS2TIMER_H__ … … 40 40 ****************************************************************************/ 41 41 42 #if 043 typedef struct _MMTIMEREVENT44 {45 struct _MMTIMEREVENT* prev;46 struct _MMTIMEREVENT* next;47 48 DWORD id; // event id49 DWORD timeScheduled; // system time to fire event50 DWORD timePeriod; // period if periodic event51 TID tidCaller; // thread ID of caller thread52 DWORD dwUser; // user supplied value53 LPTIMERCALLBACK lpCallback; // address to call54 DWORD dwFlags; // event flags55 } MMTIMEREVENT, *PMMTIMEREVENT, *LPTIMEREVENT;56 #endif57 58 42 /* 59 43 addEvent … … 75 59 static BOOL leaveResolutionScope(int dwPeriod); // release resolution request 76 60 static int queryCurrentResolution(); // query maximum resolution 77 61 78 62 // public variables 79 63 int dwPeriod; … … 107 91 void KillTimer(); 108 92 109 110 93 DWORD getTimerID() { return timerID; }; 111 94 void setTimerID(DWORD id) { timerID = id; }; 95 96 #ifdef DEBUG 97 LONG addRef(); 98 #else 99 LONG addRef() { return InterlockedIncrement(&refCount); }; 100 #endif 101 LONG getRefCount() { return refCount; }; 102 LONG release(); 112 103 113 104 protected: … … 130 121 Stopped 131 122 }; 123 124 LONG refCount; 125 132 126 static int timerPeriod; 133 127 -
trunk/src/winmm/time.cpp
r9901 r10269 1 /* $Id: time.cpp,v 1.1 7 2003-03-05 14:48:45sandervl Exp $ */1 /* $Id: time.cpp,v 1.18 2003-10-13 09:18:38 sandervl Exp $ */ 2 2 3 3 /* … … 145 145 } 146 146 HMHandleFree(IDEvent); 147 // return OS2Timer::killEvent(UINT IDEvent) 148 149 delete os2timer;147 148 os2timer->KillTimer(); 149 os2timer->release(); 150 150 return TIMERR_NOERROR; 151 151 } … … 205 205 if(HMHandleAllocate(&timerID, (ULONG)timer) != NO_ERROR) { 206 206 dprintf(("HMHandleAllocate failed!!")); 207 delete timer;207 timer->release(); 208 208 return 0; 209 209 } … … 213 213 { 214 214 dprintf(("WINMM:timeSetEvent: couldn't start timer!\n")); 215 delete(timer);215 timer->release(); 216 216 return(0); 217 217 } -
trunk/src/winmm/waveinoutbase.cpp
r9902 r10269 1 /* $Id: waveinoutbase.cpp,v 1. 6 2003-03-05 14:49:04sandervl Exp $ */1 /* $Id: waveinoutbase.cpp,v 1.7 2003-10-13 09:18:38 sandervl Exp $ */ 2 2 3 3 /* … … 100 100 void WaveInOut::callback(UINT uMessage, DWORD dw1, DWORD dw2) 101 101 { 102 dprintf(("WINMM:WaveInOut::callback type %x (HDRVR h=%08xh, UINT uMessage=%08xh, DWORD dwUser=%08xh, DWORD dw1=%08xh, DWORD dw2=%08xh)\n",103 fdwOpen, this, uMessage, dwInstance, dw1, dw2));102 dprintf(("WINMM:WaveInOut::callback type %x, callback 0x%x (HDRVR h=%08xh, UINT uMessage=%08xh, DWORD dwUser=%08xh, DWORD dw1=%08xh, DWORD dw2=%08xh)", 103 fdwOpen, dwCallback, this, uMessage, dwInstance, dw1, dw2)); 104 104 105 105 switch(fdwOpen & CALLBACK_TYPEMASK) { … … 118 118 LPDRVCALLBACK mthdCallback = (LPDRVCALLBACK)dwCallback; 119 119 120 selCallback = GetProcessTIBSel(); 120 if(selTIB == SELECTOR_OS2_FS) { 121 selCallback = GetProcessTIBSel(); 122 } 123 else selCallback = selTIB; 121 124 122 125 //TODO: may not be very safe. perhaps we should allocate a new TIB for the DART thread or let another thread do the actual callback … … 125 128 SetFS(selCallback); // switch to callback win32 tib selector (stored in WaveInOutOpen) 126 129 127 //@@@PH 1999/12/28 Shockwave Flash esseem to make assumptions on a130 //@@@PH 1999/12/28 Shockwave Flash seem to make assumptions on a 128 131 // specific stack layout. Do we have the correct calling convention here? 129 132 mthdCallback((HDRVR)this, uMessage, dwInstance, dw1, dw2); -
trunk/src/winmm/waveoutdart.cpp
r9982 r10269 1 /* $Id: waveoutdart.cpp,v 1.2 2 2003-04-03 14:04:50sandervl Exp $ */1 /* $Id: waveoutdart.cpp,v 1.23 2003-10-13 09:18:38 sandervl Exp $ */ 2 2 3 3 /*
Note:
See TracChangeset
for help on using the changeset viewer.