Some other synchronisation issues.
[wine.git] / dlls / winmm / winemm.h
blob6d7b1c399f329098f87c58a9048c9e7cfbce5175
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 "mmddk.h"
27 typedef DWORD (WINAPI *MessageProc16)(UINT16 wDevID, UINT16 wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
28 typedef DWORD (WINAPI *MessageProc32)(UINT wDevID, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
30 /* Who said goofy boy ? */
31 #define WINE_DI_MAGIC 0x900F1B01
33 typedef struct tagWINE_DRIVER
35 DWORD dwMagic;
36 /* as usual LPWINE_DRIVER == hDriver32 */
37 DWORD dwFlags;
38 union {
39 struct {
40 HMODULE hModule;
41 DRIVERPROC lpDrvProc;
42 DWORD dwDriverID;
43 } d32;
44 struct {
45 HDRVR16 hDriver16;
46 } d16;
47 } d;
48 struct tagWINE_DRIVER* lpPrevItem;
49 struct tagWINE_DRIVER* lpNextItem;
50 } WINE_DRIVER, *LPWINE_DRIVER;
52 typedef struct tagWINE_MLD {
53 /* EPP struct tagWINE_MLD* lpNext; */ /* not used so far */
54 UINT uDeviceID;
55 UINT type;
56 UINT mmdIndex; /* index to low-level driver in MMDrvs table */
57 DWORD dwDriverInstance; /* this value is driver related, as opposed to
58 * opendesc.dwInstance which is client (callback) related */
59 WORD bFrom32;
60 WORD dwFlags;
61 DWORD dwCallback;
62 DWORD dwClientInstance;
63 } WINE_MLD, *LPWINE_MLD;
65 typedef struct {
66 WINE_MLD mld;
67 } WINE_WAVE, *LPWINE_WAVE;
69 typedef struct {
70 WINE_MLD mld;
71 MIDIOPENDESC mod; /* FIXME: should be removed */
72 } WINE_MIDI, *LPWINE_MIDI;
74 typedef struct {
75 WINE_MLD mld;
76 } WINE_MIXER, *LPWINE_MIXER;
78 extern BOOL MMDRV_Init(void);
79 extern UINT MMDRV_GetNum(UINT);
80 extern LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
81 DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32);
82 extern void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld);
83 extern DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwParam2);
84 extern DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg);
85 extern LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID);
86 extern LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped);
87 extern DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
88 extern UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, DWORD dwParam2);
90 #define MMDRV_AUX 0
91 #define MMDRV_MIXER 1
92 #define MMDRV_MIDIIN 2
93 #define MMDRV_MIDIOUT 3
94 #define MMDRV_WAVEIN 4
95 #define MMDRV_WAVEOUT 5
96 #define MMDRV_MAX 6
98 #define WINE_MMTHREAD_CREATED 0x4153494C /* "BSIL" */
99 #define WINE_MMTHREAD_DELETED 0xDEADDEAD
101 typedef struct {
102 DWORD dwSignature; /* 00 "BSIL" when ok, 0xDEADDEAD when being deleted */
103 DWORD dwCounter; /* 04 > 1 when in mmThread functions */
104 HANDLE hThread; /* 08 hThread */
105 DWORD dwThreadID; /* 0C */
106 FARPROC16 fpThread; /* 10 address of thread proc (segptr or lin depending on dwFlags) */
107 DWORD dwThreadPmt; /* 14 parameter to be passed upon thread creation to fpThread */
108 DWORD dwSignalCount; /* 18 counter used for signaling */
109 HANDLE hEvent; /* 1C event */
110 HANDLE hVxD; /* 20 return from OpenVxDHandle */
111 DWORD dwStatus; /* 24 0x00, 0x10, 0x20, 0x30 */
112 DWORD dwFlags; /* 28 dwFlags upon creation */
113 HANDLE16 hTask; /* 2C handle to created task */
114 } WINE_MMTHREAD;
116 typedef struct tagWINE_MCIDRIVER {
117 UINT wDeviceID;
118 UINT wType;
119 LPSTR lpstrElementName;
120 LPSTR lpstrDeviceType;
121 LPSTR lpstrAlias;
122 HDRVR hDriver;
123 DRIVERPROC16 driverProc;
124 DWORD dwPrivate;
125 YIELDPROC lpfnYieldProc;
126 DWORD dwYieldData;
127 BOOL bIs32;
128 HTASK16 hCreatorTask;
129 UINT uTypeCmdTable;
130 UINT uSpecificCmdTable;
131 struct tagWINE_MCIDRIVER*lpNext;
132 } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
134 #define WINE_TIMER_IS32 0x80
136 typedef struct tagWINE_TIMERENTRY {
137 UINT wDelay;
138 UINT wResol;
139 FARPROC16 lpFunc;
140 DWORD dwUser;
141 UINT16 wFlags;
142 UINT16 wTimerID;
143 UINT uCurTime;
144 struct tagWINE_TIMERENTRY* lpNext;
145 } WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
147 typedef struct tagWINE_MMIO {
148 MMIOINFO info;
149 struct IOProcList* ioProc;
150 BOOL bTmpIOProc;
151 HANDLE hMem;
152 SEGPTR buffer16;
153 struct tagWINE_MMIO* lpNext;
154 BOOL bBufferLoaded;
155 DWORD dwFileSize;
156 } WINE_MMIO, *LPWINE_MMIO;
158 typedef struct tagWINE_PLAYSOUND {
159 BOOL bLoop : 1,
160 bAlloc : 1;
161 LPCWSTR pszSound;
162 HMODULE hMod;
163 DWORD fdwSound;
164 struct tagWINE_PLAYSOUND* lpNext;
165 } WINE_PLAYSOUND, *LPWINE_PLAYSOUND;
167 typedef struct tagWINE_MM_IDATA {
168 /* iData reference */
169 DWORD dwThisProcess;
170 struct tagWINE_MM_IDATA* lpNextIData;
171 /* winmm part */
172 HANDLE hWinMM32Instance;
173 HANDLE hWinMM16Instance;
174 HANDLE h16Module32;
175 CRITICAL_SECTION cs;
176 /* mm timer part */
177 HANDLE hMMTimer;
178 DWORD mmSysTimeMS;
179 LPWINE_TIMERENTRY lpTimerList;
180 int nSizeLpTimers;
181 LPWINE_TIMERENTRY lpTimers;
182 /* mci part */
183 LPWINE_MCIDRIVER lpMciDrvs;
184 /* low level drivers (unused yet) */
185 /* LPWINE_WAVE lpWave; */
186 /* LPWINE_MIDI lpMidi; */
187 /* LPWINE_MIXER lpMixer; */
188 /* mmio part */
189 LPWINE_MMIO lpMMIO;
190 /* playsound and sndPlaySound */
191 WINE_PLAYSOUND* lpPlaySound;
192 HANDLE psLastEvent;
193 HANDLE psStopEvent;
194 } WINE_MM_IDATA, *LPWINE_MM_IDATA;
196 /* function prototypes */
198 typedef LONG (*MCIPROC16)(DWORD, HDRVR16, WORD, DWORD, DWORD);
199 typedef LONG (*MCIPROC)(DWORD, HDRVR, DWORD, DWORD, DWORD);
201 extern LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr);
202 extern BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz);
203 extern LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2);
205 extern LPWINE_MCIDRIVER MCI_GetDriver(UINT16 uDevID);
206 extern UINT MCI_GetDriverFromString(LPCSTR str);
207 extern DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr);
208 extern const char* MCI_MessageToString(UINT16 wMsg);
210 extern UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data);
212 extern LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32);
214 extern DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
215 extern DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
216 extern DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
218 void CALLBACK WINE_mmThreadEntryPoint(DWORD _pmt);
220 void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16);
221 void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, const MMTIME* mmt32);
223 BOOL MULTIMEDIA_MciInit(void);
224 LPWINE_MM_IDATA MULTIMEDIA_GetIData(void);
226 LPWINE_MM_IDATA TIME_MMTimeStart(void);
227 void TIME_MMTimeStop(void);