kernel32/tests: Use PROCESS_ALL_ACCESS definition compatible with versions of Windows...
[wine.git] / dlls / msacm32 / msacm32_main.c
bloba47611cae5a8c64e378655f1c4eea52f10f4516f
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
29 #include "mmsystem.h"
30 #define NOBITMAP
31 #include "mmreg.h"
32 #include "msacm.h"
33 #include "msacmdrv.h"
34 #include "wineacm.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msacm);
38 /**********************************************************************/
40 HINSTANCE MSACM_hInstance32 = 0;
42 /***********************************************************************
43 * DllMain (MSACM32.init)
45 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
47 TRACE("%p 0x%x %p\n", hInstDLL, fdwReason, lpvReserved);
49 switch (fdwReason) {
50 case DLL_PROCESS_ATTACH:
51 DisableThreadLibraryCalls(hInstDLL);
52 MSACM_hHeap = HeapCreate(0, 0x10000, 0);
53 MSACM_hInstance32 = hInstDLL;
54 MSACM_RegisterAllDrivers();
55 break;
56 case DLL_PROCESS_DETACH:
57 MSACM_UnregisterAllDrivers();
58 if (lpvReserved) break;
59 HeapDestroy(MSACM_hHeap);
60 break;
61 default:
62 break;
64 return TRUE;
67 /***********************************************************************
68 * XRegThunkEntry (MSACM32.1)
69 * FIXME
70 * No documentation found.
73 /***********************************************************************
74 * acmGetVersion (MSACM32.@)
76 DWORD WINAPI acmGetVersion(void)
78 OSVERSIONINFOA version;
80 version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
81 if (!GetVersionExA( &version ))
82 return 0x04030000;
84 switch (version.dwPlatformId) {
85 case VER_PLATFORM_WIN32_NT:
86 return 0x04000565; /* 4.0.1381 */
87 default:
88 FIXME("%x not supported\n", version.dwPlatformId);
89 /* fall through */
90 case VER_PLATFORM_WIN32_WINDOWS:
91 return 0x04030000; /* 4.3.0 */
95 /***********************************************************************
96 * acmMessage32 (MSACM32.35)
97 * FIXME
98 * No documentation found.
101 /***********************************************************************
102 * acmMetrics (MSACM32.@)
104 MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
106 PWINE_ACMOBJ pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
107 BOOL bLocal = TRUE;
108 PWINE_ACMDRIVERID padid;
109 DWORD val = 0;
110 unsigned int i;
111 MMRESULT mmr = MMSYSERR_NOERROR;
113 TRACE("(%p, %d, %p);\n", hao, uMetric, pMetric);
115 #define CheckLocal(padid) (!bLocal || ((padid)->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL))
117 switch (uMetric) {
118 case ACM_METRIC_COUNT_DRIVERS:
119 bLocal = FALSE;
120 /* fall through */
121 case ACM_METRIC_COUNT_LOCAL_DRIVERS:
122 if (hao) return MMSYSERR_INVALHANDLE;
123 if (!pMetric) return MMSYSERR_INVALPARAM;
124 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
125 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
126 val++;
127 *(LPDWORD)pMetric = val;
128 break;
130 case ACM_METRIC_COUNT_CODECS:
131 bLocal = FALSE;
132 /* fall through */
133 case ACM_METRIC_COUNT_LOCAL_CODECS:
134 if (hao) return MMSYSERR_INVALHANDLE;
135 if (!pMetric) return MMSYSERR_INVALPARAM;
136 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
137 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
138 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC) &&
139 CheckLocal(padid))
140 val++;
141 *(LPDWORD)pMetric = val;
142 break;
144 case ACM_METRIC_COUNT_CONVERTERS:
145 bLocal = FALSE;
146 /* fall through */
147 case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
148 if (hao) return MMSYSERR_INVALHANDLE;
149 if (!pMetric) return MMSYSERR_INVALPARAM;
150 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
151 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
152 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CONVERTER) &&
153 CheckLocal(padid))
154 val++;
155 *(LPDWORD)pMetric = val;
156 break;
158 case ACM_METRIC_COUNT_FILTERS:
159 bLocal = FALSE;
160 /* fall through */
161 case ACM_METRIC_COUNT_LOCAL_FILTERS:
162 if (hao) return MMSYSERR_INVALHANDLE;
163 if (!pMetric) return MMSYSERR_INVALPARAM;
164 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
165 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
166 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_FILTER) &&
167 CheckLocal(padid))
168 val++;
169 *(LPDWORD)pMetric = val;
170 break;
172 case ACM_METRIC_COUNT_DISABLED:
173 bLocal = FALSE;
174 /* fall through */
175 case ACM_METRIC_COUNT_LOCAL_DISABLED:
176 if (hao) return MMSYSERR_INVALHANDLE;
177 if (!pMetric) return MMSYSERR_INVALPARAM;
178 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
179 if ((padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
180 val++;
181 *(LPDWORD)pMetric = val;
182 break;
184 case ACM_METRIC_MAX_SIZE_FORMAT:
185 if (hao == NULL) {
186 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
187 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
188 for (i = 0; i < padid->cFormatTags; i++) {
189 if (val < padid->aFormatTag[i].cbwfx)
190 val = padid->aFormatTag[i].cbwfx;
194 } else if (pao != NULL) {
195 switch (pao->dwType) {
196 case WINE_ACMOBJ_DRIVER:
197 case WINE_ACMOBJ_DRIVERID:
198 padid = pao->pACMDriverID;
199 break;
200 default:
201 return MMSYSERR_INVALHANDLE;
203 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
204 for (i = 0; i < padid->cFormatTags; i++) {
205 if (val < padid->aFormatTag[i].cbwfx)
206 val = padid->aFormatTag[i].cbwfx;
209 } else {
210 return MMSYSERR_INVALHANDLE;
212 if (!pMetric) return MMSYSERR_INVALPARAM;
213 *(LPDWORD)pMetric = val;
214 break;
216 case ACM_METRIC_COUNT_HARDWARE:
217 if (hao) return MMSYSERR_INVALHANDLE;
218 if (!pMetric) return MMSYSERR_INVALPARAM;
219 *(LPDWORD)pMetric = 0;
220 FIXME("ACM_METRIC_COUNT_HARDWARE not implemented\n");
221 break;
223 case ACM_METRIC_DRIVER_PRIORITY:
224 /* Return current list position of driver */
225 if (!hao) return MMSYSERR_INVALHANDLE;
226 mmr = MMSYSERR_INVALHANDLE;
227 for (i = 1, padid = MSACM_pFirstACMDriverID; padid; i++, padid = padid->pNextACMDriverID) {
228 if (padid == (PWINE_ACMDRIVERID)hao) {
229 if (pMetric) {
230 *(LPDWORD)pMetric = i;
231 mmr = MMSYSERR_NOERROR;
232 } else {
233 mmr = MMSYSERR_INVALPARAM;
235 break;
238 break;
240 case ACM_METRIC_DRIVER_SUPPORT:
241 /* Return fdwSupport for driver */
242 if (!hao) return MMSYSERR_INVALHANDLE;
243 mmr = MMSYSERR_INVALHANDLE;
244 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
245 if (padid == (PWINE_ACMDRIVERID)hao) {
246 if (pMetric) {
247 *(LPDWORD)pMetric = padid->fdwSupport;
248 mmr = MMSYSERR_NOERROR;
249 } else {
250 mmr = MMSYSERR_INVALPARAM;
252 break;
255 break;
257 case ACM_METRIC_HARDWARE_WAVE_INPUT:
258 case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
259 case ACM_METRIC_MAX_SIZE_FILTER:
260 default:
261 FIXME("(%p, %d, %p): stub\n", hao, uMetric, pMetric);
262 mmr = MMSYSERR_NOTSUPPORTED;
264 return mmr;