1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(msacm
);
41 /***********************************************************************
42 * acmDriverAddA (MSACM32.@)
44 MMRESULT WINAPI
acmDriverAddA(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
45 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
48 return MMSYSERR_INVALPARAM
;
50 /* Check if any unknown flags */
52 ~(ACM_DRIVERADDF_FUNCTION
|ACM_DRIVERADDF_NOTIFYHWND
|
53 ACM_DRIVERADDF_GLOBAL
))
54 return MMSYSERR_INVALFLAG
;
56 /* Check if any incompatible flags */
57 if ((fdwAdd
& ACM_DRIVERADDF_FUNCTION
) &&
58 (fdwAdd
& ACM_DRIVERADDF_NOTIFYHWND
))
59 return MMSYSERR_INVALFLAG
;
61 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
62 * LoadDriver on it, to be sure we can call SendDriverMessage on the
65 *phadid
= (HACMDRIVERID
) MSACM_RegisterDriver(NULL
, NULL
, hinstModule
);
67 /* FIXME: lParam, dwPriority and fdwAdd ignored */
69 return MMSYSERR_NOERROR
;
72 /***********************************************************************
73 * acmDriverAddW (MSACM32.@)
77 MMRESULT WINAPI
acmDriverAddW(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
78 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
80 FIXME("(%p, 0x%08x, %ld, %ld, %ld): stub\n",
81 phadid
, hinstModule
, lParam
, dwPriority
, fdwAdd
);
83 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
84 return MMSYSERR_ERROR
;
87 /***********************************************************************
88 * acmDriverClose (MSACM32.@)
90 MMRESULT WINAPI
acmDriverClose(HACMDRIVER had
, DWORD fdwClose
)
93 PWINE_ACMDRIVERID padid
;
94 PWINE_ACMDRIVER
* tpad
;
97 return MMSYSERR_INVALFLAG
;
99 pad
= MSACM_GetDriver(had
);
101 return MMSYSERR_INVALHANDLE
;
103 padid
= pad
->obj
.pACMDriverID
;
105 /* remove driver from list */
106 for (tpad
= &(padid
->pACMDriverList
); *tpad
; *tpad
= (*tpad
)->pNextACMDriver
) {
108 *tpad
= (*tpad
)->pNextACMDriver
;
113 /* close driver if it has been opened */
114 if (pad
->hDrvr
&& !padid
->hInstModule
)
115 CloseDriver(pad
->hDrvr
, 0, 0);
117 HeapFree(MSACM_hHeap
, 0, pad
);
119 return MMSYSERR_NOERROR
;
122 /***********************************************************************
123 * acmDriverDetailsA (MSACM32.@)
125 MMRESULT WINAPI
acmDriverDetailsA(HACMDRIVERID hadid
, PACMDRIVERDETAILSA padd
, DWORD fdwDetails
)
128 ACMDRIVERDETAILSW addw
;
130 addw
.cbStruct
= sizeof(addw
);
131 mmr
= acmDriverDetailsW(hadid
, &addw
, fdwDetails
);
133 padd
->fccType
= addw
.fccType
;
134 padd
->fccComp
= addw
.fccComp
;
135 padd
->wMid
= addw
.wMid
;
136 padd
->wPid
= addw
.wPid
;
137 padd
->vdwACM
= addw
.vdwACM
;
138 padd
->vdwDriver
= addw
.vdwDriver
;
139 padd
->fdwSupport
= addw
.fdwSupport
;
140 padd
->cFormatTags
= addw
.cFormatTags
;
141 padd
->cFilterTags
= addw
.cFilterTags
;
142 padd
->hicon
= addw
.hicon
;
143 WideCharToMultiByte( CP_ACP
, 0, addw
.szShortName
, -1, padd
->szShortName
,
144 sizeof(padd
->szShortName
), NULL
, NULL
);
145 WideCharToMultiByte( CP_ACP
, 0, addw
.szLongName
, -1, padd
->szLongName
,
146 sizeof(padd
->szLongName
), NULL
, NULL
);
147 WideCharToMultiByte( CP_ACP
, 0, addw
.szCopyright
, -1, padd
->szCopyright
,
148 sizeof(padd
->szCopyright
), NULL
, NULL
);
149 WideCharToMultiByte( CP_ACP
, 0, addw
.szLicensing
, -1, padd
->szLicensing
,
150 sizeof(padd
->szLicensing
), NULL
, NULL
);
151 WideCharToMultiByte( CP_ACP
, 0, addw
.szFeatures
, -1, padd
->szFeatures
,
152 sizeof(padd
->szFeatures
), NULL
, NULL
);
157 /***********************************************************************
158 * acmDriverDetailsW (MSACM32.@)
160 MMRESULT WINAPI
acmDriverDetailsW(HACMDRIVERID hadid
, PACMDRIVERDETAILSW padd
, DWORD fdwDetails
)
166 return MMSYSERR_INVALFLAG
;
168 mmr
= acmDriverOpen(&acmDrvr
, hadid
, 0);
169 if (mmr
== MMSYSERR_NOERROR
) {
170 mmr
= (MMRESULT
)MSACM_Message(acmDrvr
, ACMDM_DRIVER_DETAILS
, (LPARAM
)padd
, 0);
172 acmDriverClose(acmDrvr
, 0);
178 /***********************************************************************
179 * acmDriverEnum (MSACM32.@)
181 MMRESULT WINAPI
acmDriverEnum(ACMDRIVERENUMCB fnCallback
, DWORD dwInstance
, DWORD fdwEnum
)
183 PWINE_ACMDRIVERID padid
;
186 if (!fnCallback
) return MMSYSERR_INVALPARAM
;
188 if (fdwEnum
& ~(ACM_DRIVERENUMF_NOLOCAL
|ACM_DRIVERENUMF_DISABLED
))
189 return MMSYSERR_INVALFLAG
;
191 for (padid
= MSACM_pFirstACMDriverID
; padid
; padid
= padid
->pNextACMDriverID
) {
192 fdwSupport
= padid
->fdwSupport
;
194 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
195 if (fdwEnum
& ACM_DRIVERENUMF_DISABLED
)
196 fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
200 if (!(*fnCallback
)((HACMDRIVERID
)padid
, dwInstance
, fdwSupport
))
204 return MMSYSERR_NOERROR
;
207 /***********************************************************************
208 * acmDriverID (MSACM32.@)
210 MMRESULT WINAPI
acmDriverID(HACMOBJ hao
, PHACMDRIVERID phadid
, DWORD fdwDriverID
)
215 return MMSYSERR_INVALPARAM
;
218 return MMSYSERR_INVALFLAG
;
220 pao
= MSACM_GetObj(hao
, WINE_ACMOBJ_DONTCARE
);
222 return MMSYSERR_INVALHANDLE
;
224 *phadid
= (HACMDRIVERID
) pao
->pACMDriverID
;
226 return MMSYSERR_NOERROR
;
229 /***********************************************************************
230 * acmDriverMessage (MSACM32.@)
233 LRESULT WINAPI
acmDriverMessage(HACMDRIVER had
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
235 if ((uMsg
>= ACMDM_USER
&& uMsg
< ACMDM_RESERVED_LOW
) ||
236 uMsg
== ACMDM_DRIVER_ABOUT
||
237 uMsg
== DRV_QUERYCONFIGURE
||
238 uMsg
== DRV_CONFIGURE
)
239 return MSACM_Message(had
, uMsg
, lParam1
, lParam2
);
240 return MMSYSERR_INVALPARAM
;
243 static MMRESULT
MSACM_DriverOpenHelper(PWINE_ACMDRIVER
* ppad
, PWINE_ACMDRIVERID padid
, DWORD fdwOpen
, BOOL useDesc
)
245 MMRESULT ret
= MMSYSERR_ERROR
;
250 pad
= HeapAlloc(MSACM_hHeap
, 0, sizeof(WINE_ACMDRIVER
));
251 if (!pad
) return MMSYSERR_NOMEM
;
253 pad
->obj
.dwType
= WINE_ACMOBJ_DRIVER
;
254 pad
->obj
.pACMDriverID
= padid
;
256 if (!(pad
->hDrvr
= padid
->hInstModule
)) {
257 /* this is not an externally added driver... need to load it */
258 if (!padid
->pszDriverAlias
) goto gotError
;
261 ACMDRVOPENDESCW adod
;
264 adod
.cbStruct
= sizeof(adod
);
265 adod
.fccType
= ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
;
266 adod
.fccComp
= ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
;
267 adod
.dwVersion
= acmGetVersion();
268 adod
.dwFlags
= fdwOpen
;
270 len
= strlen("Drivers32") + 1;
271 adod
.pszSectionName
= HeapAlloc(MSACM_hHeap
, 0, len
* sizeof(WCHAR
));
272 MultiByteToWideChar(CP_ACP
, 0, "Drivers32", -1, (LPWSTR
)adod
.pszSectionName
, len
);
273 len
= strlen(padid
->pszDriverAlias
) + 1;
274 adod
.pszAliasName
= HeapAlloc(MSACM_hHeap
, 0, len
* sizeof(WCHAR
));
275 MultiByteToWideChar(CP_ACP
, 0, padid
->pszDriverAlias
, -1, (LPWSTR
)adod
.pszAliasName
, len
);
278 pad
->hDrvr
= OpenDriverA(padid
->pszDriverAlias
, NULL
, (DWORD
)&adod
);
280 HeapFree(MSACM_hHeap
, 0, (LPWSTR
)adod
.pszSectionName
);
281 HeapFree(MSACM_hHeap
, 0, (LPWSTR
)adod
.pszAliasName
);
287 if (!(pad
->hDrvr
= OpenDriverA(padid
->pszDriverAlias
, 0L, 0L))) {
288 ret
= MMSYSERR_ERROR
;
294 return MMSYSERR_NOERROR
;
296 HeapFree(MSACM_hHeap
, 0, pad
);
300 /***********************************************************************
301 * acmDriverOpen (MSACM32.@)
303 MMRESULT WINAPI
acmDriverOpen(PHACMDRIVER phad
, HACMDRIVERID hadid
, DWORD fdwOpen
)
305 PWINE_ACMDRIVERID padid
;
306 PWINE_ACMDRIVER pad
= NULL
, first_pad
= NULL
;
309 TRACE("(%p, %x, %08lu)\n", phad
, hadid
, fdwOpen
);
312 return MMSYSERR_INVALPARAM
;
315 return MMSYSERR_INVALFLAG
;
317 padid
= MSACM_GetDriverID(hadid
);
319 return MMSYSERR_INVALHANDLE
;
321 /* first driver to be loaded ? */
322 if (!padid
->pACMDriverList
&& !padid
->hInstModule
) {
323 ret
= MSACM_DriverOpenHelper(&first_pad
, padid
, fdwOpen
, FALSE
);
324 if (ret
) goto gotError
;
327 /* insert new pad at beg of list */
328 first_pad
->pNextACMDriver
= NULL
;
329 padid
->pACMDriverList
= first_pad
;
332 ret
= MSACM_DriverOpenHelper(&pad
, padid
, fdwOpen
, TRUE
);
335 acmDriverClose((HACMDRIVER
)first_pad
, 0L);
339 /* insert new pad at beg of list */
340 pad
->pNextACMDriver
= padid
->pACMDriverList
;
341 padid
->pACMDriverList
= pad
;
343 /* FIXME: Create a WINE_ACMDRIVER32 */
344 *phad
= (HACMDRIVER
)pad
;
345 TRACE("'%s' => %08lx\n", padid
->pszDriverAlias
, (DWORD
)pad
);
347 return MMSYSERR_NOERROR
;
349 if (pad
&& !pad
->hDrvr
)
350 HeapFree(MSACM_hHeap
, 0, pad
);
354 /***********************************************************************
355 * acmDriverPriority (MSACM32.@)
357 MMRESULT WINAPI
acmDriverPriority(HACMDRIVERID hadid
, DWORD dwPriority
, DWORD fdwPriority
)
359 PWINE_ACMDRIVERID padid
;
362 LONG lBufferLength
= sizeof(szBuffer
);
365 DWORD dwPriorityCounter
;
367 padid
= MSACM_GetDriverID(hadid
);
369 return MMSYSERR_INVALHANDLE
;
371 /* Check for unknown flags */
373 ~(ACM_DRIVERPRIORITYF_ENABLE
|ACM_DRIVERPRIORITYF_DISABLE
|
374 ACM_DRIVERPRIORITYF_BEGIN
|ACM_DRIVERPRIORITYF_END
))
375 return MMSYSERR_INVALFLAG
;
377 /* Check for incompatible flags */
378 if ((fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) &&
379 (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
))
380 return MMSYSERR_INVALFLAG
;
382 /* Check for incompatible flags */
383 if ((fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) &&
384 (fdwPriority
& ACM_DRIVERPRIORITYF_END
))
385 return MMSYSERR_INVALFLAG
;
387 lError
= RegOpenKeyA(HKEY_CURRENT_USER
,
388 "Software\\Microsoft\\Multimedia\\"
389 "Audio Compression Manager\\Priority v4.00",
392 /* FIXME: Create key */
393 if (lError
!= ERROR_SUCCESS
)
394 return MMSYSERR_ERROR
;
396 for (dwPriorityCounter
= 1; ; dwPriorityCounter
++) {
397 snprintf(szSubKey
, 17, "Priorty%ld", dwPriorityCounter
);
398 lError
= RegQueryValueA(hPriorityKey
, szSubKey
, szBuffer
, &lBufferLength
);
399 if (lError
!= ERROR_SUCCESS
)
402 FIXME("(0x%08x, %ld, %ld): stub (partial)\n",
403 hadid
, dwPriority
, fdwPriority
);
407 RegCloseKey(hPriorityKey
);
409 return MMSYSERR_ERROR
;
412 /***********************************************************************
413 * acmDriverRemove (MSACM32.@)
415 MMRESULT WINAPI
acmDriverRemove(HACMDRIVERID hadid
, DWORD fdwRemove
)
417 PWINE_ACMDRIVERID padid
;
419 padid
= MSACM_GetDriverID(hadid
);
421 return MMSYSERR_INVALHANDLE
;
424 return MMSYSERR_INVALFLAG
;
426 MSACM_UnregisterDriver(padid
);
428 return MMSYSERR_NOERROR
;