1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
15 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(msacm
)
26 /***********************************************************************
27 * acmDriverAddA (MSACM32.2)
29 MMRESULT WINAPI
acmDriverAddA(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
30 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
33 return MMSYSERR_INVALPARAM
;
35 /* Check if any unknown flags */
37 ~(ACM_DRIVERADDF_FUNCTION
|ACM_DRIVERADDF_NOTIFYHWND
|
38 ACM_DRIVERADDF_GLOBAL
))
39 return MMSYSERR_INVALFLAG
;
41 /* Check if any incompatible flags */
42 if ((fdwAdd
& ACM_DRIVERADDF_FUNCTION
) &&
43 (fdwAdd
& ACM_DRIVERADDF_NOTIFYHWND
))
44 return MMSYSERR_INVALFLAG
;
46 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
47 * LoadDriver on it, to be sure we can call SendDriverMessage on the
50 *phadid
= (HACMDRIVERID
) MSACM_RegisterDriver(NULL
, NULL
, hinstModule
);
52 /* FIXME: lParam, dwPriority and fdwAdd ignored */
54 return MMSYSERR_NOERROR
;
57 /***********************************************************************
58 * acmDriverAddW (MSACM32.3)
62 MMRESULT WINAPI
acmDriverAddW(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
63 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
65 FIXME("(%p, 0x%08x, %ld, %ld, %ld): stub\n",
66 phadid
, hinstModule
, lParam
, dwPriority
, fdwAdd
);
68 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
69 return MMSYSERR_ERROR
;
72 /***********************************************************************
73 * acmDriverClose (MSACM32.4)
75 MMRESULT WINAPI
acmDriverClose(HACMDRIVER had
, DWORD fdwClose
)
81 return MMSYSERR_INVALFLAG
;
83 p
= MSACM_GetDriver(had
);
85 return MMSYSERR_INVALHANDLE
;
87 for (tp
= &(p
->obj
.pACMDriverID
->pACMDriverList
); *tp
; *tp
= (*tp
)->pNextACMDriver
) {
89 *tp
= (*tp
)->pNextACMDriver
;
94 if (p
->hDrvr
&& !p
->obj
.pACMDriverID
->pACMDriverList
)
95 CloseDriver(p
->hDrvr
, 0, 0);
97 HeapFree(MSACM_hHeap
, 0, p
);
99 return MMSYSERR_NOERROR
;
102 /***********************************************************************
103 * acmDriverDetailsA (MSACM32.5)
105 MMRESULT WINAPI
acmDriverDetailsA(HACMDRIVERID hadid
, PACMDRIVERDETAILSA padd
, DWORD fdwDetails
)
108 ACMDRIVERDETAILSW addw
;
110 addw
.cbStruct
= sizeof(addw
);
111 mmr
= acmDriverDetailsW(hadid
, &addw
, fdwDetails
);
113 padd
->fccType
= addw
.fccType
;
114 padd
->fccComp
= addw
.fccComp
;
115 padd
->wMid
= addw
.wMid
;
116 padd
->wPid
= addw
.wPid
;
117 padd
->vdwACM
= addw
.vdwACM
;
118 padd
->vdwDriver
= addw
.vdwDriver
;
119 padd
->fdwSupport
= addw
.fdwSupport
;
120 padd
->cFormatTags
= addw
.cFormatTags
;
121 padd
->cFilterTags
= addw
.cFilterTags
;
122 padd
->hicon
= addw
.hicon
;
123 lstrcpyWtoA(padd
->szShortName
, addw
.szShortName
);
124 lstrcpyWtoA(padd
->szLongName
, addw
.szLongName
);
125 lstrcpyWtoA(padd
->szCopyright
, addw
.szCopyright
);
126 lstrcpyWtoA(padd
->szLicensing
, addw
.szLicensing
);
127 lstrcpyWtoA(padd
->szFeatures
, addw
.szFeatures
);
132 /***********************************************************************
133 * acmDriverDetailsW (MSACM32.6)
135 MMRESULT WINAPI
acmDriverDetailsW(HACMDRIVERID hadid
, PACMDRIVERDETAILSW padd
, DWORD fdwDetails
)
141 return MMSYSERR_INVALFLAG
;
143 mmr
= acmDriverOpen(&acmDrvr
, hadid
, 0);
145 mmr
= (MMRESULT
)acmDriverMessage(acmDrvr
, ACMDM_DRIVER_DETAILS
, (LPARAM
) padd
, 0);
147 acmDriverClose(acmDrvr
, 0);
153 /***********************************************************************
154 * acmDriverEnum (MSACM32.7)
156 MMRESULT WINAPI
acmDriverEnum(ACMDRIVERENUMCB fnCallback
, DWORD dwInstance
, DWORD fdwEnum
)
162 return MMSYSERR_INVALPARAM
;
165 if (fdwEnum
&& ~(ACM_DRIVERENUMF_NOLOCAL
|ACM_DRIVERENUMF_DISABLED
)) {
166 return MMSYSERR_INVALFLAG
;
169 for (p
= MSACM_pFirstACMDriverID
; p
; p
= p
->pNextACMDriverID
) {
170 fdwSupport
= ACMDRIVERDETAILS_SUPPORTF_CODEC
;
172 if (fdwEnum
& ACM_DRIVERENUMF_DISABLED
)
173 fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
177 (*fnCallback
)((HACMDRIVERID
) p
, dwInstance
, fdwSupport
);
180 return MMSYSERR_NOERROR
;
183 /***********************************************************************
184 * acmDriverID (MSACM32.8)
186 MMRESULT WINAPI
acmDriverID(HACMOBJ hao
, PHACMDRIVERID phadid
, DWORD fdwDriverID
)
190 pao
= MSACM_GetObj(hao
);
192 return MMSYSERR_INVALHANDLE
;
195 return MMSYSERR_INVALPARAM
;
198 return MMSYSERR_INVALFLAG
;
200 *phadid
= (HACMDRIVERID
) pao
->pACMDriverID
;
202 return MMSYSERR_NOERROR
;
205 /***********************************************************************
206 * acmDriverMessage (MSACM32.9)
210 LRESULT WINAPI
acmDriverMessage(HACMDRIVER had
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
212 PWINE_ACMDRIVER pad
= MSACM_GetDriver(had
);
214 return MMSYSERR_INVALPARAM
;
216 /* FIXME: Check if uMsg legal */
218 if (!SendDriverMessage(pad
->hDrvr
, uMsg
, lParam1
, lParam2
))
219 return MMSYSERR_NOTSUPPORTED
;
221 return MMSYSERR_NOERROR
;
225 /***********************************************************************
226 * acmDriverOpen (MSACM32.10)
228 MMRESULT WINAPI
acmDriverOpen(PHACMDRIVER phad
, HACMDRIVERID hadid
, DWORD fdwOpen
)
230 PWINE_ACMDRIVERID padid
;
233 TRACE("(%p, %x, %08lu)\n", phad
, hadid
, fdwOpen
);
236 return MMSYSERR_INVALPARAM
;
238 padid
= MSACM_GetDriverID(hadid
);
240 return MMSYSERR_INVALHANDLE
;
243 return MMSYSERR_INVALFLAG
;
245 pad
= HeapAlloc(MSACM_hHeap
, 0, sizeof(WINE_ACMDRIVER
));
246 if (!pad
) return MMSYSERR_NOMEM
;
248 pad
->obj
.pACMDriverID
= padid
;
250 if (!padid
->hInstModule
)
251 pad
->hDrvr
= OpenDriverA(padid
->pszDriverAlias
, "drivers32", 0);
253 pad
->hDrvr
= padid
->hInstModule
;
256 HeapFree(MSACM_hHeap
, 0, pad
);
257 return MMSYSERR_ERROR
;
260 pad
->pfnDriverProc
= GetProcAddress(pad
->hDrvr
, "DriverProc");
262 /* insert new pad at beg of list */
263 pad
->pNextACMDriver
= padid
->pACMDriverList
;
264 padid
->pACMDriverList
= pad
;
266 /* FIXME: Create a WINE_ACMDRIVER32 */
267 *phad
= (HACMDRIVER
)pad
;
269 return MMSYSERR_NOERROR
;
272 /***********************************************************************
273 * acmDriverPriority (MSACM32.11)
275 MMRESULT WINAPI
acmDriverPriority(HACMDRIVERID hadid
, DWORD dwPriority
, DWORD fdwPriority
)
277 PWINE_ACMDRIVERID padid
;
280 LONG lBufferLength
= sizeof(szBuffer
);
283 DWORD dwPriorityCounter
;
285 padid
= MSACM_GetDriverID(hadid
);
287 return MMSYSERR_INVALHANDLE
;
289 /* Check for unknown flags */
291 ~(ACM_DRIVERPRIORITYF_ENABLE
|ACM_DRIVERPRIORITYF_DISABLE
|
292 ACM_DRIVERPRIORITYF_BEGIN
|ACM_DRIVERPRIORITYF_END
))
293 return MMSYSERR_INVALFLAG
;
295 /* Check for incompatible flags */
296 if ((fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) &&
297 (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
))
298 return MMSYSERR_INVALFLAG
;
300 /* Check for incompatible flags */
301 if ((fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) &&
302 (fdwPriority
& ACM_DRIVERPRIORITYF_END
))
303 return MMSYSERR_INVALFLAG
;
305 lError
= RegOpenKeyA(HKEY_CURRENT_USER
,
306 "Software\\Microsoft\\Multimedia\\"
307 "Audio Compression Manager\\Priority v4.00",
310 /* FIXME: Create key */
311 if (lError
!= ERROR_SUCCESS
)
312 return MMSYSERR_ERROR
;
314 for (dwPriorityCounter
= 1; ; dwPriorityCounter
++) {
315 wsnprintfA(szSubKey
, 17, "Priorty%ld", dwPriorityCounter
);
316 lError
= RegQueryValueA(hPriorityKey
, szSubKey
, szBuffer
, &lBufferLength
);
317 if (lError
!= ERROR_SUCCESS
)
320 FIXME("(0x%08x, %ld, %ld): stub (partial)\n",
321 hadid
, dwPriority
, fdwPriority
);
325 RegCloseKey(hPriorityKey
);
327 return MMSYSERR_ERROR
;
330 /***********************************************************************
331 * acmDriverRemove (MSACM32.12)
333 MMRESULT WINAPI
acmDriverRemove(HACMDRIVERID hadid
, DWORD fdwRemove
)
335 PWINE_ACMDRIVERID padid
;
337 padid
= MSACM_GetDriverID(hadid
);
339 return MMSYSERR_INVALHANDLE
;
342 return MMSYSERR_INVALFLAG
;
344 MSACM_UnregisterDriver(padid
);
346 return MMSYSERR_NOERROR
;