1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
17 #include "wine/winestring.h"
18 #include "debugtools.h"
26 DEFAULT_DEBUG_CHANNEL(msacm);
28 /***********************************************************************
29 * acmDriverAddA (MSACM32.2)
31 MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
32 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
35 return MMSYSERR_INVALPARAM;
37 /* Check if any unknown flags */
39 ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
40 ACM_DRIVERADDF_GLOBAL))
41 return MMSYSERR_INVALFLAG;
43 /* Check if any incompatible flags */
44 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
45 (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
46 return MMSYSERR_INVALFLAG;
48 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
49 * LoadDriver on it, to be sure we can call SendDriverMessage on the
52 *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule);
54 /* FIXME: lParam, dwPriority and fdwAdd ignored */
56 return MMSYSERR_NOERROR;
59 /***********************************************************************
60 * acmDriverAddW (MSACM32.3)
64 MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule,
65 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
67 FIXME("(%p, 0x%08x, %ld, %ld, %ld): stub\n",
68 phadid, hinstModule, lParam, dwPriority, fdwAdd);
70 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
71 return MMSYSERR_ERROR;
74 /***********************************************************************
75 * acmDriverClose (MSACM32.4)
77 MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
80 PWINE_ACMDRIVERID padid;
81 PWINE_ACMDRIVER* tpad;
84 return MMSYSERR_INVALFLAG;
86 pad = MSACM_GetDriver(had);
88 return MMSYSERR_INVALHANDLE;
90 padid = pad->obj.pACMDriverID;
92 /* remove driver from list */
93 for (tpad = &(padid->pACMDriverList); *tpad; *tpad = (*tpad)->pNextACMDriver) {
95 *tpad = (*tpad)->pNextACMDriver;
100 /* close driver if it has been opened */
101 if (pad->hDrvr && !padid->hInstModule)
102 CloseDriver(pad->hDrvr, 0, 0);
104 HeapFree(MSACM_hHeap, 0, pad);
106 return MMSYSERR_NOERROR;
109 /***********************************************************************
110 * acmDriverDetailsA (MSACM32.5)
112 MMRESULT WINAPI acmDriverDetailsA(HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, DWORD fdwDetails)
115 ACMDRIVERDETAILSW addw;
117 addw.cbStruct = sizeof(addw);
118 mmr = acmDriverDetailsW(hadid, &addw, fdwDetails);
120 padd->fccType = addw.fccType;
121 padd->fccComp = addw.fccComp;
122 padd->wMid = addw.wMid;
123 padd->wPid = addw.wPid;
124 padd->vdwACM = addw.vdwACM;
125 padd->vdwDriver = addw.vdwDriver;
126 padd->fdwSupport = addw.fdwSupport;
127 padd->cFormatTags = addw.cFormatTags;
128 padd->cFilterTags = addw.cFilterTags;
129 padd->hicon = addw.hicon;
130 lstrcpyWtoA(padd->szShortName, addw.szShortName);
131 lstrcpyWtoA(padd->szLongName, addw.szLongName);
132 lstrcpyWtoA(padd->szCopyright, addw.szCopyright);
133 lstrcpyWtoA(padd->szLicensing, addw.szLicensing);
134 lstrcpyWtoA(padd->szFeatures, addw.szFeatures);
139 /***********************************************************************
140 * acmDriverDetailsW (MSACM32.6)
142 MMRESULT WINAPI acmDriverDetailsW(HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, DWORD fdwDetails)
148 return MMSYSERR_INVALFLAG;
150 mmr = acmDriverOpen(&acmDrvr, hadid, 0);
151 if (mmr == MMSYSERR_NOERROR) {
152 mmr = (MMRESULT)MSACM_Message(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM)padd, 0);
154 acmDriverClose(acmDrvr, 0);
160 /***********************************************************************
161 * acmDriverEnum (MSACM32.7)
163 MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
166 ACMDRIVERDETAILSW add;
168 if (!fnCallback) return MMSYSERR_INVALPARAM;
170 if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED))
171 return MMSYSERR_INVALFLAG;
173 add.cbStruct = sizeof(add);
174 for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) {
175 if (acmDriverDetailsW((HACMDRIVERID)p, &add, 0) != MMSYSERR_NOERROR)
178 if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
179 add.fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
183 if (!(*fnCallback)((HACMDRIVERID)p, dwInstance, add.fdwSupport))
187 return MMSYSERR_NOERROR;
190 /***********************************************************************
191 * acmDriverID (MSACM32.8)
193 MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
198 return MMSYSERR_INVALPARAM;
201 return MMSYSERR_INVALFLAG;
203 pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
205 return MMSYSERR_INVALHANDLE;
207 *phadid = (HACMDRIVERID) pao->pACMDriverID;
209 return MMSYSERR_NOERROR;
212 /***********************************************************************
213 * acmDriverMessage (MSACM32.9)
216 LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
218 if ((uMsg >= ACMDM_USER && uMsg < ACMDM_RESERVED_LOW) ||
219 uMsg == ACMDM_DRIVER_ABOUT ||
220 uMsg == DRV_QUERYCONFIGURE ||
221 uMsg == DRV_CONFIGURE)
222 return MSACM_Message(had, uMsg, lParam1, lParam2);
223 return MMSYSERR_INVALPARAM;
227 /***********************************************************************
228 * acmDriverOpen (MSACM32.10)
230 MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
232 PWINE_ACMDRIVERID padid;
235 TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
238 return MMSYSERR_INVALPARAM;
241 return MMSYSERR_INVALFLAG;
243 padid = MSACM_GetDriverID(hadid);
245 return MMSYSERR_INVALHANDLE;
247 pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
248 if (!pad) return MMSYSERR_NOMEM;
250 pad->obj.dwType = WINE_ACMOBJ_DRIVER;
251 pad->obj.pACMDriverID = padid;
253 if (!(pad->hDrvr = padid->hInstModule) && padid->pszDriverAlias)
254 pad->hDrvr = OpenDriverA(padid->pszDriverAlias, NULL, 0);
256 HeapFree(MSACM_hHeap, 0, pad);
257 return MMSYSERR_ERROR;
260 /* insert new pad at beg of list */
261 pad->pNextACMDriver = padid->pACMDriverList;
262 padid->pACMDriverList = pad;
264 /* FIXME: Create a WINE_ACMDRIVER32 */
265 *phad = (HACMDRIVER)pad;
266 TRACE("'%s' => %08lx\n", padid->pszDriverAlias, (DWORD)pad);
267 return MMSYSERR_NOERROR;
270 /***********************************************************************
271 * acmDriverPriority (MSACM32.11)
273 MMRESULT WINAPI acmDriverPriority(HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority)
275 PWINE_ACMDRIVERID padid;
278 LONG lBufferLength = sizeof(szBuffer);
281 DWORD dwPriorityCounter;
283 padid = MSACM_GetDriverID(hadid);
285 return MMSYSERR_INVALHANDLE;
287 /* Check for unknown flags */
289 ~(ACM_DRIVERPRIORITYF_ENABLE|ACM_DRIVERPRIORITYF_DISABLE|
290 ACM_DRIVERPRIORITYF_BEGIN|ACM_DRIVERPRIORITYF_END))
291 return MMSYSERR_INVALFLAG;
293 /* Check for incompatible flags */
294 if ((fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) &&
295 (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE))
296 return MMSYSERR_INVALFLAG;
298 /* Check for incompatible flags */
299 if ((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) &&
300 (fdwPriority & ACM_DRIVERPRIORITYF_END))
301 return MMSYSERR_INVALFLAG;
303 lError = RegOpenKeyA(HKEY_CURRENT_USER,
304 "Software\\Microsoft\\Multimedia\\"
305 "Audio Compression Manager\\Priority v4.00",
308 /* FIXME: Create key */
309 if (lError != ERROR_SUCCESS)
310 return MMSYSERR_ERROR;
312 for (dwPriorityCounter = 1; ; dwPriorityCounter++) {
313 snprintf(szSubKey, 17, "Priorty%ld", dwPriorityCounter);
314 lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength);
315 if (lError != ERROR_SUCCESS)
318 FIXME("(0x%08x, %ld, %ld): stub (partial)\n",
319 hadid, dwPriority, fdwPriority);
323 RegCloseKey(hPriorityKey);
325 return MMSYSERR_ERROR;
328 /***********************************************************************
329 * acmDriverRemove (MSACM32.12)
331 MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
333 PWINE_ACMDRIVERID padid;
335 padid = MSACM_GetDriverID(hadid);
337 return MMSYSERR_INVALHANDLE;
340 return MMSYSERR_INVALFLAG;
342 MSACM_UnregisterDriver(padid);
344 return MMSYSERR_NOERROR;