Change all SendAsyncCallback calls into the synchronous
[wine/wine-gecko.git] / dlls / winmm / winemm.h
blob47253590bbb2889055c9b07252f6928ca913c64b
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"
31 #define WINE_DEFAULT_WINMM_DRIVER "oss"
32 #define WINE_DEFAULT_WINMM_MAPPER "msacm.drv"
33 #define WINE_DEFAULT_WINMM_MIDI "midimap.dll"
35 typedef enum {
36 WINMM_MAP_NOMEM, /* ko, memory problem */
37 WINMM_MAP_MSGERROR, /* ko, unknown message */
38 WINMM_MAP_OK, /* ok, no memory allocated. to be sent to the proc. */
39 WINMM_MAP_OKMEM, /* ok, some memory allocated, need to call UnMapMsg. to be sent to the proc. */
40 } WINMM_MapType;
42 /* Who said goofy boy ? */
43 #define WINE_DI_MAGIC 0x900F1B01
45 typedef struct tagWINE_DRIVER
47 DWORD dwMagic;
48 /* as usual LPWINE_DRIVER == hDriver32 */
49 DWORD dwFlags;
50 union {
51 struct {
52 HMODULE hModule;
53 DRIVERPROC lpDrvProc;
54 DWORD_PTR dwDriverID;
55 } d32;
56 struct {
57 UINT16 hDriver16;
58 } d16;
59 } d;
60 struct tagWINE_DRIVER* lpPrevItem;
61 struct tagWINE_DRIVER* lpNextItem;
62 } WINE_DRIVER, *LPWINE_DRIVER;
64 typedef DWORD (CALLBACK *WINEMM_msgFunc16)(UINT16, WORD, DWORD, DWORD, DWORD);
65 typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT , UINT, DWORD, DWORD, DWORD);
67 /* for each loaded driver and each known type of driver, this structure contains
68 * the information needed to access it
70 typedef struct tagWINE_MM_DRIVER_PART {
71 int nIDMin; /* lower bound of global indexes for this type */
72 int nIDMax; /* hhigher bound of global indexes for this type */
73 union {
74 WINEMM_msgFunc32 fnMessage32; /* pointer to function */
75 WINEMM_msgFunc16 fnMessage16;
76 } u;
77 } WINE_MM_DRIVER_PART;
79 #define MMDRV_AUX 0
80 #define MMDRV_MIXER 1
81 #define MMDRV_MIDIIN 2
82 #define MMDRV_MIDIOUT 3
83 #define MMDRV_WAVEIN 4
84 #define MMDRV_WAVEOUT 5
85 #define MMDRV_MAX 6
87 /* each low-level .drv will be associated with an instance of this structure */
88 typedef struct tagWINE_MM_DRIVER {
89 HDRVR hDriver;
90 LPSTR drvname; /* name of the driver */
91 unsigned bIs32 : 1, /* TRUE if 32 bit driver, FALSE for 16 */
92 bIsMapper : 1; /* TRUE if mapper */
93 WINE_MM_DRIVER_PART parts[MMDRV_MAX];/* Information for all known types */
94 } WINE_MM_DRIVER, *LPWINE_MM_DRIVER;
96 typedef struct tagWINE_MLD {
97 /* EPP struct tagWINE_MLD* lpNext; */ /* not used so far */
98 UINT uDeviceID;
99 UINT type;
100 UINT mmdIndex; /* index to low-level driver in MMDrvs table */
101 DWORD dwDriverInstance; /* this value is driver related, as opposed to
102 * opendesc.dwInstance which is client (callback) related */
103 WORD bFrom32;
104 WORD dwFlags;
105 DWORD dwCallback;
106 DWORD dwClientInstance;
107 } WINE_MLD, *LPWINE_MLD;
109 typedef struct {
110 WINE_MLD mld;
111 } WINE_WAVE, *LPWINE_WAVE;
113 typedef struct {
114 WINE_MLD mld;
115 MIDIOPENDESC mod; /* FIXME: should be removed */
116 } WINE_MIDI, *LPWINE_MIDI;
118 typedef struct {
119 WINE_MLD mld;
120 } WINE_MIXER, *LPWINE_MIXER;
122 #define WINE_MMTHREAD_CREATED 0x4153494C /* "BSIL" */
123 #define WINE_MMTHREAD_DELETED 0xDEADDEAD
125 typedef struct {
126 DWORD dwSignature; /* 00 "BSIL" when ok, 0xDEADDEAD when being deleted */
127 DWORD dwCounter; /* 04 > 1 when in mmThread functions */
128 HANDLE hThread; /* 08 hThread */
129 DWORD dwThreadID; /* 0C */
130 DWORD fpThread; /* 10 address of thread proc (segptr or lin depending on dwFlags) */
131 DWORD dwThreadPmt; /* 14 parameter to be passed upon thread creation to fpThread */
132 LONG dwSignalCount; /* 18 counter used for signaling */
133 HANDLE hEvent; /* 1C event */
134 HANDLE hVxD; /* 20 return from OpenVxDHandle */
135 DWORD dwStatus; /* 24 0x00, 0x10, 0x20, 0x30 */
136 DWORD dwFlags; /* 28 dwFlags upon creation */
137 UINT16 hTask; /* 2C handle to created task */
138 } WINE_MMTHREAD;
140 typedef struct tagWINE_MCIDRIVER {
141 UINT wDeviceID;
142 UINT wType;
143 LPWSTR lpstrElementName;
144 LPWSTR lpstrDeviceType;
145 LPWSTR lpstrAlias;
146 HDRVR hDriver;
147 DWORD dwPrivate;
148 YIELDPROC lpfnYieldProc;
149 DWORD dwYieldData;
150 BOOL bIs32;
151 DWORD CreatorThread;
152 UINT uTypeCmdTable;
153 UINT uSpecificCmdTable;
154 struct tagWINE_MCIDRIVER*lpNext;
155 } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
157 #define WINE_TIMER_IS32 0x80
159 typedef struct tagWINE_TIMERENTRY {
160 UINT wDelay;
161 UINT wResol;
162 LPTIMECALLBACK lpFunc; /* can be lots of things */
163 DWORD dwUser;
164 UINT16 wFlags;
165 UINT16 wTimerID;
166 DWORD dwTriggerTime;
167 struct tagWINE_TIMERENTRY* lpNext;
168 } WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
170 enum mmioProcType {MMIO_PROC_16,MMIO_PROC_32A,MMIO_PROC_32W};
172 struct IOProcList
174 struct IOProcList*pNext; /* Next item in linked list */
175 FOURCC fourCC; /* four-character code identifying IOProc */
176 LPMMIOPROC pIOProc; /* pointer to IProc */
177 enum mmioProcType type; /* 16, 32A or 32W */
178 int count; /* number of objects linked to it */
181 typedef struct tagWINE_MMIO {
182 MMIOINFO info;
183 struct tagWINE_MMIO* lpNext;
184 struct IOProcList* ioProc;
185 unsigned bTmpIOProc : 1,
186 bBufferLoaded : 1;
187 DWORD segBuffer16;
188 DWORD dwFileSize;
189 } WINE_MMIO, *LPWINE_MMIO;
191 typedef struct tagWINE_PLAYSOUND {
192 unsigned bLoop : 1,
193 bAlloc : 1;
194 LPCWSTR pszSound;
195 HMODULE hMod;
196 DWORD fdwSound;
197 HANDLE hThread;
198 struct tagWINE_PLAYSOUND* lpNext;
199 } WINE_PLAYSOUND, *LPWINE_PLAYSOUND;
201 typedef struct tagWINE_MM_IDATA {
202 /* winmm part */
203 HANDLE hWinMM32Instance;
204 HANDLE hWinMM16Instance;
205 CRITICAL_SECTION cs;
206 /* mci part */
207 LPWINE_MCIDRIVER lpMciDrvs;
208 /* low level drivers (unused yet) */
209 /* LPWINE_WAVE lpWave; */
210 /* LPWINE_MIDI lpMidi; */
211 /* LPWINE_MIXER lpMixer; */
212 /* mmio part */
213 LPWINE_MMIO lpMMIO;
214 /* playsound and sndPlaySound */
215 WINE_PLAYSOUND* lpPlaySound;
216 HANDLE psLastEvent;
217 HANDLE psStopEvent;
218 } WINE_MM_IDATA, *LPWINE_MM_IDATA;
220 /* function prototypes */
222 typedef LONG (*MCIPROC)(DWORD, HDRVR, DWORD, DWORD, DWORD);
223 typedef WINMM_MapType (*MMDRV_MAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2);
224 typedef WINMM_MapType (*MMDRV_UNMAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT ret);
226 LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr);
227 BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz);
228 LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2);
229 void DRIVER_UnloadAll(void);
231 BOOL MMDRV_Init(void);
232 void MMDRV_Exit(void);
233 UINT MMDRV_GetNum(UINT);
234 LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
235 DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32);
236 void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld);
237 DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwParam2);
238 DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg);
239 LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID);
240 LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped);
241 DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2, BOOL bFrom32);
242 UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, DWORD dwParam2);
243 BOOL MMDRV_Is32(unsigned int);
244 void MMDRV_InstallMap(unsigned int, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC,
245 MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, LPDRVCALLBACK);
247 WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID);
248 UINT MCI_GetDriverFromString(LPCWSTR str);
249 DWORD MCI_WriteString(LPWSTR lpDstStr, DWORD dstSize, LPCWSTR lpSrcStr);
250 const char* MCI_MessageToString(UINT wMsg);
251 UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data);
252 LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2);
253 DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
254 DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
255 DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
256 UINT MCI_SetCommandTable(void *table, UINT uDevType);
257 BOOL MCI_DeleteCommandTable(UINT uTbl, BOOL delete);
258 LPWSTR MCI_strdupAtoW(LPCSTR str);
259 LPSTR MCI_strdupWtoA(LPCWSTR str);
261 BOOL WINMM_CheckForMMSystem(void);
262 const char* WINMM_ErrorToString(MMRESULT error);
264 UINT MIXER_Open(LPHMIXER lphMix, UINT uDeviceID, DWORD_PTR dwCallback,
265 DWORD_PTR dwInstance, DWORD fdwOpen, BOOL bFrom32);
266 UINT MIDI_OutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback,
267 DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
268 UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback,
269 DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
270 MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
271 DWORD cMidi, DWORD_PTR dwCallback,
272 DWORD_PTR dwInstance, DWORD fdwOpen, BOOL bFrom32);
273 UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
274 LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
275 DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
277 HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo,
278 DWORD dwOpenFlags, enum mmioProcType type);
279 LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
280 DWORD dwFlags, enum mmioProcType type);
281 LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
282 LPARAM lParam2, enum mmioProcType type);
283 LPWINE_MMIO MMIO_Get(HMMIO h);
285 WORD TIME_SetEventInternal(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc,
286 DWORD dwUser, UINT wFlags);
287 void TIME_MMTimeStart(void);
288 void TIME_MMTimeStop(void);
290 /* Global variables */
291 extern WINE_MM_IDATA WINMM_IData;
293 /* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded
294 * NULL otherwise
296 extern WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16);
297 extern LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM);
298 extern LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM);
299 extern LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM);
300 extern WINMM_MapType (*pFnMciMapMsg16To32W)(WORD,WORD,DWORD,DWORD_PTR*);
301 extern WINMM_MapType (*pFnMciUnMapMsg16To32W)(WORD,WORD,DWORD,DWORD_PTR);
302 extern WINMM_MapType (*pFnMciMapMsg32WTo16)(WORD,WORD,DWORD,DWORD_PTR*);
303 extern WINMM_MapType (*pFnMciUnMapMsg32WTo16)(WORD,WORD,DWORD,DWORD_PTR);
304 extern LRESULT (*pFnCallMMDrvFunc16)(DWORD /* in fact FARPROC16 */,WORD,WORD,LONG,LONG,LONG);
305 extern unsigned (*pFnLoadMMDrvFunc16)(LPCSTR,LPWINE_DRIVER, LPWINE_MM_DRIVER);
306 extern LRESULT (*pFnMmioCallback16)(DWORD,LPMMIOINFO,UINT,LPARAM,LPARAM);
307 extern void (WINAPI *pFnReleaseThunkLock)(DWORD*);
308 extern void (WINAPI *pFnRestoreThunkLock)(DWORD);
309 /* GetDriverFlags() returned bits is not documented (nor the call itself)
310 * Here are Wine only definitions of the bits
312 #define WINE_GDF_EXIST 0x80000000
313 #define WINE_GDF_16BIT 0x10000000