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.

311 lines
7.1 KiB

  1. //==========================================================================;
  2. //
  3. // waveout.c
  4. //
  5. // Copyright (c) 1992-1998 Microsoft Corporation
  6. //
  7. // Description:
  8. //
  9. //
  10. // History:
  11. // 9/18/93 cjp [curtisp]
  12. //
  13. //==========================================================================;
  14. #include <windows.h>
  15. #include <windowsx.h>
  16. #include <mmsystem.h>
  17. #include <mmddk.h>
  18. #include <mmreg.h>
  19. #include <msacm.h>
  20. #include <msacmdrv.h>
  21. #include "msacmmap.h"
  22. #include "debug.h"
  23. //--------------------------------------------------------------------------;
  24. //
  25. // DWORD wodmMapperStatus
  26. //
  27. // Description:
  28. //
  29. //
  30. // Arguments:
  31. // LPMAPSTREAM pms:
  32. //
  33. // DWORD dwStatus:
  34. //
  35. // LPDWORD pdw:
  36. //
  37. // Return (DWORD):
  38. //
  39. // History:
  40. // 08/13/93 cjp [curtisp]
  41. //
  42. //--------------------------------------------------------------------------;
  43. DWORD FNLOCAL wodmMapperStatus
  44. (
  45. LPMAPSTREAM pms,
  46. DWORD dwStatus,
  47. LPDWORD pdw
  48. )
  49. {
  50. MMRESULT mmr;
  51. // V_WPOINTER(pdw, sizeof(DWORD), MMSYSERR_INVALPARAM);
  52. if ((NULL == pms) || (NULL == pdw))
  53. {
  54. return (MMSYSERR_INVALPARAM);
  55. }
  56. //
  57. //
  58. //
  59. switch (dwStatus)
  60. {
  61. case WAVEOUT_MAPPER_STATUS_DEVICE:
  62. {
  63. UINT uId = (UINT)(-1); // Invalid value
  64. mmr = waveOutGetID(pms->hwoReal, &uId);
  65. if (MMSYSERR_NOERROR != mmr)
  66. {
  67. return (mmr);
  68. }
  69. *pdw = uId;
  70. return (MMSYSERR_NOERROR);
  71. }
  72. case WAVEOUT_MAPPER_STATUS_MAPPED:
  73. *pdw = (NULL != pms->has);
  74. return (MMSYSERR_NOERROR);
  75. case WAVEOUT_MAPPER_STATUS_FORMAT:
  76. if (NULL != pms->has)
  77. _fmemcpy(pdw, pms->pwfxReal, sizeof(PCMWAVEFORMAT));
  78. else
  79. _fmemcpy(pdw, pms->pwfxClient, sizeof(PCMWAVEFORMAT));
  80. ((LPWAVEFORMATEX)pdw)->cbSize = 0;
  81. return (MMSYSERR_NOERROR);
  82. }
  83. //
  84. //
  85. //
  86. return (MMSYSERR_NOTSUPPORTED);
  87. } // wodmMapperStatus()
  88. //--------------------------------------------------------------------------;
  89. //
  90. // DWORD wodMessage
  91. //
  92. // Description:
  93. // This function conforms to the standard Wave output driver message
  94. // procedure (wodMessage), which is documented in mmddk.d.
  95. //
  96. // Arguments:
  97. // UINT uId:
  98. //
  99. // UINT uMsg:
  100. //
  101. // DWORD dwUser:
  102. //
  103. // DWORD dwParam1:
  104. //
  105. // DWORD dwParam2:
  106. //
  107. // Return (DWORD):
  108. //
  109. //
  110. // History:
  111. // 11/15/92 cjp [curtisp]
  112. //
  113. //--------------------------------------------------------------------------;
  114. EXTERN_C DWORD FNEXPORT wodMessage
  115. (
  116. UINT uId,
  117. UINT uMsg,
  118. DWORD_PTR dwUser,
  119. DWORD_PTR dwParam1,
  120. DWORD_PTR dwParam2
  121. )
  122. {
  123. #ifndef WIN32 // Mechanism doesn't work for multithread
  124. static int fSem = 0;
  125. #endif // !WIN32
  126. DWORD dw;
  127. LPMAPSTREAM pms; // pointer to per-instance info structure
  128. if (!gpag->fEnabled)
  129. {
  130. DPF(1, "wodMessage: called while disabled!");
  131. return ((WODM_GETNUMDEVS == uMsg) ? 0L : MMSYSERR_NOTENABLED);
  132. }
  133. #ifndef WIN32
  134. //
  135. // we call back into the mmsystem wave APIs so protect ourself
  136. // from being re-entered!
  137. //
  138. if (fSem)
  139. {
  140. DPF(0, "!wodMessage() being reentered! fSem=%d", fSem);
  141. return (MMSYSERR_NOTSUPPORTED);
  142. }
  143. #endif
  144. pms = (LPMAPSTREAM)dwUser;
  145. switch (uMsg)
  146. {
  147. case WODM_GETNUMDEVS:
  148. return (1L);
  149. case WODM_GETDEVCAPS:
  150. return mapWaveGetDevCaps(FALSE, (LPWAVEOUTCAPS)dwParam1, (UINT)dwParam2);
  151. case WODM_OPEN:
  152. #ifndef WIN32
  153. fSem++;
  154. #endif // !WIN32
  155. //
  156. // dwParam1 contains a pointer to a WAVEOPENDESC
  157. // dwParam2 contains wave driver specific flags in the LOWORD
  158. // and generic driver flags in the HIWORD
  159. //
  160. dw = mapWaveOpen(FALSE, uId, dwUser, (LPWAVEOPENDESC)dwParam1, (DWORD)(PtrToLong((PVOID)dwParam2)));
  161. #ifndef WIN32
  162. fSem--;
  163. #endif // !WIN32
  164. return (dw);
  165. case WODM_CLOSE:
  166. return (mapWaveClose(pms));
  167. case WODM_PREPARE:
  168. return (mapWavePrepareHeader(pms, (LPWAVEHDR)dwParam1));
  169. case WODM_UNPREPARE:
  170. return (mapWaveUnprepareHeader(pms, (LPWAVEHDR)dwParam1));
  171. case WODM_WRITE:
  172. return (mapWaveWriteBuffer(pms, (LPWAVEHDR)dwParam1));
  173. case WODM_PAUSE:
  174. return waveOutPause(pms->hwoReal);
  175. case WODM_RESTART:
  176. return waveOutRestart(pms->hwoReal);
  177. case WODM_RESET:
  178. return waveOutReset(pms->hwoReal);
  179. case WODM_BREAKLOOP:
  180. return waveOutBreakLoop(pms->hwoReal);
  181. case WODM_GETPOS:
  182. return mapWaveGetPosition(pms, (LPMMTIME)dwParam1, (UINT)dwParam2);
  183. case WODM_GETVOLUME:
  184. if (NULL != pms)
  185. {
  186. #if (WINVER < 0x0400)
  187. UINT uDevId;
  188. waveOutGetID(pms->hwoReal, &uDevId);
  189. return waveOutGetVolume(uDevId, (LPDWORD)dwParam1);
  190. #else
  191. return waveOutGetVolume(pms->hwoReal, (LPDWORD)dwParam1);
  192. #endif
  193. }
  194. else
  195. {
  196. UINT uDevId;
  197. WAIT_FOR_MUTEX(gpag->hMutexSettings);
  198. uDevId = gpag->pSettings->uIdPreferredOut;
  199. RELEASE_MUTEX(gpag->hMutexSettings);
  200. if ((UINT)WAVE_MAPPER != uDevId)
  201. {
  202. #if (WINVER < 0x0400)
  203. return waveOutGetVolume(uDevId, (LPDWORD)dwParam1);
  204. #else
  205. return waveOutGetVolume((HWAVEOUT)LongToHandle(uDevId), (LPDWORD)dwParam1);
  206. #endif
  207. }
  208. }
  209. return (MMSYSERR_NOTSUPPORTED);
  210. case WODM_SETVOLUME:
  211. if (NULL != pms)
  212. {
  213. #if (WINVER < 0x0400)
  214. UINT uDevId;
  215. waveOutGetID(pms->hwoReal, &uDevId);
  216. return waveOutSetVolume(uDevId, (DWORD)(PtrToLong((PVOID)dwParam1)) );
  217. #else
  218. return waveOutSetVolume(pms->hwoReal, (DWORD)(PtrToLong((PVOID)dwParam1)) );
  219. #endif
  220. }
  221. else
  222. {
  223. UINT uDevId;
  224. WAIT_FOR_MUTEX(gpag->hMutexSettings);
  225. uDevId = gpag->pSettings->uIdPreferredOut;
  226. RELEASE_MUTEX(gpag->hMutexSettings);
  227. if ((UINT)WAVE_MAPPER != uDevId)
  228. {
  229. #if (WINVER < 0x0400)
  230. return waveOutSetVolume(uDevId, (DWORD)(PtrToLong((PVOID)dwParam1)) );
  231. #else
  232. return waveOutSetVolume((HWAVEOUT)(UINT_PTR)uDevId, (DWORD)(PtrToLong((PVOID)dwParam1)) );
  233. #endif
  234. }
  235. }
  236. return (MMSYSERR_NOTSUPPORTED);
  237. case WODM_GETPITCH:
  238. return waveOutGetPitch(pms->hwoReal, (LPDWORD)dwParam1);
  239. case WODM_SETPITCH:
  240. return waveOutSetPitch(pms->hwoReal, (DWORD)(PtrToLong((PVOID)dwParam1)) );
  241. case WODM_GETPLAYBACKRATE:
  242. return waveOutGetPlaybackRate(pms->hwoReal, (LPDWORD)dwParam1);
  243. case WODM_SETPLAYBACKRATE:
  244. return waveOutSetPlaybackRate(pms->hwoReal, (DWORD)(PtrToLong((PVOID)dwParam1)) );
  245. case WODM_MAPPER_STATUS:
  246. dw = wodmMapperStatus(pms, (DWORD)(PtrToLong((PVOID)dwParam1)), (LPDWORD)dwParam2);
  247. return (dw);
  248. #if (WINVER >= 0x0400)
  249. case DRVM_MAPPER_RECONFIGURE:
  250. mapDriverDisable(NULL);
  251. mapDriverEnable(NULL);
  252. return (0);
  253. #endif
  254. }
  255. if (!pms || !pms->hwoReal)
  256. return (MMSYSERR_NOTSUPPORTED);
  257. return waveOutMessage(pms->hwoReal, uMsg, dwParam1, dwParam2);
  258. } // wodMessage()