Leaked source code of windows server 2003
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.

833 lines
24 KiB

  1. /******************************************************************************
  2. Copyright (C) Microsoft Corporation 1985-1991. All rights reserved.
  3. Title: graphic.c - Multimedia Systems Media Control Interface
  4. driver for AVI.
  5. *****************************************************************************/
  6. #include <win32.h>
  7. #include <mmddk.h>
  8. #include <vfw.h>
  9. #include "common.h"
  10. #include "digitalv.h"
  11. #include "mciavi.h"
  12. HANDLE ghModule;
  13. typedef DWORD NPMCIGRAPHIC;
  14. #define MCIAVI_PRODUCTNAME 2
  15. #define MCIAVI_VERSION 3
  16. BOOL FAR PASCAL GraphicInit (void);
  17. BOOL NEAR PASCAL GraphicWindowInit (void);
  18. void PASCAL GraphicFree (void);
  19. DWORD PASCAL GraphicDrvOpen (LPMCI_OPEN_DRIVER_PARMS lpParms);
  20. void FAR PASCAL GraphicDelayedNotify (NPMCIGRAPHIC npMCI, UINT wStatus);
  21. void FAR PASCAL GraphicImmediateNotify (UINT wDevID,
  22. LPMCI_GENERIC_PARMS lpParms,
  23. DWORD dwFlags, DWORD dwErr);
  24. DWORD PASCAL GraphicClose(NPMCIGRAPHIC npMCI);
  25. DWORD PASCAL GraphicOpen (NPMCIGRAPHIC FAR * lpnpMCI, DWORD dwFlags,
  26. LPMCI_DGV_OPEN_PARMS lpOpen, UINT wDeviceID);
  27. DWORD FAR PASCAL GraphicInfo(NPMCIGRAPHIC npMCI, DWORD dwFlags,
  28. LPMCI_DGV_INFO_PARMS lpInfo);
  29. DWORD FAR PASCAL GraphicPlay (NPMCIGRAPHIC npMCI, DWORD dwFlags,
  30. LPMCI_PLAY_PARMS lpPlay );
  31. DWORD FAR PASCAL GraphicCue(NPMCIGRAPHIC npMCI, DWORD dwFlags,
  32. LPMCI_DGV_CUE_PARMS lpCue);
  33. DWORD FAR PASCAL GraphicStep (NPMCIGRAPHIC npMCI, DWORD dwFlags,
  34. LPMCI_DGV_STEP_PARMS lpStep);
  35. DWORD FAR PASCAL GraphicStop (NPMCIGRAPHIC npMCI, DWORD dwFlags,
  36. LPMCI_GENERIC_PARMS lpParms);
  37. DWORD FAR PASCAL GraphicSeek (NPMCIGRAPHIC npMCI, DWORD dwFlags,
  38. LPMCI_SEEK_PARMS lpSeek);
  39. DWORD FAR PASCAL GraphicPause(NPMCIGRAPHIC npMCI, DWORD dwFlags,
  40. LPMCI_GENERIC_PARMS lpParms);
  41. DWORD FAR PASCAL GraphicStatus (NPMCIGRAPHIC npMCI,
  42. DWORD dwFlags, LPMCI_DGV_STATUS_PARMS lpStatus);
  43. DWORD FAR PASCAL GraphicSet (NPMCIGRAPHIC npMCI,
  44. DWORD dwFlags, LPMCI_DGV_SET_PARMS lpSet);
  45. DWORD FAR PASCAL GraphicResume (NPMCIGRAPHIC npMCI,
  46. DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms);
  47. DWORD FAR PASCAL GraphicRealize(NPMCIGRAPHIC npMCI, DWORD dwFlags);
  48. DWORD FAR PASCAL GraphicUpdate(NPMCIGRAPHIC npMCI, DWORD dwFlags,
  49. LPMCI_DGV_UPDATE_PARMS lpParms);
  50. DWORD FAR PASCAL GraphicWindow (NPMCIGRAPHIC npMCI, DWORD dwFlags,
  51. LPMCI_DGV_WINDOW_PARMS lpWindow);
  52. DWORD FAR PASCAL GraphicConfig(NPMCIGRAPHIC npMCI, DWORD dwFlags);
  53. DWORD FAR PASCAL GraphicSetAudio (NPMCIGRAPHIC npMCI,
  54. DWORD dwFlags, LPMCI_DGV_SETAUDIO_PARMS lpSet);
  55. DWORD FAR PASCAL GraphicSetVideo (NPMCIGRAPHIC npMCI,
  56. DWORD dwFlags, LPMCI_DGV_SETVIDEO_PARMS lpSet);
  57. DWORD FAR PASCAL GraphicSignal(NPMCIGRAPHIC npMCI,
  58. DWORD dwFlags, LPMCI_DGV_SIGNAL_PARMS lpSignal);
  59. DWORD FAR PASCAL GraphicWhere(NPMCIGRAPHIC npMCI, DWORD dwFlags,
  60. LPMCI_DGV_RECT_PARMS lpParms);
  61. DWORD FAR PASCAL GraphicPut ( NPMCIGRAPHIC npMCI,
  62. DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms);
  63. BOOL FAR PASCAL ConfigDialog(HWND hwnd, NPMCIGRAPHIC npMCI);
  64. DWORD PASCAL mciDriverEntry(UINT wDeviceID, UINT wMessage, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms);
  65. void CheckWindowMove(NPMCIGRAPHIC npMCI, BOOL fForce);
  66. /* statics */
  67. static INT swCommandTable = -1;
  68. /***************************************************************************
  69. *
  70. * @doc INTERNAL MCIAVI
  71. *
  72. * @api DWORD | GraphicDrvOpen | This function is called when the DriverProc
  73. * gets a DRV_OPEN message. This happens each time that a new movie
  74. * is opened thru MCI.
  75. *
  76. * @parm LPMCI_OPEN_DRIVER_PARMS | lpOpen | Far pointer to the standard
  77. * MCI open parameters
  78. *
  79. * @rdesc Returns the mci device id. The installable driver interface will
  80. * pass this ID to the DriverProc in the dwDriverID parameter on all
  81. * subsequent messages. To fail the open, return 0L.
  82. *
  83. ***************************************************************************/
  84. DWORD PASCAL GraphicDrvOpen(LPMCI_OPEN_DRIVER_PARMS lpOpen)
  85. {
  86. /* Specify the custom command table and the device type */
  87. lpOpen->wCustomCommandTable = swCommandTable;
  88. lpOpen->wType = MCI_DEVTYPE_DIGITAL_VIDEO;
  89. /* Set the device ID to the MCI Device ID */
  90. return (DWORD) (UINT)lpOpen->wDeviceID;
  91. }
  92. /***************************************************************************
  93. *
  94. * @doc INTERNAL MCIAVI
  95. *
  96. * @api void | GraphicFree | This function is called when the DriverProc
  97. * gets a DRV_FREE message. This happens when the drivers open count
  98. * reaches 0.
  99. *
  100. ***************************************************************************/
  101. void PASCAL GraphicFree16(void)
  102. {
  103. if (swCommandTable != -1) {
  104. mciFreeCommandResource(swCommandTable);
  105. swCommandTable = -1;
  106. }
  107. GraphicFree();
  108. }
  109. /***************************************************************************
  110. *
  111. * @doc INTERNAL MCIAVI
  112. *
  113. * @api DWORD | GraphicInfo | This function returns alphanumeric information.
  114. *
  115. * @parm NPMCIGRAPHIC | npMCI | Near pointer to instance data block
  116. *
  117. * @parm DWORD | dwFlags | Flags for the info. message.
  118. *
  119. * @parm LPMCI_INFO_PARMS | lpPlay | Parameters for the info message.
  120. *
  121. * @rdesc Returns an MCI error code.
  122. *
  123. ***************************************************************************/
  124. DWORD NEAR PASCAL GraphicInfo16(NPMCIGRAPHIC npMCI, DWORD dwFlags,
  125. LPMCI_DGV_INFO_PARMS lpInfo)
  126. {
  127. DWORD dwRet = 0L;
  128. TCHAR ch = TEXT('\0');
  129. BOOL fTest = FALSE;
  130. if (!lpInfo->lpstrReturn)
  131. return MCIERR_PARAM_OVERFLOW;
  132. if (dwFlags & MCI_TEST)
  133. fTest = TRUE;
  134. dwFlags &= ~(MCI_WAIT | MCI_NOTIFY | MCI_TEST);
  135. switch (dwFlags) {
  136. case 0L:
  137. return MCIERR_MISSING_PARAMETER;
  138. /* !!! Not returning PARAM_OVERFLOW here but I am above - lazy eh */
  139. LoadString(ghModule, MCIAVI_PRODUCTNAME, lpInfo->lpstrReturn,
  140. (UINT)lpInfo->dwRetSize);
  141. break;
  142. case MCI_INFO_VERSION:
  143. /* !!! Not returning PARAM_OVERFLOW here but I am above - lazy eh */
  144. LoadString(ghModule, MCIAVI_VERSION, lpInfo->lpstrReturn,
  145. (UINT)lpInfo->dwRetSize);
  146. break;
  147. case MCI_DGV_INFO_USAGE:
  148. dwRet = MCIERR_UNSUPPORTED_FUNCTION;
  149. break;
  150. case MCI_DGV_INFO_ITEM:
  151. switch (lpInfo->dwItem) {
  152. case MCI_DGV_INFO_AUDIO_QUALITY:
  153. case MCI_DGV_INFO_VIDEO_QUALITY:
  154. case MCI_DGV_INFO_STILL_QUALITY:
  155. case MCI_DGV_INFO_AUDIO_ALG:
  156. case MCI_DGV_INFO_VIDEO_ALG:
  157. case MCI_DGV_INFO_STILL_ALG:
  158. default:
  159. dwRet = MCIERR_UNSUPPORTED_FUNCTION;
  160. break;
  161. }
  162. break;
  163. default:
  164. dwRet = MCIERR_FLAGS_NOT_COMPATIBLE;
  165. break;
  166. }
  167. if (fTest && (LOWORD(dwRet) == 0)) {
  168. /* There is no error, but the test flag is on. Return as little
  169. ** as possible.
  170. */
  171. dwRet = 0;
  172. if (lpInfo->dwRetSize)
  173. lpInfo->lpstrReturn[0] = '\0';
  174. }
  175. return dwRet;
  176. }
  177. /***************************************************************************
  178. *
  179. * @doc INTERNAL MCIAVI
  180. *
  181. * @api DWORD | GraphicList | This function supports the MCI_LIST command.
  182. *
  183. * @parm NPMCIGRAPHIC | npMCI | Near pointer to instance data block
  184. *
  185. * @parm DWORD | dwFlags | Flags for the List message.
  186. *
  187. * @parm LPMCI_DGV_LIST_PARMS | lpList | Parameters for the list message.
  188. *
  189. * @rdesc Returns an MCI error code.
  190. *
  191. ***************************************************************************/
  192. DWORD NEAR PASCAL GraphicList(NPMCIGRAPHIC npMCI,
  193. DWORD dwFlags, LPMCI_DGV_LIST_PARMS lpList)
  194. {
  195. return MCIERR_UNSUPPORTED_FUNCTION;
  196. }
  197. /***************************************************************************
  198. *
  199. * @doc INTERNAL MCIAVI
  200. *
  201. * @api DWORD | GraphicGetDevCaps | This function returns device
  202. * capabilities
  203. *
  204. * @parm NPMCIGRAPHIC | npMCI | Near pointer to instance data block
  205. *
  206. * @parm DWORD | dwFlags | Flags for the GetDevCaps message.
  207. *
  208. * @parm LPMCI_GETDEVCAPS_PARMS | lpCaps | Parameters for the GetDevCaps
  209. * message.
  210. *
  211. * @rdesc Returns an MCI error code.
  212. *
  213. ***************************************************************************/
  214. DWORD NEAR PASCAL GraphicGetDevCaps (NPMCIGRAPHIC npMCI,
  215. DWORD dwFlags, LPMCI_GETDEVCAPS_PARMS lpCaps )
  216. {
  217. DWORD dwRet = 0L;
  218. if (dwFlags & MCI_GETDEVCAPS_ITEM)
  219. {
  220. switch (lpCaps->dwItem)
  221. {
  222. case MCI_GETDEVCAPS_CAN_RECORD:
  223. case MCI_GETDEVCAPS_CAN_EJECT:
  224. case MCI_GETDEVCAPS_CAN_SAVE:
  225. case MCI_DGV_GETDEVCAPS_CAN_LOCK:
  226. case MCI_DGV_GETDEVCAPS_CAN_STR_IN:
  227. case MCI_DGV_GETDEVCAPS_CAN_FREEZE:
  228. case MCI_DGV_GETDEVCAPS_HAS_STILL:
  229. lpCaps->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
  230. dwRet = MCI_RESOURCE_RETURNED;
  231. break;
  232. case MCI_DGV_GETDEVCAPS_CAN_REVERSE:
  233. case MCI_GETDEVCAPS_CAN_PLAY:
  234. case MCI_GETDEVCAPS_HAS_AUDIO:
  235. case MCI_GETDEVCAPS_HAS_VIDEO:
  236. case MCI_GETDEVCAPS_USES_FILES:
  237. case MCI_GETDEVCAPS_COMPOUND_DEVICE:
  238. case MCI_DGV_GETDEVCAPS_PALETTES:
  239. case MCI_DGV_GETDEVCAPS_CAN_STRETCH:
  240. case MCI_DGV_GETDEVCAPS_CAN_TEST:
  241. lpCaps->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
  242. dwRet = MCI_RESOURCE_RETURNED;
  243. break;
  244. case MCI_GETDEVCAPS_DEVICE_TYPE:
  245. lpCaps->dwReturn = MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO,
  246. MCI_DEVTYPE_DIGITAL_VIDEO);
  247. dwRet = MCI_RESOURCE_RETURNED;
  248. break;
  249. case MCI_DGV_GETDEVCAPS_MAX_WINDOWS:
  250. case MCI_DGV_GETDEVCAPS_MAXIMUM_RATE:
  251. case MCI_DGV_GETDEVCAPS_MINIMUM_RATE:
  252. default:
  253. dwRet = MCIERR_UNSUPPORTED_FUNCTION;
  254. break;
  255. }
  256. }
  257. else
  258. dwRet = MCIERR_MISSING_PARAMETER;
  259. if ((dwFlags & MCI_TEST) && (LOWORD(dwRet) == 0)) {
  260. /* There is no error, but the test flag is on. Return as little
  261. ** as possible.
  262. */
  263. dwRet = 0;
  264. lpCaps->dwReturn = 0;
  265. }
  266. return (dwRet);
  267. }
  268. /***************************************************************************
  269. *
  270. * @doc INTERNAL MCIAVI
  271. *
  272. * @api DWORD | mciSpecial | This function handles all the MCI
  273. * commands that don't require instance data such as open.
  274. *
  275. * @parm UINT | wDeviceID | The MCI device ID
  276. *
  277. * @parm UINT | wMessage | The requested action to be performed.
  278. *
  279. * @parm DWORD | dwFlags | Flags for the message.
  280. *
  281. * @parm DWORD | lpParms | Parameters for this message.
  282. *
  283. * @rdesc Error Constant. 0L on success
  284. *
  285. ***************************************************************************/
  286. DWORD NEAR PASCAL mciSpecial (UINT wDeviceID, UINT wMessage, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
  287. {
  288. NPMCIGRAPHIC npMCI = 0L;
  289. DWORD dwRet;
  290. /* since there in no instance block, there is no saved notification */
  291. /* to abort. */
  292. switch (wMessage) {
  293. case MCI_OPEN_DRIVER:
  294. if (dwFlags & (MCI_OPEN_ELEMENT | MCI_OPEN_ELEMENT_ID))
  295. dwRet = GraphicOpen (&npMCI, dwFlags,
  296. (LPMCI_DGV_OPEN_PARMS) lpParms, wDeviceID);
  297. else
  298. dwRet = 0L;
  299. mciSetDriverData (wDeviceID, (UINT)npMCI);
  300. break;
  301. case MCI_GETDEVCAPS:
  302. dwRet = GraphicGetDevCaps(NULL, dwFlags,
  303. (LPMCI_GETDEVCAPS_PARMS)lpParms);
  304. break;
  305. case MCI_CONFIGURE:
  306. if (!(dwFlags & MCI_TEST))
  307. ConfigDialog(NULL, NULL);
  308. dwRet = 0L;
  309. break;
  310. case MCI_INFO:
  311. dwRet = GraphicInfo16(NULL, dwFlags, (LPMCI_DGV_INFO_PARMS)lpParms);
  312. break;
  313. case MCI_CLOSE_DRIVER:
  314. dwRet = 0L;
  315. break;
  316. default:
  317. dwRet = MCIERR_UNSUPPORTED_FUNCTION;
  318. break;
  319. }
  320. GraphicImmediateNotify (wDeviceID, lpParms, dwFlags, dwRet);
  321. return (dwRet);
  322. }
  323. /***************************************************************************
  324. *
  325. * @doc INTERNAL MCIAVI
  326. *
  327. * @api DWORD | mciDriverEntry | This function is the MCI handler
  328. *
  329. * @parm UINT | wDeviceID | The MCI device ID
  330. *
  331. * @parm UINT | wMessage | The requested action to be performed.
  332. *
  333. * @parm DWORD | dwFlags | Flags for the message.
  334. *
  335. * @parm DWORD | lpParms | Parameters for this message.
  336. *
  337. * @rdesc Error Constant. 0L on success
  338. *
  339. ***************************************************************************/
  340. DWORD PASCAL mciDriverEntry (UINT wDeviceID, UINT wMessage, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
  341. {
  342. NPMCIGRAPHIC npMCI = 0L;
  343. DWORD dwRet = MCIERR_UNRECOGNIZED_COMMAND;
  344. BOOL fDelayed = FALSE;
  345. BOOL fNested = FALSE;
  346. /* All current commands require a parameter block. */
  347. if (!lpParms && (dwFlags & MCI_NOTIFY))
  348. return (MCIERR_MISSING_PARAMETER);
  349. npMCI = (NPMCIGRAPHIC) (UINT)mciGetDriverData(wDeviceID);
  350. if (!npMCI)
  351. return mciSpecial(wDeviceID, wMessage, dwFlags, lpParms);
  352. #if 0
  353. #ifdef DEBUG
  354. else
  355. Assert(npMCI->mciid == MCIID);
  356. #endif
  357. if (npMCI->wMessageCurrent) {
  358. fNested = TRUE;
  359. if (wMessage != MCI_STATUS && wMessage != MCI_GETDEVCAPS &&
  360. wMessage != MCI_INFO) {
  361. //DPF(("Warning!!!!!\n"));
  362. //DPF(("Warning!!!!! MCIAVI reentered: received %x while processing %x\n", wMessage, npMCI->wMessageCurrent));
  363. //DPF(("Warning!!!!!\n"));
  364. // Assert(0);
  365. // return MCIERR_DEVICE_NOT_READY;
  366. }
  367. } else
  368. npMCI->wMessageCurrent = wMessage;
  369. #endif
  370. switch (wMessage) {
  371. case MCI_CLOSE_DRIVER:
  372. // Question: Should we set the driver data to NULL
  373. // before closing the device? It would seem the right order.
  374. // So... we have moved this line before the call to GraphicClose
  375. mciSetDriverData(wDeviceID, 0L);
  376. // note that GraphicClose will release and delete the critsec
  377. dwRet = GraphicClose(npMCI);
  378. npMCI = NULL;
  379. break;
  380. case MCI_PLAY:
  381. dwRet = GraphicPlay(npMCI, dwFlags, (LPMCI_PLAY_PARMS)lpParms);
  382. fDelayed = TRUE;
  383. break;
  384. case MCI_CUE:
  385. dwRet = GraphicCue(npMCI, dwFlags, (LPMCI_DGV_CUE_PARMS)lpParms);
  386. fDelayed = TRUE;
  387. break;
  388. case MCI_STEP:
  389. dwRet = GraphicStep(npMCI, dwFlags, (LPMCI_DGV_STEP_PARMS)lpParms);
  390. fDelayed = TRUE;
  391. break;
  392. case MCI_STOP:
  393. dwRet = GraphicStop(npMCI, dwFlags, lpParms);
  394. break;
  395. case MCI_SEEK:
  396. dwRet = GraphicSeek (npMCI, dwFlags, (LPMCI_SEEK_PARMS)lpParms);
  397. fDelayed = TRUE;
  398. break;
  399. case MCI_PAUSE:
  400. dwRet = GraphicPause(npMCI, dwFlags, lpParms);
  401. fDelayed = TRUE;
  402. break;
  403. case MCI_RESUME:
  404. dwRet = GraphicResume(npMCI, dwFlags, lpParms);
  405. fDelayed = TRUE;
  406. break;
  407. case MCI_SET:
  408. dwRet = GraphicSet(npMCI, dwFlags,
  409. (LPMCI_DGV_SET_PARMS)lpParms);
  410. break;
  411. case MCI_STATUS:
  412. dwRet = GraphicStatus(npMCI, dwFlags,
  413. (LPMCI_DGV_STATUS_PARMS)lpParms);
  414. break;
  415. case MCI_INFO:
  416. dwRet = GraphicInfo (npMCI, dwFlags, (LPMCI_DGV_INFO_PARMS)lpParms);
  417. break;
  418. case MCI_GETDEVCAPS:
  419. dwRet = GraphicGetDevCaps(npMCI, dwFlags, (LPMCI_GETDEVCAPS_PARMS)lpParms);
  420. break;
  421. case MCI_REALIZE:
  422. dwRet = GraphicRealize(npMCI, dwFlags);
  423. break;
  424. case MCI_UPDATE:
  425. dwRet = GraphicUpdate(npMCI, dwFlags, (LPMCI_DGV_UPDATE_PARMS)lpParms);
  426. break;
  427. case MCI_WINDOW:
  428. dwRet = GraphicWindow(npMCI, dwFlags, (LPMCI_DGV_WINDOW_PARMS)lpParms);
  429. break;
  430. case MCI_PUT:
  431. dwRet = GraphicPut(npMCI, dwFlags, (LPMCI_DGV_RECT_PARMS)lpParms);
  432. break;
  433. case MCI_WHERE:
  434. dwRet = GraphicWhere(npMCI, dwFlags, (LPMCI_DGV_RECT_PARMS)lpParms);
  435. break;
  436. case MCI_CONFIGURE:
  437. dwRet = GraphicConfig(npMCI, dwFlags);
  438. break;
  439. case MCI_SETAUDIO:
  440. dwRet = GraphicSetAudio(npMCI, dwFlags,
  441. (LPMCI_DGV_SETAUDIO_PARMS) lpParms);
  442. break;
  443. case MCI_SETVIDEO:
  444. dwRet = GraphicSetVideo(npMCI, dwFlags,
  445. (LPMCI_DGV_SETVIDEO_PARMS) lpParms);
  446. break;
  447. case MCI_SIGNAL:
  448. dwRet = GraphicSignal(npMCI, dwFlags,
  449. (LPMCI_DGV_SIGNAL_PARMS) lpParms);
  450. break;
  451. case MCI_LIST:
  452. dwRet = GraphicList(npMCI, dwFlags,
  453. (LPMCI_DGV_LIST_PARMS) lpParms);
  454. break;
  455. #if 0
  456. case MCI_LOAD:
  457. dwRet = GraphicLoad(npMCI, dwFlags,
  458. (LPMCI_DGV_LOAD_PARMS) lpParms);
  459. break;
  460. #endif
  461. case MCI_RECORD:
  462. case MCI_SAVE:
  463. case MCI_CUT:
  464. case MCI_COPY:
  465. case MCI_PASTE:
  466. case MCI_UNDO:
  467. case MCI_DELETE:
  468. case MCI_CAPTURE:
  469. case MCI_QUALITY:
  470. case MCI_MONITOR:
  471. case MCI_RESERVE:
  472. case MCI_FREEZE:
  473. case MCI_UNFREEZE:
  474. dwRet = MCIERR_UNSUPPORTED_FUNCTION;
  475. break;
  476. /* Do we need this case? */
  477. default:
  478. dwRet = MCIERR_UNRECOGNIZED_COMMAND;
  479. break;
  480. }
  481. if (!fDelayed || (dwFlags & MCI_TEST)) {
  482. /* We haven't processed the notify yet. */
  483. if (npMCI && (dwFlags & MCI_NOTIFY) && (!LOWORD(dwRet)))
  484. /* Throw away the old notify */
  485. GraphicDelayedNotify(npMCI, MCI_NOTIFY_SUPERSEDED);
  486. /* And send the new one out immediately. */
  487. GraphicImmediateNotify(wDeviceID, lpParms, dwFlags, dwRet);
  488. }
  489. if (npMCI) {
  490. /* Everything from here on relies on npMCI still being around */
  491. #if 0
  492. /* If there's an error, don't save the callback.... */
  493. if (fDelayed && dwRet != 0 && (dwFlags & MCI_NOTIFY)) {
  494. // this might be too late, of course, but shouldn't do
  495. // any harm
  496. npMCI->hCallback = 0;
  497. }
  498. //
  499. // see if we need to tell the DRAW device about moving.
  500. // MPlayer is sending the status and position command alot
  501. // so this is a "timer"
  502. //
  503. // !!!do we need to do it this often?
  504. //
  505. if (npMCI->dwFlags & MCIAVI_WANTMOVE)
  506. CheckWindowMove(npMCI, FALSE);
  507. if (!fNested)
  508. npMCI->wMessageCurrent = 0;
  509. #endif
  510. }
  511. return dwRet;
  512. }
  513. #define CONFIG_ID 10000L // Use the hiword of dwDriverID to identify
  514. extern HWND ghwndConfig;
  515. /* Link to DefDriverProc in MMSystem explicitly, so we don't get the
  516. ** one in USER by mistake.
  517. */
  518. #ifndef _WIN32
  519. extern DWORD FAR PASCAL mmDefDriverProc(DWORD, HANDLE, UINT, DWORD, DWORD);
  520. #else
  521. #define mmDefDriverProc DefDriverProc
  522. #endif
  523. #ifndef _WIN32
  524. BOOL FAR PASCAL LibMain (HANDLE hModule, int cbHeap, LPSTR lpchCmdLine)
  525. {
  526. ghModule = hModule;
  527. return TRUE;
  528. }
  529. #else
  530. #if 0
  531. // Get the module handle on DRV_LOAD
  532. BOOL DllInstanceInit(PVOID hModule, ULONG Reason, PCONTEXT pContext)
  533. {
  534. if (Reason == DLL_PROCESS_ATTACH) {
  535. ghModule = hModule; // All we need to save is our module handle...
  536. } else {
  537. if (Reason == DLL_PROCESS_DETACH) {
  538. }
  539. }
  540. return TRUE;
  541. }
  542. #endif
  543. #endif // WIN16
  544. /***************************************************************************
  545. *
  546. * @doc INTERNAL
  547. *
  548. * @api DWORD | DriverProc | The entry point for an installable driver.
  549. *
  550. * @parm DWORD | dwDriverId | For most messages, dwDriverId is the DWORD
  551. * value that the driver returns in response to a DRV_OPEN message.
  552. * Each time that the driver is opened, through the DrvOpen API,
  553. * the driver receives a DRV_OPEN message and can return an
  554. * arbitrary, non-zero, value. The installable driver interface
  555. * saves this value and returns a unique driver handle to the
  556. * application. Whenever the application sends a message to the
  557. * driver using the driver handle, the interface routes the message
  558. * to this entry point and passes the corresponding dwDriverId.
  559. *
  560. * This mechanism allows the driver to use the same or different
  561. * identifiers for multiple opens but ensures that driver handles
  562. * are unique at the application interface layer.
  563. *
  564. * The following messages are not related to a particular open
  565. * instance of the driver. For these messages, the dwDriverId
  566. * will always be ZERO.
  567. *
  568. * DRV_LOAD, DRV_FREE, DRV_ENABLE, DRV_DISABLE, DRV_OPEN
  569. *
  570. * @parm UINT | wMessage | The requested action to be performed. Message
  571. * values below DRV_RESERVED are used for globally defined messages.
  572. * Message values from DRV_RESERVED to DRV_USER are used for
  573. * defined driver portocols. Messages above DRV_USER are used
  574. * for driver specific messages.
  575. *
  576. * @parm DWORD | dwParam1 | Data for this message. Defined separately for
  577. * each message
  578. *
  579. * @parm DWORD | dwParam2 | Data for this message. Defined separately for
  580. * each message
  581. *
  582. * @rdesc Defined separately for each message.
  583. *
  584. ***************************************************************************/
  585. DWORD FAR PASCAL _LOADDS DriverProc (DWORD dwDriverID, HANDLE hDriver, UINT wMessage,
  586. DWORD dwParam1, DWORD dwParam2)
  587. {
  588. DWORD dwRes = 0L;
  589. /*
  590. * critical sections are now per-device. This means they
  591. * cannot be held around the whole driver-proc, since until we open
  592. * the device, we don't have a critical section to hold.
  593. * The critical section is allocated in mciSpecial on opening. It is
  594. * also held in mciDriverEntry, in GraphicWndProc, and around
  595. * all worker thread draw functions.
  596. */
  597. switch (wMessage)
  598. {
  599. // Standard, globally used messages.
  600. case DRV_LOAD:
  601. #ifdef _WIN32
  602. if (ghModule) {
  603. Assert(!"Did not expect ghModule to be non-NULL");
  604. }
  605. ghModule = GetDriverModuleHandle(hDriver); // Remember
  606. #define GET_MAPPING_MODULE_NAME TEXT("wow32.dll")
  607. runningInWow = (GetModuleHandle(GET_MAPPING_MODULE_NAME) != NULL);
  608. #endif
  609. if (GraphicInit()) // Initialize graphic mgmt.
  610. dwRes = 1L;
  611. else
  612. dwRes = 0L;
  613. break;
  614. case DRV_FREE:
  615. GraphicFree16();
  616. dwRes = 1L;
  617. //DPF(("Returning from DRV_FREE\n"));
  618. #if 0
  619. Assert(npMCIList == NULL);
  620. #endif
  621. ghModule = NULL;
  622. break;
  623. case DRV_OPEN:
  624. if (!dwParam2)
  625. dwRes = CONFIG_ID;
  626. else
  627. dwRes = GraphicDrvOpen((LPMCI_OPEN_DRIVER_PARMS)dwParam2);
  628. break;
  629. case DRV_CLOSE:
  630. /* If we have a configure dialog up, fail the close.
  631. ** Otherwise, we'll be unloaded while we still have the
  632. ** configuration window up.
  633. */
  634. #if 0
  635. if (ghwndConfig)
  636. dwRes = 0L;
  637. else
  638. #endif
  639. dwRes = 1L;
  640. break;
  641. case DRV_ENABLE:
  642. dwRes = 1L;
  643. break;
  644. case DRV_DISABLE:
  645. dwRes = 1L;
  646. break;
  647. case DRV_QUERYCONFIGURE:
  648. dwRes = 1L; /* Yes, we can be configured */
  649. break;
  650. case DRV_CONFIGURE:
  651. ConfigDialog((HWND)(UINT)dwParam1, NULL);
  652. dwRes = 1L;
  653. break;
  654. default:
  655. if (!HIWORD(dwDriverID) &&
  656. wMessage >= DRV_MCI_FIRST &&
  657. wMessage <= DRV_MCI_LAST)
  658. dwRes = mciDriverEntry ((UINT)dwDriverID,
  659. wMessage,
  660. dwParam1,
  661. (LPMCI_GENERIC_PARMS)dwParam2);
  662. else
  663. dwRes = mmDefDriverProc(dwDriverID,
  664. hDriver,
  665. wMessage,
  666. dwParam1,
  667. dwParam2);
  668. break;
  669. }
  670. return dwRes;
  671. }