Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / winmm / winemm.h
blobed288cd482cdc3e22f0517b87b19bd50e1b3ce07
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*****************************************************************************
4 * Copyright 1998, Luiz Otavio L. Zorzella
5 * 1999, Eric Pouech
7 * Purpose: multimedia declarations (internal to WINMM & MMSYSTEM DLLs)
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *****************************************************************************
25 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "mmddk.h"
30 #include "wine/mmsystem16.h"
31 #include "wownt32.h"
33 typedef DWORD (WINAPI *MessageProc16)(UINT16 wDevID, UINT16 wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
34 typedef DWORD (WINAPI *MessageProc32)(UINT wDevID, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
36 typedef enum {
37 WINMM_MAP_NOMEM, /* ko, memory problem */
38 WINMM_MAP_MSGERROR, /* ko, unknown message */
39 WINMM_MAP_OK, /* ok, no memory allocated. to be sent to the proc. */
40 WINMM_MAP_OKMEM, /* ok, some memory allocated, need to call UnMapMsg. to be sent to the proc. */
41 } WINMM_MapType;
43 /* Who said goofy boy ? */
44 #define WINE_DI_MAGIC 0x900F1B01
46 typedef struct tagWINE_DRIVER
48 DWORD dwMagic;
49 /* as usual LPWINE_DRIVER == hDriver32 */
50 DWORD dwFlags;
51 union {
52 struct {
53 HMODULE hModule;
54 DRIVERPROC lpDrvProc;
55 DWORD dwDriverID;
56 } d32;
57 struct {
58 HDRVR16 hDriver16;
59 } d16;
60 } d;
61 struct tagWINE_DRIVER* lpPrevItem;
62 struct tagWINE_DRIVER* lpNextItem;
63 } WINE_DRIVER, *LPWINE_DRIVER;
65 typedef DWORD (CALLBACK *WINEMM_msgFunc16)(UINT16, WORD, DWORD, DWORD, DWORD);
66 typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT , UINT, DWORD, DWORD, DWORD);
68 /* for each loaded driver and each known type of driver, this structure contains
69 * the information needed to access it
71 typedef struct tagWINE_MM_DRIVER_PART {
72 int nIDMin; /* lower bound of global indexes for this type */
73 int nIDMax; /* hhigher bound of global indexes for this type */
74 union {
75 WINEMM_msgFunc32 fnMessage32; /* pointer to fonction */
76 WINEMM_msgFunc16 fnMessage16;
77 } u;
78 } WINE_MM_DRIVER_PART;
80 #define MMDRV_AUX 0
81 #define MMDRV_MIXER 1
82 #define MMDRV_MIDIIN 2
83 #define MMDRV_MIDIOUT 3
84 #define MMDRV_WAVEIN 4
85 #define MMDRV_WAVEOUT 5
86 #define MMDRV_MAX 6
88 /* each low-level .drv will be associated with an instance of this structure */
89 typedef struct tagWINE_MM_DRIVER {
90 HDRVR hDriver;
91 LPSTR drvname; /* name of the driver */
92 BOOL bIs32 : 1, /* TRUE if 32 bit driver, FALSE for 16 */
93 bIsMapper : 1; /* TRUE if mapper */
94 WINE_MM_DRIVER_PART parts[MMDRV_MAX];/* Information for all known types */
95 } WINE_MM_DRIVER, *LPWINE_MM_DRIVER;
97 typedef struct tagWINE_MLD {
98 /* EPP struct tagWINE_MLD* lpNext; */ /* not used so far */
99 UINT uDeviceID;
100 UINT type;
101 UINT mmdIndex; /* index to low-level driver in MMDrvs table */
102 DWORD dwDriverInstance; /* this value is driver related, as opposed to
103 * opendesc.dwInstance which is client (callback) related */
104 WORD bFrom32;
105 WORD dwFlags;
106 DWORD dwCallback;
107 DWORD dwClientInstance;
108 } WINE_MLD, *LPWINE_MLD;
110 typedef struct {
111 WINE_MLD mld;
112 } WINE_WAVE, *LPWINE_WAVE;
114 typedef struct {
115 WINE_MLD mld;
116 MIDIOPENDESC mod; /* FIXME: should be removed */
117 } WINE_MIDI, *LPWINE_MIDI;
119 typedef struct {
120 WINE_MLD mld;
121 } WINE_MIXER, *LPWINE_MIXER;
123 #define WINE_MMTHREAD_CREATED 0x4153494C /* "BSIL" */
124 #define WINE_MMTHREAD_DELETED 0xDEADDEAD
126 typedef struct {
127 DWORD dwSignature; /* 00 "BSIL" when ok, 0xDEADDEAD when being deleted */
128 DWORD dwCounter; /* 04 > 1 when in mmThread functions */
129 HANDLE hThread; /* 08 hThread */
130 DWORD dwThreadID; /* 0C */
131 FARPROC16 fpThread; /* 10 address of thread proc (segptr or lin depending on dwFlags) */
132 DWORD dwThreadPmt; /* 14 parameter to be passed upon thread creation to fpThread */
133 DWORD dwSignalCount; /* 18 counter used for signaling */
134 HANDLE hEvent; /* 1C event */
135 HANDLE hVxD; /* 20 return from OpenVxDHandle */
136 DWORD dwStatus; /* 24 0x00, 0x10, 0x20, 0x30 */
137 DWORD dwFlags; /* 28 dwFlags upon creation */
138 HANDLE16 hTask; /* 2C handle to created task */
139 } WINE_MMTHREAD;
141 typedef struct tagWINE_MCIDRIVER {
142 UINT wDeviceID;
143 UINT wType;
144 LPSTR lpstrElementName;
145 LPSTR lpstrDeviceType;
146 LPSTR lpstrAlias;
147 HDRVR hDriver;
148 DRIVERPROC16 driverProc;
149 DWORD dwPrivate;
150 YIELDPROC lpfnYieldProc;
151 DWORD dwYieldData;
152 BOOL bIs32;
153 DWORD CreatorThread;
154 UINT uTypeCmdTable;
155 UINT uSpecificCmdTable;
156 struct tagWINE_MCIDRIVER*lpNext;
157 } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
159 #define WINE_TIMER_IS32 0x80
161 typedef struct tagWINE_TIMERENTRY {
162 UINT wDelay;
163 UINT wResol;
164 FARPROC16 lpFunc;
165 DWORD dwUser;
166 UINT16 wFlags;
167 UINT16 wTimerID;
168 UINT uCurTime;
169 struct tagWINE_TIMERENTRY* lpNext;
170 } WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
172 enum mmioProcType {MMIO_PROC_16,MMIO_PROC_32A,MMIO_PROC_32W};
174 struct IOProcList
176 struct IOProcList*pNext; /* Next item in linked list */
177 FOURCC fourCC; /* four-character code identifying IOProc */
178 LPMMIOPROC pIOProc; /* pointer to IProc */
179 enum mmioProcType type; /* 16, 32A or 32W */
180 int count; /* number of objects linked to it */
183 typedef struct tagWINE_MMIO {
184 MMIOINFO info;
185 struct tagWINE_MMIO* lpNext;
186 struct IOProcList* ioProc;
187 BOOL bTmpIOProc : 1,
188 bBufferLoaded : 1;
189 SEGPTR segBuffer16;
190 DWORD dwFileSize;
191 } WINE_MMIO, *LPWINE_MMIO;
193 typedef struct tagWINE_PLAYSOUND {
194 BOOL bLoop : 1,
195 bAlloc : 1;
196 LPCWSTR pszSound;
197 HMODULE hMod;
198 DWORD fdwSound;
199 struct tagWINE_PLAYSOUND* lpNext;
200 } WINE_PLAYSOUND, *LPWINE_PLAYSOUND;
202 typedef struct tagWINE_MM_IDATA {
203 /* winmm part */
204 HANDLE hWinMM32Instance;
205 HANDLE hWinMM16Instance;
206 CRITICAL_SECTION cs;
207 /* mm timer part */
208 HANDLE hMMTimer;
209 DWORD mmSysTimeMS;
210 LPWINE_TIMERENTRY lpTimerList;
211 int nSizeLpTimers;
212 LPWINE_TIMERENTRY lpTimers;
213 /* mci part */
214 LPWINE_MCIDRIVER lpMciDrvs;
215 /* low level drivers (unused yet) */
216 /* LPWINE_WAVE lpWave; */
217 /* LPWINE_MIDI lpMidi; */
218 /* LPWINE_MIXER lpMixer; */
219 /* mmio part */
220 LPWINE_MMIO lpMMIO;
221 /* playsound and sndPlaySound */
222 WINE_PLAYSOUND* lpPlaySound;
223 HANDLE psLastEvent;
224 HANDLE psStopEvent;
225 } WINE_MM_IDATA, *LPWINE_MM_IDATA;
227 /* function prototypes */
229 typedef LONG (*MCIPROC16)(DWORD, HDRVR16, WORD, DWORD, DWORD);
230 typedef LONG (*MCIPROC)(DWORD, HDRVR, DWORD, DWORD, DWORD);
231 typedef WINMM_MapType (*MMDRV_MAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2);
232 typedef WINMM_MapType (*MMDRV_UNMAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT ret);
234 LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr);
235 BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz);
236 LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2);
237 void DRIVER_UnloadAll(void);
239 BOOL MMDRV_Init(void);
240 void MMDRV_Exit(void);
241 UINT MMDRV_GetNum(UINT);
242 LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
243 DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32);
244 void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld);
245 DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwParam2);
246 DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg);
247 LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID);
248 LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped);
249 DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
250 UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, DWORD dwParam2);
251 BOOL MMDRV_Is32(unsigned int);
252 void MMDRV_InstallMap(unsigned int, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC,
253 MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, LPDRVCALLBACK);
255 BOOL MCI_Init(void);
256 WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID);
257 UINT MCI_GetDriverFromString(LPCSTR str);
258 DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr);
259 const char* MCI_MessageToString(UINT16 wMsg);
260 UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data);
261 LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2);
262 DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
263 DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
264 DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
265 UINT MCI_SetCommandTable(void *table, UINT uDevType);
267 BOOL WINMM_CheckForMMSystem(void);
269 UINT MIXER_Open(LPHMIXER lphMix, UINT uDeviceID, DWORD dwCallback,
270 DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32);
271 UINT MIDI_OutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD dwCallback,
272 DWORD dwInstance, DWORD dwFlags, BOOL bFrom32);
273 UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD dwCallback,
274 DWORD dwInstance, DWORD dwFlags, BOOL bFrom32);
275 MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
276 DWORD cMidi, DWORD dwCallback,
277 DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32);
278 UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
279 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
280 DWORD dwInstance, DWORD dwFlags, BOOL bFrom32);
282 HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo,
283 DWORD dwOpenFlags, enum mmioProcType type);
284 LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
285 DWORD dwFlags, enum mmioProcType type);
286 LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
287 LPARAM lParam2, enum mmioProcType type);
288 LPWINE_MMIO MMIO_Get(HMMIO h);
290 WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
291 FARPROC16 lpFunc, DWORD dwUser, UINT wFlags);
292 void TIME_MMTimeStart(void);
293 void TIME_MMTimeStop(void);
295 /* Global variables */
296 extern LPWINE_MM_IDATA WINMM_IData;
298 /* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded
299 * NULL otherwise
301 extern WINE_MMTHREAD* (*pFnGetMMThread16)(HANDLE16);
302 extern LPWINE_DRIVER (*pFnOpenDriver16)(LPCSTR,LPCSTR,LPARAM);
303 extern LRESULT (*pFnCloseDriver16)(HDRVR16,LPARAM,LPARAM);
304 extern LRESULT (*pFnSendMessage16)(HDRVR16,UINT,LPARAM,LPARAM);
305 extern WINMM_MapType (*pFnMciMapMsg16To32A)(WORD,WORD,DWORD*);
306 extern WINMM_MapType (*pFnMciUnMapMsg16To32A)(WORD,WORD,DWORD);
307 extern WINMM_MapType (*pFnMciMapMsg32ATo16)(WORD,WORD,DWORD,DWORD*);
308 extern WINMM_MapType (*pFnMciUnMapMsg32ATo16)(WORD,WORD,DWORD,DWORD);
309 extern LRESULT (*pFnCallMMDrvFunc16)(FARPROC16,WORD,WORD,LONG,LONG,LONG);
310 extern unsigned (*pFnLoadMMDrvFunc16)(LPCSTR,LPWINE_DRIVER, LPWINE_MM_DRIVER);
311 extern LRESULT (*pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM);
313 /* mmsystem (16 bit files) only functions */
314 void MMDRV_Init16(void);
315 void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16);
316 void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, const MMTIME* mmt32);
318 /* HANDLE16 -> HANDLE conversions */
319 #define HDRVR_32(h16) ((HDRVR)(ULONG_PTR)(h16))
320 #define HMIDI_32(h16) ((HMIDI)(ULONG_PTR)(h16))
321 #define HMIDIIN_32(h16) ((HMIDIIN)(ULONG_PTR)(h16))
322 #define HMIDIOUT_32(h16) ((HMIDIOUT)(ULONG_PTR)(h16))
323 #define HMIDISTRM_32(h16) ((HMIDISTRM)(ULONG_PTR)(h16))
324 #define HMIXER_32(h16) ((HMIXER)(ULONG_PTR)(h16))
325 #define HMIXEROBJ_32(h16) ((HMIXEROBJ)(ULONG_PTR)(h16))
326 #define HMMIO_32(h16) ((HMMIO)(ULONG_PTR)(h16))
327 #define HWAVE_32(h16) ((HWAVE)(ULONG_PTR)(h16))
328 #define HWAVEIN_32(h16) ((HWAVEIN)(ULONG_PTR)(h16))
329 #define HWAVEOUT_32(h16) ((HWAVEOUT)(ULONG_PTR)(h16))
331 /* HANDLE -> HANDLE16 conversions */
332 #define HDRVR_16(h32) (LOWORD(h32))
333 #define HMIDI_16(h32) (LOWORD(h32))
334 #define HMIDIIN_16(h32) (LOWORD(h32))
335 #define HMIDIOUT_16(h32) (LOWORD(h32))
336 #define HMIDISTRM_16(h32) (LOWORD(h32))
337 #define HMIXER_16(h32) (LOWORD(h32))
338 #define HMIXEROBJ_16(h32) (LOWORD(h32))
339 #define HMMIO_16(h32) (LOWORD(h32))
340 #define HWAVE_16(h32) (LOWORD(h32))
341 #define HWAVEIN_16(h32) (LOWORD(h32))
342 #define HWAVEOUT_16(h32) (LOWORD(h32))