ae362f25cc5d67d55e0d08ed3bca201e36f8e98c
[reactos.git] / dll / win32 / msacm32 / msacm32_main.c
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2
3 /*
4 * MSACM32 library
5 *
6 * Copyright 1998 Patrik Stridvall
7 * 1999 Eric Pouech
8 *
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.
13 *
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.
18 *
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
22 */
23
24 #include "wineacm.h"
25
26 /**********************************************************************/
27
28 HINSTANCE MSACM_hInstance32 = 0;
29
30 /***********************************************************************
31 * DllMain (MSACM32.init)
32 */
33 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
34 {
35 TRACE("%p 0x%x %p\n", hInstDLL, fdwReason, lpvReserved);
36
37 switch (fdwReason) {
38 case DLL_PROCESS_ATTACH:
39 DisableThreadLibraryCalls(hInstDLL);
40 MSACM_hHeap = HeapCreate(0, 0x10000, 0);
41 MSACM_hInstance32 = hInstDLL;
42 MSACM_RegisterAllDrivers();
43 break;
44 case DLL_PROCESS_DETACH:
45 MSACM_UnregisterAllDrivers();
46 if (lpvReserved) break;
47 HeapDestroy(MSACM_hHeap);
48 break;
49 default:
50 break;
51 }
52 return TRUE;
53 }
54
55 /***********************************************************************
56 * XRegThunkEntry (MSACM32.1)
57 * FIXME
58 * No documentation found.
59 */
60
61 /***********************************************************************
62 * acmGetVersion (MSACM32.@)
63 */
64 DWORD WINAPI acmGetVersion(void)
65 {
66 OSVERSIONINFOA version;
67
68 version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
69 if (!GetVersionExA( &version ))
70 return 0x04030000;
71
72 switch (version.dwPlatformId) {
73 case VER_PLATFORM_WIN32_NT:
74 return 0x04000565; /* 4.0.1381 */
75 case VER_PLATFORM_WIN32s:
76 return 0x02010000; /* 2.1 */
77 default:
78 FIXME("%x not supported\n", version.dwPlatformId);
79 /* fall through */
80 case VER_PLATFORM_WIN32_WINDOWS:
81 return 0x04030000; /* 4.3.0 */
82 }
83 }
84
85 /***********************************************************************
86 * acmMessage32 (MSACM32.35)
87 * FIXME
88 * No documentation found.
89 */
90
91 /***********************************************************************
92 * acmMetrics (MSACM32.@)
93 */
94 MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
95 {
96 PWINE_ACMOBJ pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
97 BOOL bLocal = TRUE;
98 PWINE_ACMDRIVERID padid;
99 DWORD val = 0;
100 unsigned int i;
101 MMRESULT mmr = MMSYSERR_NOERROR;
102
103 TRACE("(%p, %d, %p);\n", hao, uMetric, pMetric);
104
105 #define CheckLocal(padid) (!bLocal || ((padid)->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL))
106
107 switch (uMetric) {
108 case ACM_METRIC_COUNT_DRIVERS:
109 bLocal = FALSE;
110 /* fall through */
111 case ACM_METRIC_COUNT_LOCAL_DRIVERS:
112 if (hao) return MMSYSERR_INVALHANDLE;
113 if (!pMetric) return MMSYSERR_INVALPARAM;
114 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
115 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
116 val++;
117 *(LPDWORD)pMetric = val;
118 break;
119
120 case ACM_METRIC_COUNT_CODECS:
121 bLocal = FALSE;
122 /* fall through */
123 case ACM_METRIC_COUNT_LOCAL_CODECS:
124 if (hao) return MMSYSERR_INVALHANDLE;
125 if (!pMetric) return MMSYSERR_INVALPARAM;
126 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
127 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
128 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC) &&
129 CheckLocal(padid))
130 val++;
131 *(LPDWORD)pMetric = val;
132 break;
133
134 case ACM_METRIC_COUNT_CONVERTERS:
135 bLocal = FALSE;
136 /* fall through */
137 case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
138 if (hao) return MMSYSERR_INVALHANDLE;
139 if (!pMetric) return MMSYSERR_INVALPARAM;
140 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
141 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
142 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CONVERTER) &&
143 CheckLocal(padid))
144 val++;
145 *(LPDWORD)pMetric = val;
146 break;
147
148 case ACM_METRIC_COUNT_FILTERS:
149 bLocal = FALSE;
150 /* fall through */
151 case ACM_METRIC_COUNT_LOCAL_FILTERS:
152 if (hao) return MMSYSERR_INVALHANDLE;
153 if (!pMetric) return MMSYSERR_INVALPARAM;
154 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
155 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
156 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_FILTER) &&
157 CheckLocal(padid))
158 val++;
159 *(LPDWORD)pMetric = val;
160 break;
161
162 case ACM_METRIC_COUNT_DISABLED:
163 bLocal = FALSE;
164 /* fall through */
165 case ACM_METRIC_COUNT_LOCAL_DISABLED:
166 if (hao) return MMSYSERR_INVALHANDLE;
167 if (!pMetric) return MMSYSERR_INVALPARAM;
168 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
169 if ((padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
170 val++;
171 *(LPDWORD)pMetric = val;
172 break;
173
174 case ACM_METRIC_MAX_SIZE_FORMAT:
175 if (hao == NULL) {
176 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
177 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
178 for (i = 0; i < padid->cFormatTags; i++) {
179 if (val < padid->aFormatTag[i].cbwfx)
180 val = padid->aFormatTag[i].cbwfx;
181 }
182 }
183 }
184 } else if (pao != NULL) {
185 switch (pao->dwType) {
186 case WINE_ACMOBJ_DRIVER:
187 case WINE_ACMOBJ_DRIVERID:
188 padid = pao->pACMDriverID;
189 break;
190 default:
191 return MMSYSERR_INVALHANDLE;
192 }
193 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
194 for (i = 0; i < padid->cFormatTags; i++) {
195 if (val < padid->aFormatTag[i].cbwfx)
196 val = padid->aFormatTag[i].cbwfx;
197 }
198 }
199 } else {
200 return MMSYSERR_INVALHANDLE;
201 }
202 if (!pMetric) return MMSYSERR_INVALPARAM;
203 *(LPDWORD)pMetric = val;
204 break;
205
206 case ACM_METRIC_COUNT_HARDWARE:
207 if (hao) return MMSYSERR_INVALHANDLE;
208 if (!pMetric) return MMSYSERR_INVALPARAM;
209 *(LPDWORD)pMetric = 0;
210 FIXME("ACM_METRIC_COUNT_HARDWARE not implemented\n");
211 break;
212
213 case ACM_METRIC_DRIVER_PRIORITY:
214 /* Return current list position of driver */
215 if (!hao) return MMSYSERR_INVALHANDLE;
216 mmr = MMSYSERR_INVALHANDLE;
217 for (i = 1, padid = MSACM_pFirstACMDriverID; padid; i++, padid = padid->pNextACMDriverID) {
218 if (padid == (PWINE_ACMDRIVERID)hao) {
219 if (pMetric) {
220 *(LPDWORD)pMetric = i;
221 mmr = MMSYSERR_NOERROR;
222 } else {
223 mmr = MMSYSERR_INVALPARAM;
224 }
225 break;
226 }
227 }
228 break;
229
230 case ACM_METRIC_DRIVER_SUPPORT:
231 /* Return fdwSupport for driver */
232 if (!hao) return MMSYSERR_INVALHANDLE;
233 mmr = MMSYSERR_INVALHANDLE;
234 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
235 if (padid == (PWINE_ACMDRIVERID)hao) {
236 if (pMetric) {
237 *(LPDWORD)pMetric = padid->fdwSupport;
238 mmr = MMSYSERR_NOERROR;
239 } else {
240 mmr = MMSYSERR_INVALPARAM;
241 }
242 break;
243 }
244 }
245 break;
246
247 case ACM_METRIC_HARDWARE_WAVE_INPUT:
248 case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
249 case ACM_METRIC_MAX_SIZE_FILTER:
250 default:
251 FIXME("(%p, %d, %p): stub\n", hao, uMetric, pMetric);
252 mmr = MMSYSERR_NOTSUPPORTED;
253 }
254 return mmr;
255 }