1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
17 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(msacm);
27 /***********************************************************************
28 * acmDriverAddA (MSACM32.2)
30 MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
31 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
34 return MMSYSERR_INVALPARAM;
36 /* Check if any unknown flags */
38 ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
39 ACM_DRIVERADDF_GLOBAL))
40 return MMSYSERR_INVALFLAG;
42 /* Check if any incompatible flags */
43 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
44 (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
45 return MMSYSERR_INVALFLAG;
47 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
48 * LoadDriver on it, to be sure we can call SendDriverMessage on the
51 *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule);
53 /* FIXME: lParam, dwPriority and fdwAdd ignored */
55 return MMSYSERR_NOERROR;
58 /***********************************************************************
59 * acmDriverAddW (MSACM32.3)
63 MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule,
64 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
66 FIXME("(%p, 0x%08x, %ld, %ld, %ld): stub\n",
67 phadid, hinstModule, lParam, dwPriority, fdwAdd);
69 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
70 return MMSYSERR_ERROR;
73 /***********************************************************************
74 * acmDriverClose (MSACM32.4)
76 MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
82 return MMSYSERR_INVALFLAG;
84 p = MSACM_GetDriver(had);
86 return MMSYSERR_INVALHANDLE;
88 for (tp = &(p->obj.pACMDriverID->pACMDriverList); *tp; *tp = (*tp)->pNextACMDriver) {
90 *tp = (*tp)->pNextACMDriver;
95 if (p->hDrvr && !p->obj.pACMDriverID->pACMDriverList)
96 CloseDriver(p->hDrvr, 0, 0);
98 HeapFree(MSACM_hHeap, 0, p);
100 return MMSYSERR_NOERROR;
103 /***********************************************************************
104 * acmDriverDetailsA (MSACM32.5)
106 MMRESULT WINAPI acmDriverDetailsA(HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, DWORD fdwDetails)
109 ACMDRIVERDETAILSW addw;
111 addw.cbStruct = sizeof(addw);
112 mmr = acmDriverDetailsW(hadid, &addw, fdwDetails);
114 padd->fccType = addw.fccType;
115 padd->fccComp = addw.fccComp;
116 padd->wMid = addw.wMid;
117 padd->wPid = addw.wPid;
118 padd->vdwACM = addw.vdwACM;
119 padd->vdwDriver = addw.vdwDriver;
120 padd->fdwSupport = addw.fdwSupport;
121 padd->cFormatTags = addw.cFormatTags;
122 padd->cFilterTags = addw.cFilterTags;
123 padd->hicon = addw.hicon;
124 lstrcpyWtoA(padd->szShortName, addw.szShortName);
125 lstrcpyWtoA(padd->szLongName, addw.szLongName);
126 lstrcpyWtoA(padd->szCopyright, addw.szCopyright);
127 lstrcpyWtoA(padd->szLicensing, addw.szLicensing);
128 lstrcpyWtoA(padd->szFeatures, addw.szFeatures);
133 /***********************************************************************
134 * acmDriverDetailsW (MSACM32.6)
136 MMRESULT WINAPI acmDriverDetailsW(HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, DWORD fdwDetails)
142 return MMSYSERR_INVALFLAG;
144 mmr = acmDriverOpen(&acmDrvr, hadid, 0);
146 mmr = (MMRESULT)acmDriverMessage(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM) padd, 0);
148 acmDriverClose(acmDrvr, 0);
154 /***********************************************************************
155 * acmDriverEnum (MSACM32.7)
157 MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
163 return MMSYSERR_INVALPARAM;
166 if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED)) {
167 return MMSYSERR_INVALFLAG;
170 for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) {
171 fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
173 if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
174 fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
178 (*fnCallback)((HACMDRIVERID) p, dwInstance, fdwSupport);
181 return MMSYSERR_NOERROR;
184 /***********************************************************************
185 * acmDriverID (MSACM32.8)
187 MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
191 pao = MSACM_GetObj(hao);
193 return MMSYSERR_INVALHANDLE;
196 return MMSYSERR_INVALPARAM;
199 return MMSYSERR_INVALFLAG;
201 *phadid = (HACMDRIVERID) pao->pACMDriverID;
203 return MMSYSERR_NOERROR;
206 /***********************************************************************
207 * acmDriverMessage (MSACM32.9)
211 LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
213 PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
215 return MMSYSERR_INVALPARAM;
217 /* FIXME: Check if uMsg legal */
219 if (!SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2))
220 return MMSYSERR_NOTSUPPORTED;
222 return MMSYSERR_NOERROR;
226 /***********************************************************************
227 * acmDriverOpen (MSACM32.10)
229 MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
231 PWINE_ACMDRIVERID padid;
234 TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
237 return MMSYSERR_INVALPARAM;
239 padid = MSACM_GetDriverID(hadid);
241 return MMSYSERR_INVALHANDLE;
244 return MMSYSERR_INVALFLAG;
246 pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
247 if (!pad) return MMSYSERR_NOMEM;
249 pad->obj.pACMDriverID = padid;
251 if (!padid->hInstModule)
252 pad->hDrvr = OpenDriverA(padid->pszDriverAlias, "drivers32", 0);
254 pad->hDrvr = padid->hInstModule;
257 HeapFree(MSACM_hHeap, 0, pad);
258 return MMSYSERR_ERROR;
261 pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc");
263 /* insert new pad at beg of list */
264 pad->pNextACMDriver = padid->pACMDriverList;
265 padid->pACMDriverList = pad;
267 /* FIXME: Create a WINE_ACMDRIVER32 */
268 *phad = (HACMDRIVER)pad;
270 return MMSYSERR_NOERROR;
273 /***********************************************************************
274 * acmDriverPriority (MSACM32.11)
276 MMRESULT WINAPI acmDriverPriority(HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority)
278 PWINE_ACMDRIVERID padid;
281 LONG lBufferLength = sizeof(szBuffer);
284 DWORD dwPriorityCounter;
286 padid = MSACM_GetDriverID(hadid);
288 return MMSYSERR_INVALHANDLE;
290 /* Check for unknown flags */
292 ~(ACM_DRIVERPRIORITYF_ENABLE|ACM_DRIVERPRIORITYF_DISABLE|
293 ACM_DRIVERPRIORITYF_BEGIN|ACM_DRIVERPRIORITYF_END))
294 return MMSYSERR_INVALFLAG;
296 /* Check for incompatible flags */
297 if ((fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) &&
298 (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE))
299 return MMSYSERR_INVALFLAG;
301 /* Check for incompatible flags */
302 if ((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) &&
303 (fdwPriority & ACM_DRIVERPRIORITYF_END))
304 return MMSYSERR_INVALFLAG;
306 lError = RegOpenKeyA(HKEY_CURRENT_USER,
307 "Software\\Microsoft\\Multimedia\\"
308 "Audio Compression Manager\\Priority v4.00",
311 /* FIXME: Create key */
312 if (lError != ERROR_SUCCESS)
313 return MMSYSERR_ERROR;
315 for (dwPriorityCounter = 1; ; dwPriorityCounter++) {
316 snprintf(szSubKey, 17, "Priorty%ld", dwPriorityCounter);
317 lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength);
318 if (lError != ERROR_SUCCESS)
321 FIXME("(0x%08x, %ld, %ld): stub (partial)\n",
322 hadid, dwPriority, fdwPriority);
326 RegCloseKey(hPriorityKey);
328 return MMSYSERR_ERROR;
331 /***********************************************************************
332 * acmDriverRemove (MSACM32.12)
334 MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
336 PWINE_ACMDRIVERID padid;
338 padid = MSACM_GetDriverID(hadid);
340 return MMSYSERR_INVALHANDLE;
343 return MMSYSERR_INVALFLAG;
345 MSACM_UnregisterDriver(padid);
347 return MMSYSERR_NOERROR;