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.

300 lines
14 KiB

  1. /****************************************************************************
  2. *
  3. * wdmaud.h
  4. *
  5. * Common defines for wdmaud.drv and wdmaud.sys
  6. *
  7. * Copyright (C) Microsoft Corporation, 1997 - 1999 All Rights Reserved.
  8. *
  9. * History
  10. * 5-19-97 - Noel Cross (NoelC)
  11. *
  12. ***************************************************************************/
  13. #include "ks.h"
  14. #include "ksmedia.h"
  15. #define ANSI_TAG 0x42
  16. #define UNICODE_TAG 0x43
  17. #define MUSICBUFFERSIZE 20
  18. #define STREAM_BUFFERS 128
  19. #define MAXCALLBACKS 4
  20. #ifdef DEBUG
  21. #define DEVICEINFO_SIGNATURE 'IDAW' // WADI as seen in memory
  22. #define DEVICESTATE_SIGNATURE 'SDAW' // WADS as seen in memory
  23. #define MIDIDATALISTENTRY_SIGNATURE 'ELDM' // MDLE as seen in memory
  24. #endif
  25. //****************************************************************************
  26. //
  27. // Device Types
  28. //
  29. //****************************************************************************
  30. #define WaveInDevice 0
  31. #define WaveOutDevice 1
  32. #define MidiInDevice 2
  33. #define MidiOutDevice 3
  34. #define MixerDevice 4
  35. #define AuxDevice 5
  36. #define MAX_DEVICE_CLASS 6
  37. #if IS_16
  38. #define HANDLE32 DWORD
  39. #define BOOL32 DWORD
  40. #else
  41. #define HANDLE32 HANDLE
  42. #define BOOL32 BOOL
  43. #endif
  44. #define IS16( DevInfo ) ( DevInfo->dwFormat == ANSI_TAG )
  45. #define ISANSI( DevInfo ) IS16( DevInfo )
  46. #define ISWIDE( DevInfo ) ( DevInfo->dwFormat == UNICODE_TAG )
  47. //
  48. // stores the state of the wdm-based legacy device
  49. //
  50. typedef struct _DEVICESTATE {
  51. DWORD cSampleBits; // used for wave position : Count of Bits per sample
  52. HANDLE32 hThread;
  53. DWORD dwThreadId;
  54. union _QUEUE {
  55. LPMIDIHDR lpMidiInQueue;// Used for MidiIn
  56. LPWAVEHDR lpWaveQueue; // Used for WaveIn/Out
  57. // This is only required so that
  58. // CLOSE knows when things have
  59. // really finished.
  60. };
  61. struct _MIDIDATALISTENTRY *lpMidiDataQueue;
  62. ULONG LastTimeMs;
  63. LPVOID csQueue; // protection for queue
  64. HANDLE32 hevtQueue;
  65. HANDLE32 hevtExitThread;
  66. volatile BOOL32 fExit; //
  67. volatile BOOL32 fPaused; //
  68. volatile BOOL32 fRunning; //
  69. volatile BOOL32 fThreadRunning;//
  70. LPBYTE lpNoteOnMap; // What notes are turned on for MidiOut
  71. BYTE bMidiStatus; // Last running status byte for MIDI
  72. #ifdef DEBUG
  73. DWORD dwSig; // WADS as seen in memory.
  74. #endif
  75. } DEVICESTATE, FAR *LPDEVICESTATE;
  76. //
  77. // specifies which device to effect in wdmaud.sys
  78. //
  79. typedef struct _DEVICEINFO {
  80. struct _DEVICEINFO FAR *Next; // Must be first member
  81. DWORD DeviceNumber;
  82. DWORD DeviceType;
  83. HANDLE32 DeviceHandle;
  84. DWORD_PTR dwInstance; // client's instance data
  85. DWORD_PTR dwCallback; // client's callback
  86. DWORD dwCallback16; // wdmaud's 16-bit callback
  87. DWORD dwFlags; // Open flags
  88. LPVOID DataBuffer;
  89. DWORD DataBufferSize;
  90. volatile DWORD OpenDone; // for deferred open
  91. volatile DWORD OpenStatus; // for deferred open
  92. HANDLE HardwareCallbackEventHandle;
  93. DWORD dwCallbackType;
  94. DWORD dwID[MAXCALLBACKS];
  95. DWORD dwLineID;
  96. LONG ControlCallbackCount;
  97. DWORD dwFormat; // ANSI_TAG or UNICODE_TAG
  98. MMRESULT mmr; // Result of MM operation
  99. LPDEVICESTATE DeviceState;
  100. DWORD dwSig; //WADI as seen in memory.
  101. WCHAR wstrDeviceInterface[1]; // Device interface name
  102. } DEVICEINFO, FAR *LPDEVICEINFO;
  103. typedef struct _DEVICEINFO32 {
  104. UINT32 Next; // Must be first member
  105. DWORD DeviceNumber;
  106. DWORD DeviceType;
  107. UINT32 DeviceHandle;
  108. UINT32 dwInstance; // client's instance data
  109. UINT32 dwCallback; // client's callback
  110. DWORD dwCallback16; // wdmaud's 16-bit callback
  111. DWORD dwFlags; // Open flags
  112. UINT32 DataBuffer;
  113. DWORD DataBufferSize;
  114. volatile DWORD OpenDone; // for deferred open
  115. volatile DWORD OpenStatus; // for deferred open
  116. UINT32 HardwareCallbackEventHandle;
  117. DWORD dwCallbackType;
  118. DWORD dwID[MAXCALLBACKS];
  119. DWORD dwLineID;
  120. LONG ControlCallbackCount;
  121. DWORD dwFormat; // ANSI_TAG or UNICODE_TAG
  122. MMRESULT mmr; // Result of MM operation
  123. UINT32 DeviceState;
  124. DWORD dwSig; //WADI as seen in memory.
  125. WCHAR wstrDeviceInterface[1]; // Device interface name
  126. } DEVICEINFO32, FAR *LPDEVICEINFO32;
  127. #ifndef _WIN64
  128. // WARNING WARNING WARNING!!!!
  129. // If the below lines do not compile for 32 bit x86, you MUST sync the
  130. // above DEVICEINFO32 structure up with the DEVICEINFO structure.
  131. // It doesn't compile because someone didn't update DEVINCEINFO32 when
  132. // they changed DEVICEINFO.
  133. // Make SURE when you sync it up that you use UINT32 for all elements
  134. // that are normally 64bits on win64.
  135. // You MUST also update all places that thunk the above structure!
  136. // Look for all occurances of any of the DEVICEINFO32 typedefs in the
  137. // wdmaud.sys directory.
  138. struct deviceinfo_structures_are_in_sync {
  139. char x[(sizeof (DEVICEINFO32) == sizeof (DEVICEINFO)) ? 1 : -1];
  140. };
  141. // WARNING WARNING WARNING!!!
  142. // If above lines do not compile, see comment above and FIX!
  143. // DO NOT COMMENT OUT THE LINES THAT DON'T COMPILE
  144. #endif
  145. #ifdef _WIN64
  146. #pragma pack(push, 1)
  147. #define MAXDEVINTERFACE 256
  148. typedef struct {
  149. DEVICEINFO DeviceInfo;
  150. WCHAR Space[MAXDEVINTERFACE];
  151. } LOCALDEVICEINFO;
  152. #pragma pack(pop)
  153. #endif
  154. #define CDAUDIO_CHANNEL_BIAS 0x80
  155. #ifdef UNDER_NT
  156. typedef struct _MIDIDATA {
  157. KSSTREAM_HEADER StreamHeader;
  158. KSMUSICFORMAT MusicFormat;
  159. DWORD MusicData[3];
  160. } MIDIDATA, FAR *LPMIDIDATA;
  161. typedef struct _MIDIDATALISTENTRY {
  162. MIDIDATA MidiData;
  163. LPVOID pOverlapped; // Overlapped structure
  164. // for completion
  165. LPDEVICEINFO MidiDataDeviceInfo;
  166. struct _MIDIDATALISTENTRY *lpNext;
  167. #ifdef DEBUG
  168. DWORD dwSig; // MDLE as seen in memory
  169. #endif
  170. } MIDIDATALISTENTRY, FAR *LPMIDIDATALISTENTRY;
  171. #endif
  172. // IOCTL set for WDMAUD
  173. #ifdef UNDER_NT
  174. #include <devioctl.h>
  175. #define WDMAUD_CTL_CODE CTL_CODE
  176. #else
  177. #define FILE_DEVICE_SOUND 0x0000001d
  178. //
  179. // Define the method codes for how buffers are passed for I/O and FS controls
  180. //
  181. #define METHOD_BUFFERED 0
  182. #define METHOD_IN_DIRECT 1
  183. #define METHOD_OUT_DIRECT 2
  184. #define METHOD_NEITHER 3
  185. //
  186. // Define the access check value for any access
  187. //
  188. //
  189. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  190. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  191. // constants *MUST* always be in sync.
  192. //
  193. #define FILE_ANY_ACCESS 0
  194. #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
  195. #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
  196. #define WDMAUD_CTL_CODE( DeviceType, Function, Method, Access ) (ULONG)( \
  197. ((ULONG)(DeviceType) << 16) | ((ULONG)(Access) << 14) | ((ULONG)(Function) << 2) | (ULONG)(Method) \
  198. )
  199. #endif
  200. #define IOCTL_SOUND_BASE FILE_DEVICE_SOUND
  201. #define IOCTL_WDMAUD_BASE 0x0000
  202. #define IOCTL_WAVE_BASE 0x0040
  203. #define IOCTL_MIDI_BASE 0x0080
  204. #define IOCTL_MIXER_BASE 0x00C0
  205. #define IOCTL_WDMAUD_INIT WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0000, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  206. #define IOCTL_WDMAUD_ADD_DEVNODE WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0001, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  207. #define IOCTL_WDMAUD_REMOVE_DEVNODE WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  208. #define IOCTL_WDMAUD_GET_CAPABILITIES WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0003, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  209. #define IOCTL_WDMAUD_GET_NUM_DEVS WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0004, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  210. #define IOCTL_WDMAUD_OPEN_PIN WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0005, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  211. #define IOCTL_WDMAUD_CLOSE_PIN WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0006, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  212. #define IOCTL_WDMAUD_GET_VOLUME WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0007, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  213. #define IOCTL_WDMAUD_SET_VOLUME WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0008, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  214. #define IOCTL_WDMAUD_EXIT WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x0009, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  215. #define IOCTL_WDMAUD_SET_PREFERRED_DEVICE WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WDMAUD_BASE + 0x000a, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  216. #define IOCTL_WDMAUD_WAVE_OUT_PAUSE WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0000, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  217. #define IOCTL_WDMAUD_WAVE_OUT_PLAY WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0001, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  218. #define IOCTL_WDMAUD_WAVE_OUT_RESET WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  219. #define IOCTL_WDMAUD_WAVE_OUT_BREAKLOOP WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0003, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  220. #define IOCTL_WDMAUD_WAVE_OUT_GET_POS WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0004, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  221. #define IOCTL_WDMAUD_WAVE_OUT_SET_VOLUME WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0005, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  222. #define IOCTL_WDMAUD_WAVE_OUT_GET_VOLUME WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0006, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  223. #define IOCTL_WDMAUD_WAVE_OUT_WRITE_PIN WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0007, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  224. #define IOCTL_WDMAUD_WAVE_IN_STOP WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0010, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  225. #define IOCTL_WDMAUD_WAVE_IN_RECORD WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0011, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  226. #define IOCTL_WDMAUD_WAVE_IN_RESET WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0012, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  227. #define IOCTL_WDMAUD_WAVE_IN_GET_POS WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0013, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  228. #define IOCTL_WDMAUD_WAVE_IN_READ_PIN WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_WAVE_BASE + 0x0014, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  229. #define IOCTL_WDMAUD_MIDI_OUT_RESET WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0000, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  230. #define IOCTL_WDMAUD_MIDI_OUT_SET_VOLUME WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0001, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  231. #define IOCTL_WDMAUD_MIDI_OUT_GET_VOLUME WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  232. #define IOCTL_WDMAUD_MIDI_OUT_WRITE_DATA WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0003, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  233. #define IOCTL_WDMAUD_MIDI_OUT_WRITE_LONGDATA WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0004, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  234. #define IOCTL_WDMAUD_MIDI_IN_STOP WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0010, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  235. #define IOCTL_WDMAUD_MIDI_IN_RECORD WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0011, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  236. #define IOCTL_WDMAUD_MIDI_IN_RESET WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0012, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  237. #define IOCTL_WDMAUD_MIDI_IN_READ_PIN WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0013, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  238. #define IOCTL_WDMAUD_MIXER_OPEN WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIXER_BASE + 0x0000, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  239. #define IOCTL_WDMAUD_MIXER_CLOSE WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIXER_BASE + 0x0001, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  240. #define IOCTL_WDMAUD_MIXER_GETLINEINFO WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIXER_BASE + 0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  241. #define IOCTL_WDMAUD_MIXER_GETLINECONTROLS WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIXER_BASE + 0x0003, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  242. #define IOCTL_WDMAUD_MIXER_GETCONTROLDETAILS WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIXER_BASE + 0x0004, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  243. #define IOCTL_WDMAUD_MIXER_SETCONTROLDETAILS WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIXER_BASE + 0x0005, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  244. #define IOCTL_WDMAUD_MIXER_GETHARDWAREEVENTDATA WDMAUD_CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIXER_BASE + 0x0006, METHOD_BUFFERED, FILE_WRITE_ACCESS)