Windows-Server-2003/multimedia/media/avi/mciavi.16/ntaviprt.h

52 lines
2.0 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************
Copyright (C) Microsoft Corporation 1991-1992. All rights reserved.
Title: ntaviprt.h - Definitions for the portable win16/32 version of AVI
*****************************************************************************/
#ifndef WIN32
#define EnterCrit(a)
#define LeaveCrit(a)
#else
/*
* we need to enter critical sections more than once on a thread
* (eg when handling a message that requires sending another message
* to the winproc). This is ok - the same thread can get a critical
* section more than once. BUT - we need to release it the same number
* of times.
*
* Problems occur in mciaviTaskWait when we release the critsec to yield
* - we don't know how many times to release it and enter it again.
*
* Solution: keep a count of how many times we are in the critsec. When
* entering, if the count is already > 0, increment it once more, and leave
* the critsec (ensuring that the count is protected, but the critsec is
* only one level deep). On leaving, only do a leave if the count reaches
* 0.
*
* NB: Critical sections are now defined per device, in the MCIGRAPHIC
* struct. This is needed to avoid critsec deadlocks when running multiple
* 16-bit apps (if a WOW thread yields in any way - and there are a lot
* of ways - while holding the critical section, and another WOW thread
* tries to get the critical section, WOW will hang, since it won't
* reschedule).
*/
#define EnterCrit(p) { EnterCriticalSection(&(p)->CritSec); \
if ((p)->lCritRefCount++ > 0) \
LeaveCriticalSection(&(p)->CritSec);\
}
#define LeaveCrit(p) { if (--(p)->lCritRefCount <= 0) { \
LeaveCriticalSection(&(p)->CritSec);\
Sleep(0); \
} \
}
#define IsGDIObject(obj) (GetObjectType((HGDIOBJ)(obj)) != 0)
#endif