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