[WINMM]
[reactos.git] / reactos / dll / win32 / 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 <config.h>
23
24 #include <assert.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27
28 #define _INC_WINDOWS
29 #define COM_NO_WINDOWS_H
30
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
33
34 #include <windef.h>
35 #include <winbase.h>
36 #include <winuser.h>
37 #include <winreg.h>
38 #include <mmddk.h>
39
40 #include <wine/debug.h>
41 #include <wine/exception.h>
42 #include <wine/unicode.h>
43
44 #define WINE_DEFAULT_WINMM_DRIVER "alsa,oss,coreaudio,esd"
45 #define WINE_DEFAULT_WINMM_MAPPER "msacm32.drv"
46 #define WINE_DEFAULT_WINMM_MIDI "midimap.dll"
47
48 /* Who said goofy boy ? */
49 #define WINE_DI_MAGIC 0x900F1B01
50
51 typedef struct tagWINE_DRIVER
52 {
53 DWORD dwMagic;
54 /* as usual LPWINE_DRIVER == hDriver32 */
55 DWORD dwFlags;
56 HMODULE hModule;
57 DRIVERPROC lpDrvProc;
58 DWORD_PTR dwDriverID;
59 struct tagWINE_DRIVER* lpPrevItem;
60 struct tagWINE_DRIVER* lpNextItem;
61 } WINE_DRIVER, *LPWINE_DRIVER;
62
63 typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR);
64
65 /* for each loaded driver and each known type of driver, this structure contains
66 * the information needed to access it
67 */
68 typedef struct tagWINE_MM_DRIVER_PART {
69 int nIDMin; /* lower bound of global indexes for this type */
70 int nIDMax; /* hhigher bound of global indexes for this type */
71 WINEMM_msgFunc32 fnMessage32; /* pointer to function */
72 } WINE_MM_DRIVER_PART;
73
74 #define MMDRV_AUX 0
75 #define MMDRV_MIXER 1
76 #define MMDRV_MIDIIN 2
77 #define MMDRV_MIDIOUT 3
78 #define MMDRV_WAVEIN 4
79 #define MMDRV_WAVEOUT 5
80 #define MMDRV_MAX 6
81
82 /* each low-level .drv will be associated with an instance of this structure */
83 typedef struct tagWINE_MM_DRIVER {
84 HDRVR hDriver;
85 LPSTR drvname; /* name of the driver */
86 unsigned bIsMapper : 1; /* TRUE if mapper */
87 WINE_MM_DRIVER_PART parts[MMDRV_MAX];/* Information for all known types */
88 } WINE_MM_DRIVER, *LPWINE_MM_DRIVER;
89
90 typedef struct tagWINE_MLD {
91 /* EPP struct tagWINE_MLD* lpNext; */ /* not used so far */
92 UINT uDeviceID;
93 UINT type;
94 UINT mmdIndex; /* index to low-level driver in MMDrvs table */
95 DWORD_PTR dwDriverInstance; /* this value is driver related, as opposed to
96 * opendesc.dwInstance which is client (callback) related */
97 WORD dwFlags;
98 DWORD_PTR dwCallback;
99 DWORD_PTR dwClientInstance;
100 } WINE_MLD, *LPWINE_MLD;
101
102 typedef struct {
103 WINE_MLD mld;
104 } WINE_WAVE, *LPWINE_WAVE;
105
106 typedef struct {
107 WINE_MLD mld;
108 MIDIOPENDESC mod; /* FIXME: should be removed */
109 } WINE_MIDI, *LPWINE_MIDI;
110
111 typedef struct {
112 WINE_MLD mld;
113 } WINE_MIXER, *LPWINE_MIXER;
114
115 typedef struct tagWINE_MCIDRIVER {
116 UINT wDeviceID;
117 UINT wType;
118 LPWSTR lpstrElementName;
119 LPWSTR lpstrDeviceType;
120 LPWSTR lpstrAlias;
121 HDRVR hDriver;
122 DWORD_PTR dwPrivate;
123 YIELDPROC lpfnYieldProc;
124 DWORD dwYieldData;
125 DWORD CreatorThread;
126 UINT uTypeCmdTable;
127 UINT uSpecificCmdTable;
128 struct tagWINE_MCIDRIVER*lpNext;
129 } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
130
131 struct IOProcList
132 {
133 struct IOProcList*pNext; /* Next item in linked list */
134 FOURCC fourCC; /* four-character code identifying IOProc */
135 LPMMIOPROC pIOProc; /* pointer to IProc */
136 BOOL is_unicode; /* 32A or 32W */
137 int count; /* number of objects linked to it */
138 };
139
140 typedef struct tagWINE_MMIO {
141 MMIOINFO info;
142 struct tagWINE_MMIO* lpNext;
143 struct IOProcList* ioProc;
144 unsigned bTmpIOProc : 1,
145 bBufferLoaded : 1;
146 DWORD dwFileSize;
147 } WINE_MMIO, *LPWINE_MMIO;
148
149 /* function prototypes */
150 BOOL WINMM_CheckForMMSystem(void);
151 LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr);
152 BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz);
153 LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2);
154 void DRIVER_UnloadAll(void);
155 HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam);
156 BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper);
157 BOOL LoadRegistryMMEDrivers(char* key);
158 BOOL MMDRV_Init(void);
159 void MMDRV_Exit(void);
160 UINT MMDRV_GetNum(UINT);
161 LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
162 DWORD_PTR* dwCallback, DWORD_PTR* dwInstance);
163 void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld);
164 DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwParam2);
165 DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg);
166 LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID);
167 LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped);
168 DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
169 UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
170
171 const char* MCI_MessageToString(UINT wMsg);
172 DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
173 LPWSTR MCI_strdupAtoW(LPCSTR str);
174 LPSTR MCI_strdupWtoA(LPCWSTR str);
175
176 const char* WINMM_ErrorToString(MMRESULT error);
177
178 void TIME_MMTimeStop(void);
179
180 /* Global variables */
181 extern CRITICAL_SECTION WINMM_cs;
182 extern HINSTANCE hWinMM32Instance;
183 extern HANDLE psLastEvent;
184 extern HANDLE psStopEvent;
185
186 /* GetDriverFlags() returned bits is not documented (nor the call itself)
187 * Here are Wine only definitions of the bits
188 */
189 #define WINE_GDF_EXIST 0x80000000
190 #define WINE_GDF_EXTERNAL_MASK 0xF0000000
191 #define WINE_GDF_SESSION 0x00000001
192
193
194 /* Modification to take into account Windows NT's registry format */
195
196 #define NT_MME_DRIVERS32_KEY \
197 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32"
198
199 #define NT_MME_DRIVERS_KEY \
200 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers"
201
202 INT LoadRegistryMMEDrivers(char* key);