Fix NtAllocateVirtualMemory declaration and fix users of the
[wine/multimedia.git] / dlls / msacm / msacm32_main.c
blob90a01e038a0946dfb3229ffad7f77651884798b4
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*
4 * MSACM32 library
6 * Copyright 1998 Patrik Stridvall
7 * 1999 Eric Pouech
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
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winerror.h"
29 #include "wine/debug.h"
30 #include "mmsystem.h"
31 #define NOBITMAP
32 #include "mmreg.h"
33 #include "msacm.h"
34 #include "msacmdrv.h"
35 #include "wineacm.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msacm);
39 /**********************************************************************/
41 HINSTANCE MSACM_hInstance32 = 0;
43 /***********************************************************************
44 * DllMain (MSACM32.init)
46 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
48 TRACE("%p 0x%lx %p\n", hInstDLL, fdwReason, lpvReserved);
50 switch (fdwReason) {
51 case DLL_PROCESS_ATTACH:
52 DisableThreadLibraryCalls(hInstDLL);
53 MSACM_hHeap = HeapCreate(0, 0x10000, 0);
54 MSACM_hInstance32 = hInstDLL;
55 MSACM_RegisterAllDrivers();
56 break;
57 case DLL_PROCESS_DETACH:
58 MSACM_UnregisterAllDrivers();
59 HeapDestroy(MSACM_hHeap);
60 MSACM_hHeap = NULL;
61 MSACM_hInstance32 = NULL;
62 break;
63 default:
64 break;
66 return TRUE;
69 /***********************************************************************
70 * XRegThunkEntry (MSACM32.1)
71 * FIXME
72 * No documentation found.
75 /***********************************************************************
76 * acmGetVersion (MSACM32.@)
78 DWORD WINAPI acmGetVersion(void)
80 OSVERSIONINFOA version;
82 version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
83 if (!GetVersionExA( &version ))
84 return 0x04030000;
86 switch (version.dwPlatformId) {
87 case VER_PLATFORM_WIN32_NT:
88 return 0x04000565; /* 4.0.1381 */
89 default:
90 FIXME("%lx not supported\n", version.dwPlatformId);
91 case VER_PLATFORM_WIN32_WINDOWS:
92 return 0x04030000; /* 4.3.0 */
96 /***********************************************************************
97 * acmMessage32 (MSACM32.35)
98 * FIXME
99 * No documentation found.
102 /***********************************************************************
103 * acmMetrics (MSACM32.@)
105 MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
107 PWINE_ACMOBJ pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
108 BOOL bLocal = TRUE;
109 PWINE_ACMDRIVERID padid;
110 DWORD val = 0;
111 unsigned int i;
112 MMRESULT mmr = MMSYSERR_NOERROR;
114 TRACE("(%p, %d, %p);\n", hao, uMetric, pMetric);
116 #define CheckLocal(padid) (!bLocal || ((padid)->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL))
118 switch (uMetric) {
119 case ACM_METRIC_COUNT_DRIVERS:
120 bLocal = FALSE;
121 /* fall through */
122 case ACM_METRIC_COUNT_LOCAL_DRIVERS:
123 if (hao) return MMSYSERR_INVALHANDLE;
124 if (!pMetric) return MMSYSERR_INVALPARAM;
125 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
126 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
127 val++;
128 *(LPDWORD)pMetric = val;
129 break;
131 case ACM_METRIC_COUNT_CODECS:
132 bLocal = FALSE;
133 /* fall through */
134 case ACM_METRIC_COUNT_LOCAL_CODECS:
135 if (hao) return MMSYSERR_INVALHANDLE;
136 if (!pMetric) return MMSYSERR_INVALPARAM;
137 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
138 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
139 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC) &&
140 CheckLocal(padid))
141 val++;
142 *(LPDWORD)pMetric = val;
143 break;
145 case ACM_METRIC_COUNT_CONVERTERS:
146 bLocal = FALSE;
147 /* fall through */
148 case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
149 if (hao) return MMSYSERR_INVALHANDLE;
150 if (!pMetric) return MMSYSERR_INVALPARAM;
151 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
152 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
153 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CONVERTER) &&
154 CheckLocal(padid))
155 val++;
156 *(LPDWORD)pMetric = val;
157 break;
159 case ACM_METRIC_COUNT_FILTERS:
160 bLocal = FALSE;
161 /* fall through */
162 case ACM_METRIC_COUNT_LOCAL_FILTERS:
163 if (hao) return MMSYSERR_INVALHANDLE;
164 if (!pMetric) return MMSYSERR_INVALPARAM;
165 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
166 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
167 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_FILTER) &&
168 CheckLocal(padid))
169 val++;
170 *(LPDWORD)pMetric = val;
171 break;
173 case ACM_METRIC_COUNT_DISABLED:
174 bLocal = FALSE;
175 /* fall through */
176 case ACM_METRIC_COUNT_LOCAL_DISABLED:
177 if (hao) return MMSYSERR_INVALHANDLE;
178 if (!pMetric) return MMSYSERR_INVALPARAM;
179 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
180 if ((padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
181 val++;
182 *(LPDWORD)pMetric = val;
183 break;
185 case ACM_METRIC_MAX_SIZE_FORMAT:
186 if (hao == NULL) {
187 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
188 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
189 for (i = 0; i < padid->cFormatTags; i++) {
190 if (val < padid->aFormatTag[i].cbwfx)
191 val = padid->aFormatTag[i].cbwfx;
195 } else if (pao != NULL) {
196 switch (pao->dwType) {
197 case WINE_ACMOBJ_DRIVER:
198 case WINE_ACMOBJ_DRIVERID:
199 padid = pao->pACMDriverID;
200 break;
201 default:
202 return MMSYSERR_INVALHANDLE;
204 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
205 for (i = 0; i < padid->cFormatTags; i++) {
206 if (val < padid->aFormatTag[i].cbwfx)
207 val = padid->aFormatTag[i].cbwfx;
210 } else {
211 return MMSYSERR_INVALHANDLE;
213 if (!pMetric) return MMSYSERR_INVALPARAM;
214 *(LPDWORD)pMetric = val;
215 break;
217 case ACM_METRIC_COUNT_HARDWARE:
218 if (hao) return MMSYSERR_INVALHANDLE;
219 if (!pMetric) return MMSYSERR_INVALPARAM;
220 *(LPDWORD)pMetric = 0;
221 FIXME("ACM_METRIC_COUNT_HARDWARE not implemented\n");
222 break;
224 case ACM_METRIC_HARDWARE_WAVE_INPUT:
225 case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
226 case ACM_METRIC_MAX_SIZE_FILTER:
227 case ACM_METRIC_DRIVER_SUPPORT:
228 case ACM_METRIC_DRIVER_PRIORITY:
229 default:
230 FIXME("(%p, %d, %p): stub\n", hao, uMetric, pMetric);
231 mmr = MMSYSERR_NOTSUPPORTED;
233 return mmr;