1 /* 2 * 3 * COPYRIGHT: See COPYING in the top level directory 4 * PROJECT: ReactOS Multimedia 5 * FILE: dll/win32/mmdrv/mmdrv.h 6 * PURPOSE: Multimedia User Mode Driver (header) 7 * PROGRAMMER: Andrew Greenwood 8 * Aleksey Bragin 9 * UPDATE HISTORY: 10 * Jan 30, 2004: Imported into ReactOS tree 11 * Jan 10, 2007: Rewritten and tidied up 12 */ 13 14 #ifndef MMDRV_H 15 #define MMDRV_H 16 17 #include <stdarg.h> 18 19 #define WIN32_NO_STATUS 20 #include <windef.h> 21 #include <winbase.h> 22 #include <winioctl.h> 23 24 #include "mmioctl.h" 25 #include "mmddk.h" 26 27 /* Need to check these */ 28 #define MAX_DEVICES 256 29 #define MAX_DEVICE_NAME_LENGTH 256 30 #define MAX_BUFFER_SIZE 1048576 31 #define MAX_WAVE_BYTES 1048576 32 33 /* Custom flag set when overlapped I/O is done */ 34 #define WHDR_COMPLETE 0x80000000 35 36 37 /* 38 The kinds of devices which MMSYSTEM/WINMM may request from us. 39 */ 40 41 typedef enum 42 { 43 WaveOutDevice, 44 WaveInDevice, 45 MidiOutDevice, 46 MidiInDevice, 47 AuxDevice 48 } DeviceType; 49 50 #define IsWaveDevice(devicetype) \ 51 ( ( devicetype == WaveOutDevice ) || ( devicetype == WaveInDevice ) ) 52 53 #define IsMidiDevice(devicetype) \ 54 ( ( devicetype == MidiOutDevice ) || ( devicetype == MidiInDevice ) ) 55 56 #define IsAuxDevice(devicetype) \ 57 ( devicetype == AuxDevice ) 58 59 60 /* 61 We use these structures to store information regarding open devices. Since 62 the main structure gets destroyed when a device is closed, I call this a 63 "session". 64 */ 65 66 typedef struct 67 { 68 OVERLAPPED overlap; 69 LPWAVEHDR header; 70 } WaveOverlapInfo; 71 72 /* 73 typedef enum 74 { 75 WaveAddBuffer, 76 WaveClose, 77 WaveReset, 78 WaveRestart, 79 SessionThreadTerminate, 80 InvalidFunction 81 } ThreadFunction; 82 */ 83 84 /* Our own values, used with the session threads */ 85 typedef DWORD ThreadFunction; 86 #define DRVM_TERMINATE 0xFFFFFFFE 87 #define DRVM_INVALID 0xFFFFFFFF 88 89 typedef enum 90 { 91 WavePlaying, 92 WaveStopped, 93 WaveReset, 94 WaveRestart 95 } WaveState; 96 97 typedef union 98 { 99 PWAVEHDR wave_header; 100 PMIDIHDR midi_header; 101 } MediaHeader; 102 103 /* 104 typedef union 105 { 106 MediaHeader header; 107 } ThreadParameter; 108 */ 109 110 typedef struct _ThreadInfo 111 { 112 HANDLE handle; 113 HANDLE ready_event; 114 HANDLE go_event; 115 116 /*ThreadFunction function;*/ 117 DWORD function; 118 PVOID parameter; 119 120 MMRESULT result; 121 } ThreadInfo; 122 123 typedef struct _LoopInfo 124 { 125 PWAVEHDR head; 126 DWORD iterations; 127 } LoopInfo; 128 129 typedef struct _SessionInfo 130 { 131 struct _SessionInfo* next; 132 133 DeviceType device_type; 134 UINT device_id; 135 136 HANDLE kernel_device_handle; 137 138 /* These are all the same */ 139 union 140 { 141 HDRVR mme_handle; 142 HWAVE mme_wave_handle; 143 HMIDI mme_midi_handle; 144 }; 145 146 /* If playback is paused or not */ 147 BOOL is_paused; 148 149 /* Stuff passed to us from winmm */ 150 DWORD_PTR app_user_data; 151 DWORD_PTR callback; 152 153 DWORD flags; 154 155 /* Can only be one or the other */ 156 union 157 { 158 PWAVEHDR wave_queue; 159 PMIDIHDR midi_queue; 160 }; 161 162 /* Current playback point */ 163 //PWAVEHDR next_buffer; 164 165 /* Where in the current buffer we are */ 166 DWORD buffer_position; 167 168 // DWORD remaining_bytes; 169 170 LoopInfo loop; 171 172 ThreadInfo thread; 173 } SessionInfo; 174 175 #undef ASSERT 176 #define ASSERT(condition) \ 177 if ( ! (condition) ) \ 178 DPRINT("ASSERT FAILED: %s\n", #condition); 179 180 /* 181 MME interface 182 */ 183 184 BOOL 185 NotifyClient( 186 SessionInfo* session_info, 187 DWORD message, 188 DWORD_PTR parameter1, 189 DWORD_PTR parameter2); 190 191 192 /* 193 Helpers 194 */ 195 196 MMRESULT 197 ErrorToMmResult(UINT error_code); 198 199 200 /* Kernel interface */ 201 202 MMRESULT 203 CobbleDeviceName( 204 DeviceType device_type, 205 UINT device_id, 206 PWCHAR out_device_name); 207 208 MMRESULT 209 OpenKernelDevice( 210 DeviceType device_type, 211 UINT device_id, 212 DWORD access, 213 HANDLE* handle); 214 215 VOID 216 CloseKernelDevice(HANDLE device_handle); 217 218 MMRESULT 219 SetDeviceData( 220 HANDLE device_handle, 221 DWORD ioctl, 222 PBYTE input_buffer, 223 DWORD buffer_size); 224 225 MMRESULT 226 GetDeviceData( 227 HANDLE device_handle, 228 DWORD ioctl, 229 PBYTE output_buffer, 230 DWORD buffer_size); 231 232 233 /* Session management */ 234 235 MMRESULT 236 CreateSession( 237 DeviceType device_type, 238 UINT device_id, 239 SessionInfo** session_info); 240 241 VOID 242 DestroySession(SessionInfo* session); 243 244 SessionInfo* 245 GetSession( 246 DeviceType device_type, 247 UINT device_id); 248 249 MMRESULT 250 StartSessionThread(SessionInfo* session_info); 251 252 MMRESULT 253 CallSessionThread( 254 SessionInfo* session_info, 255 ThreadFunction function, 256 PVOID thread_parameter); 257 258 DWORD 259 HandleBySessionThread( 260 DWORD_PTR private_handle, 261 DWORD_PTR message, 262 DWORD_PTR parameter); 263 264 265 /* General */ 266 267 DWORD 268 GetDeviceCount(DeviceType device_type); 269 270 DWORD 271 GetDeviceCapabilities( 272 DeviceType device_type, 273 UINT device_id, 274 DWORD_PTR capabilities, 275 DWORD capabilities_size); 276 277 DWORD 278 OpenDevice( 279 DeviceType device_type, 280 UINT device_id, 281 PVOID open_descriptor, 282 DWORD flags, 283 DWORD_PTR private_handle); 284 285 DWORD 286 CloseDevice( 287 DWORD_PTR private_handle); 288 289 DWORD 290 PauseDevice( 291 DWORD private_handle); 292 293 DWORD 294 RestartDevice( 295 DWORD private_handle); 296 297 DWORD 298 ResetDevice( 299 DWORD private_handle); 300 301 DWORD 302 GetPosition( 303 DWORD private_handle, 304 PMMTIME time, 305 DWORD time_size); 306 307 DWORD 308 BreakLoop(DWORD private_handle); 309 310 DWORD 311 QueryWaveFormat( 312 DeviceType device_type, 313 PVOID lpFormat); 314 315 DWORD 316 WriteWaveBuffer( 317 DWORD_PTR private_handle, 318 PWAVEHDR wave_header, 319 DWORD wave_header_size); 320 321 322 323 324 325 /* wave thread */ 326 327 DWORD 328 WaveThread(LPVOID parameter); 329 330 331 /* Wave I/O */ 332 333 VOID 334 PerformWaveIO(SessionInfo* session_info); 335 336 337 extern CRITICAL_SECTION critical_section; 338 339 #endif /* MMDRV_H */ 340