[MSACM32]
[reactos.git] / reactos / 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 default:
76 FIXME("%x not supported\n", version.dwPlatformId);
77 /* fall through */
78 case VER_PLATFORM_WIN32_WINDOWS:
79 return 0x04030000; /* 4.3.0 */
80 }
81 }
82
83 /***********************************************************************
84 * acmMessage32 (MSACM32.35)
85 * FIXME
86 * No documentation found.
87 */
88
89 /***********************************************************************
90 * acmMetrics (MSACM32.@)
91 */
92 MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
93 {
94 PWINE_ACMOBJ pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
95 BOOL bLocal = TRUE;
96 PWINE_ACMDRIVERID padid;
97 DWORD val = 0;
98 unsigned int i;
99 MMRESULT mmr = MMSYSERR_NOERROR;
100
101 TRACE("(%p, %d, %p);\n", hao, uMetric, pMetric);
102
103 #define CheckLocal(padid) (!bLocal || ((padid)->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL))
104
105 switch (uMetric) {
106 case ACM_METRIC_COUNT_DRIVERS:
107 bLocal = FALSE;
108 /* fall through */
109 case ACM_METRIC_COUNT_LOCAL_DRIVERS:
110 if (hao) return MMSYSERR_INVALHANDLE;
111 if (!pMetric) return MMSYSERR_INVALPARAM;
112 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
113 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
114 val++;
115 *(LPDWORD)pMetric = val;
116 break;
117
118 case ACM_METRIC_COUNT_CODECS:
119 bLocal = FALSE;
120 /* fall through */
121 case ACM_METRIC_COUNT_LOCAL_CODECS:
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) &&
126 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC) &&
127 CheckLocal(padid))
128 val++;
129 *(LPDWORD)pMetric = val;
130 break;
131
132 case ACM_METRIC_COUNT_CONVERTERS:
133 bLocal = FALSE;
134 /* fall through */
135 case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
136 if (hao) return MMSYSERR_INVALHANDLE;
137 if (!pMetric) return MMSYSERR_INVALPARAM;
138 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
139 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
140 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CONVERTER) &&
141 CheckLocal(padid))
142 val++;
143 *(LPDWORD)pMetric = val;
144 break;
145
146 case ACM_METRIC_COUNT_FILTERS:
147 bLocal = FALSE;
148 /* fall through */
149 case ACM_METRIC_COUNT_LOCAL_FILTERS:
150 if (hao) return MMSYSERR_INVALHANDLE;
151 if (!pMetric) return MMSYSERR_INVALPARAM;
152 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
153 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
154 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_FILTER) &&
155 CheckLocal(padid))
156 val++;
157 *(LPDWORD)pMetric = val;
158 break;
159
160 case ACM_METRIC_COUNT_DISABLED:
161 bLocal = FALSE;
162 /* fall through */
163 case ACM_METRIC_COUNT_LOCAL_DISABLED:
164 if (hao) return MMSYSERR_INVALHANDLE;
165 if (!pMetric) return MMSYSERR_INVALPARAM;
166 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
167 if ((padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
168 val++;
169 *(LPDWORD)pMetric = val;
170 break;
171
172 case ACM_METRIC_MAX_SIZE_FORMAT:
173 if (hao == NULL) {
174 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
175 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
176 for (i = 0; i < padid->cFormatTags; i++) {
177 if (val < padid->aFormatTag[i].cbwfx)
178 val = padid->aFormatTag[i].cbwfx;
179 }
180 }
181 }
182 } else if (pao != NULL) {
183 switch (pao->dwType) {
184 case WINE_ACMOBJ_DRIVER:
185 case WINE_ACMOBJ_DRIVERID:
186 padid = pao->pACMDriverID;
187 break;
188 default:
189 return MMSYSERR_INVALHANDLE;
190 }
191 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
192 for (i = 0; i < padid->cFormatTags; i++) {
193 if (val < padid->aFormatTag[i].cbwfx)
194 val = padid->aFormatTag[i].cbwfx;
195 }
196 }
197 } else {
198 return MMSYSERR_INVALHANDLE;
199 }
200 if (!pMetric) return MMSYSERR_INVALPARAM;
201 *(LPDWORD)pMetric = val;
202 break;
203
204 case ACM_METRIC_COUNT_HARDWARE:
205 if (hao) return MMSYSERR_INVALHANDLE;
206 if (!pMetric) return MMSYSERR_INVALPARAM;
207 *(LPDWORD)pMetric = 0;
208 FIXME("ACM_METRIC_COUNT_HARDWARE not implemented\n");
209 break;
210
211 case ACM_METRIC_DRIVER_PRIORITY:
212 /* Return current list position of driver */
213 if (!hao) return MMSYSERR_INVALHANDLE;
214 mmr = MMSYSERR_INVALHANDLE;
215 for (i = 1, padid = MSACM_pFirstACMDriverID; padid; i++, padid = padid->pNextACMDriverID) {
216 if (padid == (PWINE_ACMDRIVERID)hao) {
217 if (pMetric) {
218 *(LPDWORD)pMetric = i;
219 mmr = MMSYSERR_NOERROR;
220 } else {
221 mmr = MMSYSERR_INVALPARAM;
222 }
223 break;
224 }
225 }
226 break;
227
228 case ACM_METRIC_DRIVER_SUPPORT:
229 /* Return fdwSupport for driver */
230 if (!hao) return MMSYSERR_INVALHANDLE;
231 mmr = MMSYSERR_INVALHANDLE;
232 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
233 if (padid == (PWINE_ACMDRIVERID)hao) {
234 if (pMetric) {
235 *(LPDWORD)pMetric = padid->fdwSupport;
236 mmr = MMSYSERR_NOERROR;
237 } else {
238 mmr = MMSYSERR_INVALPARAM;
239 }
240 break;
241 }
242 }
243 break;
244
245 case ACM_METRIC_HARDWARE_WAVE_INPUT:
246 case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
247 case ACM_METRIC_MAX_SIZE_FILTER:
248 default:
249 FIXME("(%p, %d, %p): stub\n", hao, uMetric, pMetric);
250 mmr = MMSYSERR_NOTSUPPORTED;
251 }
252 return mmr;
253 }