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.

293 lines
8.2 KiB

  1. /*****************************************************************************
  2. *
  3. * Component: sndvol32.exe
  4. * File: nonmixer.c
  5. * Purpose: non-mixer api specific implementations
  6. *
  7. * Copyright (c) 1985-1995 Microsoft Corporation
  8. *
  9. *****************************************************************************/
  10. /*
  11. * These are the volume control api's we have to work with.
  12. *
  13. * WINMMAPI MMRESULT WINAPI midiOutGetVolume(HMIDIOUT hmo, LPDWORD pdwVolume);
  14. * WINMMAPI MMRESULT WINAPI midiOutSetVolume(HMIDIOUT hmo, DWORD dwVolume);
  15. * WINMMAPI MMRESULT WINAPI waveOutGetVolume(UINT uId, LPDWORD pdwVolume);
  16. * WINMMAPI MMRESULT WINAPI waveOutSetVolume(UINT uId, DWORD dwVolume);
  17. * WINMMAPI MMRESULT WINAPI auxSetVolume(UINT uDeviceID, DWORD dwVolume);
  18. * WINMMAPI MMRESULT WINAPI auxGetVolume(UINT uDeviceID, LPDWORD pdwVolume);
  19. *
  20. * */
  21. #include <windows.h>
  22. #include <windowsx.h>
  23. #include <mmsystem.h>
  24. #include "volumei.h"
  25. #define STRSAFE_LIB
  26. #include <strsafe.h>
  27. int Nonmixer_GetNumDevs()
  28. {
  29. UINT cNumDevs = 0;
  30. int iDev;
  31. UINT uMxID;
  32. BOOL fAdd = FALSE;
  33. //
  34. // Is aux support required?
  35. //
  36. iDev = auxGetNumDevs();
  37. for (;iDev > 0; iDev --)
  38. {
  39. if (mixerGetID((HMIXEROBJ)IntToPtr(iDev-1)
  40. , &uMxID
  41. , MIXER_OBJECTF_AUX) == MMSYSERR_NODRIVER)
  42. {
  43. AUXCAPS axcaps;
  44. if (auxGetDevCaps(iDev-1, &axcaps, sizeof(AUXCAPS))
  45. == MMSYSERR_NOERROR)
  46. {
  47. if (axcaps.dwSupport & AUXCAPS_VOLUME)
  48. fAdd = TRUE;
  49. }
  50. }
  51. }
  52. if (fAdd)
  53. cNumDevs++;
  54. iDev = midiOutGetNumDevs();
  55. for (; iDev > 0; iDev --)
  56. {
  57. if (mixerGetID((HMIXEROBJ)IntToPtr(iDev-1)
  58. , &uMxID
  59. , MIXER_OBJECTF_MIDIOUT) == MMSYSERR_NODRIVER)
  60. {
  61. MIDIOUTCAPS mocaps;
  62. if (midiOutGetDevCaps(iDev-1, &mocaps, sizeof(MIDIOUTCAPS))
  63. == MMSYSERR_NOERROR)
  64. {
  65. if ((mocaps.dwSupport & MIDICAPS_VOLUME) ||
  66. (mocaps.dwSupport & MIDICAPS_LRVOLUME))
  67. fAdd = TRUE;
  68. }
  69. }
  70. }
  71. if (fAdd)
  72. cNumDevs++;
  73. iDev = waveOutGetNumDevs();
  74. for (; iDev > 0; iDev --)
  75. {
  76. if (mixerGetID((HMIXEROBJ)IntToPtr(iDev-1)
  77. , &uMxID
  78. , MIXER_OBJECTF_WAVEOUT) == MMSYSERR_NODRIVER)
  79. {
  80. WAVEOUTCAPS wocaps;
  81. if (waveOutGetDevCaps(iDev-1, &wocaps, sizeof(WAVEOUTCAPS))
  82. == MMSYSERR_NOERROR)
  83. {
  84. if ((wocaps.dwSupport & WAVECAPS_VOLUME) ||
  85. (wocaps.dwSupport & WAVECAPS_LRVOLUME))
  86. fAdd = TRUE;
  87. }
  88. }
  89. }
  90. if (fAdd)
  91. cNumDevs++;
  92. return cNumDevs;
  93. }
  94. void Nonmixer_SetLines(
  95. PVOLCTRLDESC pvcd)
  96. {
  97. ;
  98. }
  99. const TCHAR szAuxIn[] = TEXT ("Aux-In");
  100. const TCHAR szCD[] = TEXT ("CDROM");
  101. const TCHAR szAux[] = TEXT ("Aux");
  102. const TCHAR szMidiOut[] = TEXT ("Midi-Out");
  103. /*
  104. * Nonmixer_CreateVolumeDescription
  105. *
  106. * Return an array of volumedescriptions
  107. *
  108. */
  109. PVOLCTRLDESC Nonmixer_CreateVolumeDescription (
  110. int iDest,
  111. DWORD * pcvcd )
  112. {
  113. int iDev;
  114. PVOLCTRLDESC pvcd = NULL;
  115. UINT uMxID;
  116. DWORD cLines = 0;
  117. //
  118. // aux's
  119. //
  120. for (iDev = auxGetNumDevs(); iDev > 0; iDev --)
  121. {
  122. if (mixerGetID((HMIXEROBJ)IntToPtr(iDev-1)
  123. , &uMxID
  124. , MIXER_OBJECTF_AUX) == MMSYSERR_NODRIVER)
  125. {
  126. AUXCAPS axcaps;
  127. if (auxGetDevCaps(iDev-1, &axcaps, sizeof(AUXCAPS))
  128. == MMSYSERR_NOERROR)
  129. {
  130. if (axcaps.dwSupport & AUXCAPS_VOLUME)
  131. {
  132. LPCTSTR pszLabel;
  133. DWORD dwSupport = 0L;
  134. pszLabel = szAux;
  135. pszLabel = axcaps.wTechnology & AUXCAPS_CDAUDIO
  136. ? szCD : pszLabel;
  137. pszLabel = axcaps.wTechnology & AUXCAPS_AUXIN
  138. ? szAuxIn : pszLabel;
  139. dwSupport |= axcaps.dwSupport & AUXCAPS_LRVOLUME ? VCD_SUPPORTF_STEREO : VCD_SUPPORTF_MONO;
  140. pvcd = PVCD_AddLine(pvcd
  141. , iDev
  142. , VCD_TYPE_AUX
  143. , axcaps.szPname
  144. , (LPTSTR)pszLabel
  145. , dwSupport
  146. , &cLines );
  147. }
  148. }
  149. }
  150. }
  151. for (iDev = midiOutGetNumDevs(); iDev > 0; iDev --)
  152. {
  153. if (mixerGetID((HMIXEROBJ)IntToPtr(iDev-1)
  154. , &uMxID
  155. , MIXER_OBJECTF_MIDIOUT) == MMSYSERR_NODRIVER)
  156. {
  157. MIDIOUTCAPS mocaps;
  158. if (midiOutGetDevCaps(iDev-1, &mocaps, sizeof(MIDIOUTCAPS))
  159. == MMSYSERR_NOERROR)
  160. {
  161. if (mocaps.dwSupport & MIDICAPS_VOLUME)
  162. {
  163. DWORD dwSupport = 0L;
  164. dwSupport |= mocaps.dwSupport & MIDICAPS_LRVOLUME ? VCD_SUPPORTF_STEREO : VCD_SUPPORTF_MONO;
  165. pvcd = PVCD_AddLine(pvcd
  166. , iDev
  167. , VCD_TYPE_MIDIOUT
  168. , mocaps.szPname
  169. , (LPTSTR)szMidiOut
  170. , dwSupport
  171. , &cLines );
  172. }
  173. }
  174. }
  175. }
  176. iDev = waveOutGetNumDevs();
  177. for (; iDev > 0; iDev --)
  178. {
  179. if (mixerGetID((HMIXEROBJ)IntToPtr(iDev-1)
  180. , &uMxID
  181. , MIXER_OBJECTF_WAVEOUT) == MMSYSERR_NODRIVER)
  182. {
  183. WAVEOUTCAPS wocaps;
  184. if (waveOutGetDevCaps(iDev-1, &wocaps, sizeof(WAVEOUTCAPS))
  185. == MMSYSERR_NOERROR)
  186. {
  187. if (wocaps.dwSupport & WAVECAPS_VOLUME)
  188. {
  189. const TCHAR szWaveOut[] = TEXT ("Wave-Out");
  190. DWORD dwSupport = 0L;
  191. dwSupport |= wocaps.dwSupport & WAVECAPS_LRVOLUME ? VCD_SUPPORTF_STEREO : VCD_SUPPORTF_MONO;
  192. pvcd = PVCD_AddLine(pvcd
  193. , iDev
  194. , VCD_TYPE_WAVEOUT
  195. , wocaps.szPname
  196. , (LPTSTR)szWaveOut
  197. , dwSupport
  198. , &cLines );
  199. }
  200. }
  201. }
  202. }
  203. //
  204. // Setup indicies, etc...
  205. //
  206. Nonmixer_SetLines(pvcd);
  207. *pcvcd = cLines;
  208. return pvcd;
  209. }
  210. void Nonmixer_PollingUpdate(
  211. PMIXUIDIALOG pmxud)
  212. {
  213. }
  214. BOOL Nonmixer_Init(
  215. PMIXUIDIALOG pmxud)
  216. {
  217. return TRUE;
  218. }
  219. void Nonmixer_GetControl(
  220. PMIXUIDIALOG pmxud,
  221. HWND hctl,
  222. int imxul,
  223. int ictl)
  224. {
  225. ;
  226. }
  227. void Nonmixer_SetControl(
  228. PMIXUIDIALOG pmxud,
  229. HWND hctl,
  230. int imxul,
  231. int ictl)
  232. {
  233. ;
  234. }
  235. void Nonmixer_Shutdown(
  236. PMIXUIDIALOG pmxud)
  237. {
  238. ;
  239. }
  240. const TCHAR szNonMixer[] = TEXT ("Wave,MIDI,Aux");
  241. BOOL Nonmixer_GetDeviceName(
  242. PMIXUIDIALOG pmxud)
  243. {
  244. HRESULT hr = StringCchCopy( pmxud->szMixer, SIZEOF(pmxud->szMixer), szNonMixer );
  245. if( hr == S_OK )
  246. {
  247. return TRUE;
  248. }
  249. pmxud->szMixer[0] = TEXT('\0');
  250. return FALSE;
  251. }