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.

555 lines
16 KiB

  1. /*---------------------------------------------------------------------*\
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WMMEDIA3.C
  8. * WOW32 16-bit MultiMedia API support
  9. *
  10. * Contains:
  11. * Aux sound support apis
  12. * Joystick support apis
  13. *
  14. *
  15. * History:
  16. * Created 21-Jan-1992 by Mike Tricker (MikeTri), after jeffpar
  17. * Changed 15-Jul-1992 by Mike Tricker (MikeTri), fixing GetDevCaps calls
  18. * 26-Jul-1992 by Stephen Estrop (StephenE) thunks for mciSendCommand
  19. * 30-Jul-1992 by Mike Tricker (MikeTri), fixing Wave/Midi/MMIO
  20. * 03-Aug-1992 by Mike Tricker (MikeTri), added proper error handling
  21. * 08-Oct-1992 by StephenE spawn from the original wmmedia.c
  22. *
  23. \*---------------------------------------------------------------------*/
  24. //
  25. // We define NO_STRICT so that the compiler doesn't moan and groan when
  26. // I use the FARPROC type for the Multi-Media api loading.
  27. //
  28. #define NO_STRICT
  29. #define OEMRESOURCE
  30. #include "precomp.h"
  31. #pragma hdrstop
  32. #if 0
  33. MODNAME(wmmedia1.c);
  34. #if DBG
  35. int mmTraceAux = 0;
  36. int mmTraceJoy = 0;
  37. #endif
  38. /* ---------------------------------------------------------------------
  39. ** Auxiliary Sound APIs
  40. ** ---------------------------------------------------------------------
  41. */
  42. /**********************************************************************\
  43. *
  44. * WMM32auxGetNumDevs
  45. *
  46. * This function retrieves the number of auxiliary output devices present in the
  47. * system.
  48. *
  49. \**********************************************************************/
  50. ULONG FASTCALL WMM32auxGetNumDevs(PVDMFRAME pFrame)
  51. {
  52. ULONG ul;
  53. static FARPROC mmAPI = NULL;
  54. GET_MULTIMEDIA_API( "auxGetNumDevs", mmAPI, MMSYSERR_NODRIVER );
  55. UNREFERENCED_PARAMETER(pFrame);
  56. trace_aux(( "auxGetNumDevs()" ));
  57. ul = GETWORD16( (*mmAPI)() );
  58. trace_aux(( "-> %ld\n", ul ));
  59. RETURN(ul);
  60. }
  61. /**********************************************************************\
  62. *
  63. * WMM32auxGetDevCaps
  64. *
  65. * This function queries a specified auxiliary output device to determine its
  66. * capabilities.
  67. *
  68. \**********************************************************************/
  69. ULONG FASTCALL WMM32auxGetDevCaps(PVDMFRAME pFrame)
  70. {
  71. ULONG ul;
  72. AUXCAPS auxcaps;
  73. register PAUXGETDEVCAPS16 parg16;
  74. static FARPROC mmAPI = NULL;
  75. GET_MULTIMEDIA_API( "auxGetDevCapsA", mmAPI, MMSYSERR_NODRIVER );
  76. GETARGPTR(pFrame, sizeof(AUXGETDEVCAPS16), parg16);
  77. trace_aux(( "auxGetDevCaps( %x, %x, %x )", INT32(parg16->f1),
  78. DWORD32(parg16->f2), UINT32(parg16->f3) ));
  79. /*
  80. ** If the size parameter was zero return straight away. Note that this
  81. ** is not an error.
  82. */
  83. if ( UINT32( parg16->f3 ) == 0 ) {
  84. ul = MMSYSERR_NOERROR;
  85. }
  86. else {
  87. ul = GETWORD16((*mmAPI)( INT32(parg16->f1), &auxcaps,
  88. sizeof(AUXCAPS) ));
  89. /*
  90. ** Don't update the 16 bit structure if the call falied
  91. **
  92. */
  93. if ( ul == MMSYSERR_NOERROR ) {
  94. ul = PUTAUXCAPS16( parg16->f2, &auxcaps, UINT32(parg16->f3) );
  95. }
  96. }
  97. trace_aux(( "-> %ld\n", ul ));
  98. FREEARGPTR(parg16);
  99. RETURN(ul);
  100. }
  101. /**********************************************************************\
  102. *
  103. * WMM32auxGetVolume
  104. *
  105. * This function returns the current volume setting of an auxiliary output
  106. * device.
  107. *
  108. * Does this actually return the value in f2 ? It should...
  109. *
  110. \**********************************************************************/
  111. ULONG FASTCALL WMM32auxGetVolume(PVDMFRAME pFrame)
  112. {
  113. ULONG ul;
  114. LPDWORD lpdwVolume;
  115. register PAUXGETVOLUME16 parg16;
  116. static FARPROC mmAPI = NULL;
  117. GET_MULTIMEDIA_API( "auxGetVolume", mmAPI, MMSYSERR_NODRIVER );
  118. GETARGPTR(pFrame, sizeof(AUXGETVOLUME16), parg16);
  119. GETMISCPTR(parg16->f2, lpdwVolume);
  120. trace_aux(( "auxGetVolume( %x, %x )", INT32(parg16->f1),
  121. DWORD32(parg16->f2) ));
  122. ul = GETWORD16((*mmAPI)( INT32(parg16->f1), lpdwVolume ));
  123. trace_aux(( "-> %ld\n", ul ));
  124. FREEMISCPTR(lpdwVolume);
  125. FREEARGPTR(parg16);
  126. RETURN(ul);
  127. }
  128. /**********************************************************************\
  129. *
  130. * WMM32auxSetVolume
  131. *
  132. * This function sets the volume of an auxiliary output device.
  133. *
  134. \**********************************************************************/
  135. ULONG FASTCALL WMM32auxSetVolume(PVDMFRAME pFrame)
  136. {
  137. ULONG ul;
  138. register PAUXSETVOLUME16 parg16;
  139. static FARPROC mmAPI = NULL;
  140. GET_MULTIMEDIA_API( "auxSetVolume", mmAPI, MMSYSERR_NODRIVER );
  141. GETARGPTR(pFrame, sizeof(AUXSETVOLUME16), parg16);
  142. trace_aux(( "auxSetVolume( %x, %x )", INT32(parg16->f1),
  143. DWORD32(parg16->f2) ));
  144. ul = GETWORD16((*mmAPI)( INT32(parg16->f1), DWORD32(parg16->f2) ));
  145. trace_aux(( "-> %ld\n", ul ));
  146. FREEARGPTR(parg16);
  147. RETURN(ul);
  148. }
  149. /**********************************************************************\
  150. *
  151. * WMM32auxOutMessage
  152. *
  153. * This function sends a message to an auxiliary output device.
  154. *
  155. \**********************************************************************/
  156. ULONG FASTCALL WMM32auxOutMessage(PVDMFRAME pFrame)
  157. {
  158. ULONG ul;
  159. register PAUXOUTMESSAGE3216 parg16;
  160. static FARPROC mmAPI = NULL;
  161. GET_MULTIMEDIA_API( "auxOutMessage", mmAPI, MMSYSERR_NODRIVER );
  162. GETARGPTR(pFrame, sizeof(AUXOUTMESSAGE16), parg16);
  163. trace_aux(( "auxOutMessage( %x, %x, %x, %x )", WORD32(parg16->f1),
  164. UINT32(parg16->f2), DWORD32(parg16->f3), DWORD32(parg16->f4) ));
  165. if ( (UINT32(parg16->f2) >= DRV_BUFFER_LOW)
  166. && (UINT32(parg16->f2) <= DRV_BUFFER_HIGH) ) {
  167. LPDWORD lpdwParam1;
  168. GETMISCPTR(parg16->f3, lpdwParam1);
  169. ul = GETDWORD16((*mmAPI)( INT32(parg16->f1), UINT32(parg16->f2),
  170. (DWORD)lpdwParam1, DWORD32(parg16->f4) ));
  171. FREEMISCPTR(lpdwParam1);
  172. } else {
  173. ul = GETDWORD16((*mmAPI)( INT32(parg16->f1),
  174. MAKELONG( WORD32(parg16->f2), 0xFFFF ),
  175. DWORD32(parg16->f3),
  176. DWORD32(parg16->f4) ));
  177. }
  178. trace_aux(( "-> %ld\n", ul ));
  179. FREEARGPTR(parg16);
  180. RETURN(ul);
  181. }
  182. /* ---------------------------------------------------------------------
  183. ** Joystick APIs
  184. ** ---------------------------------------------------------------------
  185. */
  186. /**********************************************************************\
  187. *
  188. * WMM32joyGetNumDevs
  189. *
  190. * This function returns the number of joystick devices supported by the system.
  191. *
  192. *
  193. *
  194. \**********************************************************************/
  195. ULONG FASTCALL WMM32joyGetNumDevs(PVDMFRAME pFrame)
  196. {
  197. ULONG ul;
  198. static FARPROC mmAPI = NULL;
  199. GET_MULTIMEDIA_API( "joyGetNumDevs", mmAPI, MMSYSERR_NODRIVER );
  200. UNREFERENCED_PARAMETER(pFrame);
  201. trace_joy(( "joyGetNumDevs()" ));
  202. ul = GETWORD16((*mmAPI)());
  203. trace_joy(( "-> %ld\n", ul ));
  204. RETURN(ul);
  205. }
  206. /**********************************************************************\
  207. *
  208. * WMM32joyGetDevCaps
  209. *
  210. * This function queries a joystick device to determine its capabilities.
  211. *
  212. \**********************************************************************/
  213. ULONG FASTCALL WMM32joyGetDevCaps(PVDMFRAME pFrame)
  214. {
  215. ULONG ul;
  216. JOYCAPS joycaps;
  217. register PJOYGETDEVCAPS16 parg16;
  218. static FARPROC mmAPI = NULL;
  219. GET_MULTIMEDIA_API( "joyGetDevCapsA", mmAPI, MMSYSERR_NODRIVER );
  220. GETARGPTR(pFrame, sizeof(JOYGETDEVCAPS16), parg16);
  221. trace_joy(( "joyGetDevCaps( %x, %x, %x )", INT32(parg16->f1),
  222. DWORD32(parg16->f2), UINT32(parg16->f3) ));
  223. ul = GETWORD16((*mmAPI)(INT32(parg16->f1), &joycaps, sizeof(JOYCAPS)));
  224. if ( ul == JOYERR_NOERROR ) {
  225. ul = PUTJOYCAPS16( parg16->f2, &joycaps, UINT32(parg16->f3) );
  226. }
  227. trace_joy(( "-> %ld\n", ul ));
  228. FREEARGPTR(parg16);
  229. RETURN(ul);
  230. }
  231. /**********************************************************************\
  232. *
  233. * WMM32joyGetPos
  234. *
  235. * This function queries the position and button activity of a joystick device.
  236. *
  237. \**********************************************************************/
  238. ULONG FASTCALL WMM32joyGetPos(PVDMFRAME pFrame)
  239. {
  240. ULONG ul;
  241. JOYINFO joyinfo;
  242. register PJOYGETPOS16 parg16;
  243. static FARPROC mmAPI = NULL;
  244. GET_MULTIMEDIA_API( "joyGetPos", mmAPI, MMSYSERR_NODRIVER );
  245. GETARGPTR(pFrame, sizeof(JOYGETPOS16), parg16);
  246. trace_joy(( "joyGetPosition( %x, %x )", WORD32(parg16->f1),
  247. DWORD32(parg16->f2) ));
  248. ul = GETWORD16((*mmAPI)( INT32(parg16->f1), &joyinfo ));
  249. if ( ul == JOYERR_NOERROR ) {
  250. ul = PUTJOYINFO16( parg16->f2, &joyinfo );
  251. }
  252. trace_joy(( "-> %ld\n", ul ));
  253. FREEARGPTR(parg16);
  254. RETURN(ul);
  255. }
  256. /**********************************************************************\
  257. *
  258. * WMM32joySetThreshold
  259. *
  260. * This function sets the movement threshold of a joystick device.
  261. *
  262. \**********************************************************************/
  263. ULONG FASTCALL WMM32joySetThreshold(PVDMFRAME pFrame)
  264. {
  265. ULONG ul;
  266. register PJOYSETTHRESHOLD16 parg16;
  267. static FARPROC mmAPI = NULL;
  268. GET_MULTIMEDIA_API( "joySetThreshold", mmAPI, MMSYSERR_NODRIVER );
  269. GETARGPTR(pFrame, sizeof(JOYSETTHRESHOLD), parg16);
  270. trace_joy(( "joySetThreshold( %x, %x )", INT32(parg16->f1),
  271. UINT32(parg16->f2) ));
  272. ul = GETWORD16((*mmAPI)( INT32(parg16->f1), UINT32(parg16->f2) ));
  273. trace_joy(( "-> %ld\n", ul ));
  274. FREEARGPTR(parg16);
  275. RETURN(ul);
  276. }
  277. /**********************************************************************\
  278. *
  279. * WMM32joyGetThreshold
  280. *
  281. * This function queries the current movement threshold of a joystick device.
  282. *
  283. \**********************************************************************/
  284. ULONG FASTCALL WMM32joyGetThreshold(PVDMFRAME pFrame)
  285. {
  286. register PJOYGETTHRESHOLD16 parg16;
  287. ULONG ul;
  288. UINT uThreshold;
  289. LPWORD lpwThreshold16;
  290. static FARPROC mmAPI = NULL;
  291. GET_MULTIMEDIA_API( "joyGetThreshold", mmAPI, MMSYSERR_NODRIVER );
  292. GETARGPTR(pFrame, sizeof(JOYGETTHRESHOLD16), parg16);
  293. trace_joy(( "joyGetThreshold( %x, %x )", WORD32(parg16->f1),
  294. DWORD32(parg16->f2) ));
  295. ul = GETWORD16((*mmAPI)( INT32(parg16->f1), &uThreshold ));
  296. /*
  297. ** Only copy the threshold back to 16 bit space if the call was sucessful
  298. **
  299. */
  300. if ( ul == JOYERR_NOERROR ) {
  301. MMGETOPTPTR( parg16->f2, sizeof(WORD), lpwThreshold16 );
  302. if ( lpwThreshold16 ) {
  303. STOREWORD ( *lpwThreshold16, uThreshold );
  304. FLUSHVDMPTR( DWORD32(parg16->f2), sizeof(WORD), lpwThreshold16 );
  305. FREEVDMPTR ( lpwThreshold16 );
  306. }
  307. else {
  308. ul = JOYERR_PARMS;
  309. }
  310. }
  311. trace_joy(( "-> %ld\n", ul ));
  312. FREEARGPTR(parg16);
  313. RETURN(ul);
  314. }
  315. /**********************************************************************\
  316. *
  317. * WMM32joyReleaseCapture
  318. *
  319. * This function releases the capture set by joySetCapture on the specified
  320. * joystick device
  321. *
  322. \**********************************************************************/
  323. ULONG FASTCALL WMM32joyReleaseCapture(PVDMFRAME pFrame)
  324. {
  325. ULONG ul;
  326. register PJOYRELEASECAPTURE16 parg16;
  327. static FARPROC mmAPI = NULL;
  328. GET_MULTIMEDIA_API( "joyReleaseCapture", mmAPI, MMSYSERR_NODRIVER );
  329. GETARGPTR(pFrame, sizeof(JOYRELEASECAPTURE16), parg16);
  330. trace_joy(( "joyReleaseCapture( %x )", WORD32( parg16->f1 ) ));
  331. ul = GETWORD16((*mmAPI)( INT32(parg16->f1) ));
  332. trace_joy(( "-> %ld\n", ul ));
  333. FREEARGPTR(parg16);
  334. RETURN(ul);
  335. }
  336. /**********************************************************************\
  337. *
  338. * WMM32joySetCapture
  339. *
  340. * This function causes joystick messages to be sent to the specified window.
  341. *
  342. \**********************************************************************/
  343. ULONG FASTCALL WMM32joySetCapture(PVDMFRAME pFrame)
  344. {
  345. ULONG ul;
  346. register PJOYSETCAPTURE16 parg16;
  347. static FARPROC mmAPI = NULL;
  348. GET_MULTIMEDIA_API( "joySetCapture", mmAPI, MMSYSERR_NODRIVER );
  349. GETARGPTR(pFrame, sizeof(JOYSETCAPTURE), parg16);
  350. trace_joy(( "joySetCapture( %x, %x, %x, %x )", WORD32(parg16->f1),
  351. INT32(parg16->f2), UINT32(parg16->f3), BOOL32(parg16->f4) ));
  352. ul = GETWORD16((*mmAPI)( HWND32(parg16->f1), INT32(parg16->f2),
  353. UINT32(parg16->f3), BOOL32(parg16->f4) ));
  354. trace_joy(( "-> %ld\n", ul ));
  355. FREEARGPTR(parg16);
  356. RETURN(ul);
  357. }
  358. /**********************************************************************\
  359. *
  360. * WMM32joySetCalibration
  361. *
  362. * This function allows the calibration of a joystick device.
  363. *
  364. \**********************************************************************/
  365. ULONG FASTCALL WMM32joySetCalibration(PVDMFRAME pFrame)
  366. {
  367. register PJOYSETCALIBRATION16 parg16;
  368. static FARPROC mmAPI = NULL;
  369. ULONG ul;
  370. LPWORD lpwXbase;
  371. LPWORD lpwXdelta;
  372. LPWORD lpwYbase;
  373. LPWORD lpwYdelta;
  374. LPWORD lpwZbase;
  375. LPWORD lpwZdelta;
  376. UINT uXbase;
  377. UINT uXdelta;
  378. UINT uYbase;
  379. UINT uYdelta;
  380. UINT uZbase;
  381. UINT uZdelta;
  382. GET_MULTIMEDIA_API( "joySetCapture", mmAPI, MMSYSERR_NODRIVER );
  383. GETARGPTR(pFrame, sizeof(JOYSETCALIBRATION16), parg16);
  384. trace_joy(( "joySetCalibration( %x, %x, %x, %x, %x, %x, %x )",
  385. DWORD32(parg16->f1), UINT32(parg16->f2), UINT32(parg16->f3),
  386. UINT32(parg16->f4), UINT32(parg16->f5), UINT32(parg16->f6),
  387. UINT32(parg16->f7) ));
  388. MMGETOPTPTR( parg16->f2, sizeof(WORD), lpwXbase );
  389. if ( lpwXbase == NULL ) {
  390. goto exit_1;
  391. }
  392. MMGETOPTPTR( parg16->f3, sizeof(WORD), lpwXdelta );
  393. if ( lpwXdelta == NULL ) {
  394. goto exit_2;
  395. }
  396. MMGETOPTPTR( parg16->f4, sizeof(WORD), lpwYbase );
  397. if ( lpwYbase == NULL ) {
  398. goto exit_3;
  399. }
  400. MMGETOPTPTR( parg16->f5, sizeof(WORD), lpwYdelta );
  401. if ( lpwYdelta == NULL ) {
  402. goto exit_4;
  403. }
  404. MMGETOPTPTR( parg16->f6, sizeof(WORD), lpwZbase );
  405. if ( lpwZbase == NULL ) {
  406. goto exit_5;
  407. }
  408. MMGETOPTPTR( parg16->f7, sizeof(WORD), lpwZdelta );
  409. if ( lpwZdelta == NULL ) {
  410. goto exit_6;
  411. }
  412. uXbase = FETCHWORD( *lpwXbase );
  413. uXdelta = FETCHWORD( *lpwXdelta );
  414. uYbase = FETCHWORD( *lpwYbase );
  415. uYdelta = FETCHWORD( *lpwYdelta );
  416. uZbase = FETCHWORD( *lpwZbase );
  417. uZdelta = FETCHWORD( *lpwZdelta );
  418. ul = GETWORD16((*mmAPI)( DWORD32(parg16->f1), &uXbase, &uXdelta,
  419. &uYbase, &uYdelta, &uZbase, &uZdelta ));
  420. STOREWORD( *lpwXbase, uXbase );
  421. STOREWORD( *lpwXdelta, uXdelta );
  422. STOREWORD( *lpwYbase, uYbase );
  423. STOREWORD( *lpwYdelta, uYdelta );
  424. STOREWORD( *lpwZbase, uZbase );
  425. STOREWORD( *lpwZdelta, uZdelta );
  426. FREEMISCPTR( lpwZdelta );
  427. exit_6:
  428. FREEMISCPTR( lpwZbase );
  429. exit_5:
  430. FREEMISCPTR( lpwYdelta );
  431. exit_4:
  432. FREEMISCPTR( lpwYbase );
  433. exit_3:
  434. FREEMISCPTR( lpwXdelta );
  435. exit_2:
  436. FREEMISCPTR( lpwXbase );
  437. exit_1:
  438. trace_joy(( "-> %ld\n", ul ));
  439. FREEARGPTR(parg16);
  440. RETURN(ul);
  441. }
  442. #endif