1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
14 #include "debugtools.h"
23 DEFAULT_DEBUG_CHANNEL(msacm)
25 /***********************************************************************
26 * acmDriverAddA (MSACM32.2)
28 MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
29 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
32 return MMSYSERR_INVALPARAM;
34 /* Check if any unknown flags */
36 ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
37 ACM_DRIVERADDF_GLOBAL))
38 return MMSYSERR_INVALFLAG;
40 /* Check if any incompatible flags */
41 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
42 (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
43 return MMSYSERR_INVALFLAG;
45 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
46 * LoadDriver on it, to be sure we can call SendDriverMessage on the
49 *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule);
51 /* FIXME: lParam, dwPriority and fdwAdd ignored */
53 return MMSYSERR_NOERROR;
56 /***********************************************************************
57 * acmDriverAddW (MSACM32.3)
61 MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule,
62 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
64 FIXME("(%p, 0x%08x, %ld, %ld, %ld): stub\n",
65 phadid, hinstModule, lParam, dwPriority, fdwAdd);
67 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
68 return MMSYSERR_ERROR;
71 /***********************************************************************
72 * acmDriverClose (MSACM32.4)
74 MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
80 return MMSYSERR_INVALFLAG;
82 p = MSACM_GetDriver(had);
84 return MMSYSERR_INVALHANDLE;
86 for (tp = &(p->obj.pACMDriverID->pACMDriverList); *tp; *tp = (*tp)->pNextACMDriver) {
88 *tp = (*tp)->pNextACMDriver;
93 if (p->hDrvr && !p->obj.pACMDriverID->pACMDriverList)
94 CloseDriver(p->hDrvr, 0, 0);
96 HeapFree(MSACM_hHeap, 0, p);
98 return MMSYSERR_NOERROR;
101 /***********************************************************************
102 * acmDriverDetailsA (MSACM32.5)
104 MMRESULT WINAPI acmDriverDetailsA(HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, DWORD fdwDetails)
107 ACMDRIVERDETAILSW addw;
109 addw.cbStruct = sizeof(addw);
110 mmr = acmDriverDetailsW(hadid, &addw, fdwDetails);
112 padd->fccType = addw.fccType;
113 padd->fccComp = addw.fccComp;
114 padd->wMid = addw.wMid;
115 padd->wPid = addw.wPid;
116 padd->vdwACM = addw.vdwACM;
117 padd->vdwDriver = addw.vdwDriver;
118 padd->fdwSupport = addw.fdwSupport;
119 padd->cFormatTags = addw.cFormatTags;
120 padd->cFilterTags = addw.cFilterTags;
121 padd->hicon = addw.hicon;
122 lstrcpyWtoA(padd->szShortName, addw.szShortName);
123 lstrcpyWtoA(padd->szLongName, addw.szLongName);
124 lstrcpyWtoA(padd->szCopyright, addw.szCopyright);
125 lstrcpyWtoA(padd->szLicensing, addw.szLicensing);
126 lstrcpyWtoA(padd->szFeatures, addw.szFeatures);
131 /***********************************************************************
132 * acmDriverDetailsW (MSACM32.6)
134 MMRESULT WINAPI acmDriverDetailsW(HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, DWORD fdwDetails)
140 return MMSYSERR_INVALFLAG;
142 mmr = acmDriverOpen(&acmDrvr, hadid, 0);
144 mmr = (MMRESULT)acmDriverMessage(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM) padd, 0);
146 acmDriverClose(acmDrvr, 0);
152 /***********************************************************************
153 * acmDriverEnum (MSACM32.7)
155 MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
161 return MMSYSERR_INVALPARAM;
164 if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED)) {
165 return MMSYSERR_INVALFLAG;
168 for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) {
169 fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
171 if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
172 fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
176 (*fnCallback)((HACMDRIVERID) p, dwInstance, fdwSupport);
179 return MMSYSERR_NOERROR;
182 /***********************************************************************
183 * acmDriverID (MSACM32.8)
185 MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
189 pao = MSACM_GetObj(hao);
191 return MMSYSERR_INVALHANDLE;
194 return MMSYSERR_INVALPARAM;
197 return MMSYSERR_INVALFLAG;
199 *phadid = (HACMDRIVERID) pao->pACMDriverID;
201 return MMSYSERR_NOERROR;
204 /***********************************************************************
205 * acmDriverMessage (MSACM32.9)
209 LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
211 PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
213 return MMSYSERR_INVALPARAM;
215 /* FIXME: Check if uMsg legal */
217 if (!SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2))
218 return MMSYSERR_NOTSUPPORTED;
220 return MMSYSERR_NOERROR;
224 /***********************************************************************
225 * acmDriverOpen (MSACM32.10)
227 MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
229 PWINE_ACMDRIVERID padid;
232 TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
235 return MMSYSERR_INVALPARAM;
237 padid = MSACM_GetDriverID(hadid);
239 return MMSYSERR_INVALHANDLE;
242 return MMSYSERR_INVALFLAG;
244 pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
245 if (!pad) return MMSYSERR_NOMEM;
247 pad->obj.pACMDriverID = padid;
249 if (!padid->hInstModule)
250 pad->hDrvr = OpenDriverA(padid->pszDriverAlias, "drivers32", 0);
252 pad->hDrvr = padid->hInstModule;
255 HeapFree(MSACM_hHeap, 0, pad);
256 return MMSYSERR_ERROR;
259 pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc");
261 /* insert new pad at beg of list */
262 pad->pNextACMDriver = padid->pACMDriverList;
263 padid->pACMDriverList = pad;
265 /* FIXME: Create a WINE_ACMDRIVER32 */
266 *phad = (HACMDRIVER)pad;
268 return MMSYSERR_NOERROR;
271 /***********************************************************************
272 * acmDriverPriority (MSACM32.11)
274 MMRESULT WINAPI acmDriverPriority(HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority)
276 PWINE_ACMDRIVERID padid;
279 LONG lBufferLength = sizeof(szBuffer);
282 DWORD dwPriorityCounter;
284 padid = MSACM_GetDriverID(hadid);
286 return MMSYSERR_INVALHANDLE;
288 /* Check for unknown flags */
290 ~(ACM_DRIVERPRIORITYF_ENABLE|ACM_DRIVERPRIORITYF_DISABLE|
291 ACM_DRIVERPRIORITYF_BEGIN|ACM_DRIVERPRIORITYF_END))
292 return MMSYSERR_INVALFLAG;
294 /* Check for incompatible flags */
295 if ((fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) &&
296 (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE))
297 return MMSYSERR_INVALFLAG;
299 /* Check for incompatible flags */
300 if ((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) &&
301 (fdwPriority & ACM_DRIVERPRIORITYF_END))
302 return MMSYSERR_INVALFLAG;
304 lError = RegOpenKeyA(HKEY_CURRENT_USER,
305 "Software\\Microsoft\\Multimedia\\"
306 "Audio Compression Manager\\Priority v4.00",
309 /* FIXME: Create key */
310 if (lError != ERROR_SUCCESS)
311 return MMSYSERR_ERROR;
313 for (dwPriorityCounter = 1; ; dwPriorityCounter++) {
314 wsnprintfA(szSubKey, 17, "Priorty%ld", dwPriorityCounter);
315 lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength);
316 if (lError != ERROR_SUCCESS)
319 FIXME("(0x%08x, %ld, %ld): stub (partial)\n",
320 hadid, dwPriority, fdwPriority);
324 RegCloseKey(hPriorityKey);
326 return MMSYSERR_ERROR;
329 /***********************************************************************
330 * acmDriverRemove (MSACM32.12)
332 MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
334 PWINE_ACMDRIVERID padid;
336 padid = MSACM_GetDriverID(hadid);
338 return MMSYSERR_INVALHANDLE;
341 return MMSYSERR_INVALFLAG;
343 MSACM_UnregisterDriver(padid);
345 return MMSYSERR_NOERROR;