Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
11 KiB

  1. /***************************************************************************
  2. * mci.h
  3. *
  4. * Copyright (c) 1990-1998 Microsoft Corporation
  5. *
  6. * private include file
  7. *
  8. * History
  9. *
  10. * 17 Mar 92 - SteveDav - private file for MCI use
  11. * 30 Apr 92 - StephenE - Converted to Unicode
  12. *
  13. ***************************************************************************/
  14. extern CRITICAL_SECTION mciCritSec; // used to protect process global mci variables
  15. extern UINT cmciCritSec; // enter'ed count
  16. extern UINT uCritSecOwner; // thread id of critical section owner
  17. #define IDI_MCIHWND 100
  18. #define MCI_GLOBAL_PROCESS "MCIHWND.EXE"
  19. #define MCI_SERVER_NAME "MMSNDSRV"
  20. #define SND_FREE 0x80000000
  21. #ifndef DOSWIN32
  22. BOOL ServerInit(VOID);
  23. #endif
  24. extern BOOL CreatehwndNotify(VOID);
  25. #if DBG
  26. // Use mciCheckIn to check that we are within the critical section,
  27. // mciCheckOut that we are not in the critical section. Neither
  28. // routine does anything on the free build.
  29. #define mciCheckIn() (WinAssert(uCritSecOwner==GetCurrentThreadId()))
  30. #define mciCheckOut() (WinAssert(uCritSecOwner!=GetCurrentThreadId()))
  31. #define mciEnter(id) dprintf4(("Entering MCI crit sec at %s Current count is %d", id, cmciCritSec)); \
  32. EnterCriticalSection(&mciCritSec), \
  33. uCritSecOwner=GetCurrentThreadId(), \
  34. ++cmciCritSec
  35. #define mciLeave(id) dprintf4(("Leaving MCI crit sec at %s", id)); mciCheckIn(); if(!--cmciCritSec) uCritSecOwner=0; LeaveCriticalSection(&mciCritSec)
  36. #else
  37. // No counting or messages in the retail build
  38. #define mciCheckIn()
  39. #define mciCheckOut()
  40. #define mciEnter(id) EnterCriticalSection(&mciCritSec)
  41. #define mciLeave(id) LeaveCriticalSection(&mciCritSec)
  42. #endif
  43. #define mciFirstEnter(id) { mciCheckOut(); mciEnter(id);}
  44. //
  45. // Define the name of a handler entry point
  46. //
  47. #define MCI_HANDLER_PROC_NAME "DriverProc"
  48. //
  49. // Typedef the entry routine for a driver
  50. //
  51. typedef LONG (HANDLERPROC)(DWORD dwId, UINT msg, LONG lp1, LONG lp2);
  52. typedef HANDLERPROC *LPHANDLERPROC;
  53. //
  54. // MCI driver info structure
  55. //
  56. #define MCI_HANDLER_KEY 0x49434D48 // "MCIH"
  57. typedef struct _MCIHANDLERINFO {
  58. DWORD dwKey;
  59. HANDLE hModule;
  60. LPHANDLERPROC lpHandlerProc;
  61. DWORD dwOpenId;
  62. } MCIHANDLERINFO, *LPMCIHANDLERINFO;
  63. #ifndef MMNOMCI
  64. #define SetMCIEvent(h) SetEvent(h);
  65. #define ResetMCIEvent(h) ResetEvent(h);
  66. #define LockMCIGlobal EnterCriticalSection(&mciGlobalCritSec);
  67. #define UnlockMCIGlobal LeaveCriticalSection(&mciGlobalCritSec);
  68. // Although having two unicode file name may make this structure fairly
  69. // large it is still less than a page.
  70. typedef struct tagGlobalMci {
  71. UINT msg; // Function required
  72. DWORD dwFlags; // sndPlaySound flags
  73. LPCWSTR lszSound; //
  74. WCHAR szSound[MAX_PATH]; //
  75. WCHAR szDefaultSound[MAX_PATH]; // Default sound
  76. } GLOBALMCI, * PGLOBALMCI;
  77. extern PGLOBALMCI base;
  78. extern HANDLE hEvent;
  79. /****************************************************************************
  80. MCI support
  81. ****************************************************************************/
  82. #define ID_CORE_TABLE 200
  83. #define MCI_VALID_DEVICE_ID(wID) ((wID) > 0 && (wID) < MCI_wNextDeviceID && MCI_lpDeviceList[wID])
  84. // Make sure that no MCI command has more than this number of DWORD parameters
  85. #define MCI_MAX_PARAM_SLOTS 20
  86. /******* WARNING ******** Ascii specific ************************************/
  87. #define MCI_TOLOWER(c) ((WCHAR)((c) >= 'A' && (c) <= 'Z' ? (c) + 0x20 : (c)))
  88. /****************************************************************************/
  89. typedef struct tagCOMMAND_TABLE_TYPE
  90. {
  91. HANDLE hResource;
  92. HANDLE hModule; /* If not NULL then free module */
  93. /* when device is free'd */
  94. UINT wType;
  95. PUINT lpwIndex;
  96. LPWSTR lpResource;
  97. #if DBG
  98. UINT wLockCount; /* Used for debugging */
  99. #endif
  100. } COMMAND_TABLE_TYPE;
  101. typedef struct tagMCI_DEVICE_NODE {
  102. LPWSTR lpstrName; /* The name used in subsequent calls to */
  103. /* mciSendString to refer to the device */
  104. LPWSTR lpstrInstallName;/* The device name from system.ini */
  105. DWORD dwMCIOpenFlags; /* Flags set on open may be: */
  106. /* MCI_OPEN_ELEMENT_ID */
  107. /* */
  108. DWORD_PTR lpDriverData; /* DWORD of driver instance data */
  109. DWORD dwElementID; /* The element ID set by MCI_OPEN_ELEMENT_ID */
  110. YIELDPROC fpYieldProc; /* The current yield procedure if any */
  111. DWORD dwYieldData; /* Data send to the current yield procedure */
  112. MCIDEVICEID wDeviceID; /* The ID used in subsequent calls to */
  113. /* mciSendCommand to refer to the device */
  114. UINT wDeviceType; /* The type returned from the DRV_OPEN call */
  115. /* MCI_OPEN_SHAREABLE */
  116. /* MCI_OPEN_ELEMENT_ID */
  117. UINT wCommandTable; /* The device type specific command table */
  118. UINT wCustomCommandTable; /* The custom device command table if */
  119. /* any (-1 if none) */
  120. HANDLE hDriver; /* Module instance handle for the driver */
  121. HTASK hCreatorTask; /* The task context the device is in */
  122. HTASK hOpeningTask; /* The task context which sent the open command */
  123. HANDLE hDrvDriver; /* The installable driver handle */
  124. DWORD dwMCIFlags; /* General flags for this node */
  125. } MCI_DEVICE_NODE;
  126. typedef MCI_DEVICE_NODE *LPMCI_DEVICE_NODE;
  127. /* Defines for dwMCIFlags */
  128. #define MCINODE_ISCLOSING 0x00000001 /* Set during close to lock out other commands */
  129. #define MCINODE_ISAUTOCLOSING 0x00010000 /* Set during auto-close to lock out other */
  130. /* commands except an internally generated close */
  131. #define MCINODE_ISAUTOOPENED 0x00020000 /* Device was auto opened */
  132. #define MCINODE_16BIT_DRIVER 0x80000000 // Device is a 16-bit driver
  133. // Macros for accessing the flag bits. Using macros is not normally my
  134. // idea of fun, but this case seems to be justified on the grounds of
  135. // being able to maintain control over who is accessing the flags values.
  136. // Note that the flag value are only needed in the header file.
  137. #define ISCLOSING(node) (((node)->dwMCIFlags) & MCINODE_ISCLOSING)
  138. #define ISAUTOCLOSING(node) (((node)->dwMCIFlags) & MCINODE_ISAUTOCLOSING)
  139. #define ISAUTOOPENED(node) (((node)->dwMCIFlags) & MCINODE_ISAUTOOPENED)
  140. #define SETAUTOCLOSING(node) (((node)->dwMCIFlags) |= MCINODE_ISAUTOCLOSING)
  141. #define SETISCLOSING(node) (((node)->dwMCIFlags) |= MCINODE_ISCLOSING)
  142. typedef struct {
  143. LPWSTR lpstrParams;
  144. LPWSTR *lpstrPointerList;
  145. HANDLE hCallingTask;
  146. UINT wParsingError;
  147. } MCI_INTERNAL_OPEN_INFO;
  148. typedef MCI_INTERNAL_OPEN_INFO *LPMCI_INTERNAL_OPEN_INFO;
  149. typedef struct tagMCI_SYSTEM_MESSAGE {
  150. LPWSTR lpstrCommand;
  151. DWORD dwAdditionalFlags; /* Used by mciAutoOpenDevice to request */
  152. /* Notify */
  153. LPWSTR lpstrReturnString;
  154. UINT uReturnLength;
  155. HANDLE hCallingTask;
  156. LPWSTR lpstrNewDirectory; /* The current directory of the calling */
  157. /* task - includes the drive letter */
  158. } MCI_SYSTEM_MESSAGE;
  159. typedef MCI_SYSTEM_MESSAGE *LPMCI_SYSTEM_MESSAGE;
  160. #define MCI_INIT_DEVICE_LIST_SIZE 4
  161. #define MCI_DEVICE_LIST_GROW_SIZE 4
  162. #define MAX_COMMAND_TABLES 20
  163. extern BOOL MCI_bDeviceListInitialized;
  164. extern LPMCI_DEVICE_NODE *MCI_lpDeviceList;
  165. extern UINT MCI_wDeviceListSize;
  166. extern MCIDEVICEID MCI_wNextDeviceID; /* the next device ID to use for a new device */
  167. extern COMMAND_TABLE_TYPE command_tables[MAX_COMMAND_TABLES];
  168. #define mciToLower(lpstrString) CharLower(lpstrString)
  169. extern BOOL mciGlobalInit(void);
  170. extern BOOL mciSoundInit(void);
  171. extern BOOL mciInitDeviceList(void);
  172. extern UINT mciOpenDevice( DWORD dwFlags,
  173. LPMCI_OPEN_PARMSW lpOpenParms,
  174. LPMCI_INTERNAL_OPEN_INFO lpOpenInfo);
  175. extern UINT mciCloseDevice( MCIDEVICEID wID, DWORD dwFlags,
  176. LPMCI_GENERIC_PARMS lpGeneric,
  177. BOOL bCloseDriver);
  178. extern UINT mciLoadTableType(UINT wType);
  179. extern LPWSTR FindCommandInTable (UINT wTable, LPCWSTR lpstrCommand,
  180. PUINT lpwMessage);
  181. extern UINT mciEatToken (LPCWSTR *lplpstrInput, WCHAR cSeparater,
  182. LPWSTR *lplpstrOutput, BOOL bMustFind);
  183. extern LPWSTR FindCommandItem (MCIDEVICEID wDeviceID, LPCWSTR lpstrType,
  184. LPCWSTR lpstrCommand, PUINT lpwMessage,
  185. PUINT lpwTable);
  186. extern UINT mciParseParams (UINT uMessage,
  187. LPCWSTR lpstrParams,
  188. LPCWSTR lpCommandList,
  189. LPDWORD lpdwFlags,
  190. LPWSTR lpOutputParams,
  191. UINT wParamsSize,
  192. LPWSTR **lpPointerList,
  193. PUINT lpwParsingError);
  194. extern UINT mciParseCommand (MCIDEVICEID wDeviceID,
  195. LPWSTR lpstrCommand,
  196. LPCWSTR lpstrDeviceName,
  197. LPWSTR *lpCommandList,
  198. PUINT lpwTable);
  199. extern VOID mciParserFree (LPWSTR *lpstrPointerList);
  200. extern UINT mciEatCommandEntry(LPCWSTR lpEntry, LPDWORD lpValue, PUINT lpID);
  201. extern UINT mciGetParamSize (DWORD dwValue, UINT wID);
  202. extern DWORD mciSysinfo (MCIDEVICEID wDeviceID, DWORD dwFlags,
  203. LPMCI_SYSINFO_PARMSW lpSysinfo);
  204. extern UINT mciLookUpType (LPCWSTR lpstrTypeName);
  205. extern BOOL mciExtractDeviceType (LPCWSTR lpstrDeviceName,
  206. LPWSTR lpstrDeviceType,
  207. UINT uBufLen);
  208. extern BOOL mciUnlockCommandTable (UINT wCommandTable);
  209. extern UINT mciSetBreakKey (MCIDEVICEID wDeviceID, int nVirtKey, HWND hwndTrap);
  210. /***************************************************************************
  211. MCI memory allocation
  212. ***************************************************************************/
  213. #define mciAlloc(cb) winmmAlloc((DWORD)(cb))
  214. #define mciReAlloc(ptr, cb) winmmReAlloc((PVOID)(ptr), (DWORD)(cb))
  215. #define mciFree(ptr) winmmFree((PVOID)(ptr))
  216. /*
  217. // Random stuff for MCI
  218. */
  219. extern DWORD mciRelaySystemString (LPMCI_SYSTEM_MESSAGE lpMessage);
  220. void MciNotify(DWORD wParam, LONG lParam); // in MCI.C
  221. #endif // MMNOMCI
  222. /*
  223. // Some defines introduced to avoid signed/unsigned compares - and to
  224. // remove the need for absolute constants in the code
  225. */
  226. #define MCI_ERROR_VALUE ((UINT)(-1))