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