po: Update simplified Chinese translation.
[wine/multimedia.git] / dlls / msacm32 / msacm32_main.c
blob65528125eaef9c939f0decfd34eb81248b623965
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 HeapDestroy(MSACM_hHeap);
59 MSACM_hHeap = NULL;
60 MSACM_hInstance32 = NULL;
61 break;
62 default:
63 break;
65 return TRUE;
68 /***********************************************************************
69 * XRegThunkEntry (MSACM32.1)
70 * FIXME
71 * No documentation found.
74 /***********************************************************************
75 * acmGetVersion (MSACM32.@)
77 DWORD WINAPI acmGetVersion(void)
79 OSVERSIONINFOA version;
81 version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
82 if (!GetVersionExA( &version ))
83 return 0x04030000;
85 switch (version.dwPlatformId) {
86 case VER_PLATFORM_WIN32_NT:
87 return 0x04000565; /* 4.0.1381 */
88 default:
89 FIXME("%x not supported\n", version.dwPlatformId);
90 /* fall through */
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_DRIVER_PRIORITY:
225 /* Return current list position of driver */
226 if (!hao) return MMSYSERR_INVALHANDLE;
227 mmr = MMSYSERR_INVALHANDLE;
228 for (i = 1, padid = MSACM_pFirstACMDriverID; padid; i++, padid = padid->pNextACMDriverID) {
229 if (padid == (PWINE_ACMDRIVERID)hao) {
230 if (pMetric) {
231 *(LPDWORD)pMetric = i;
232 mmr = MMSYSERR_NOERROR;
233 } else {
234 mmr = MMSYSERR_INVALPARAM;
236 break;
239 break;
241 case ACM_METRIC_DRIVER_SUPPORT:
242 /* Return fdwSupport for driver */
243 if (!hao) return MMSYSERR_INVALHANDLE;
244 mmr = MMSYSERR_INVALHANDLE;
245 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
246 if (padid == (PWINE_ACMDRIVERID)hao) {
247 if (pMetric) {
248 *(LPDWORD)pMetric = padid->fdwSupport;
249 mmr = MMSYSERR_NOERROR;
250 } else {
251 mmr = MMSYSERR_INVALPARAM;
253 break;
256 break;
258 case ACM_METRIC_HARDWARE_WAVE_INPUT:
259 case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
260 case ACM_METRIC_MAX_SIZE_FILTER:
261 default:
262 FIXME("(%p, %d, %p): stub\n", hao, uMetric, pMetric);
263 mmr = MMSYSERR_NOTSUPPORTED;
265 return mmr;