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
25 #include "wine/port.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msacm
);
46 /***********************************************************************
47 * acmDriverAddA (MSACM32.@)
49 MMRESULT WINAPI
acmDriverAddA(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
50 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
53 return MMSYSERR_INVALPARAM
;
55 /* Check if any unknown flags */
57 ~(ACM_DRIVERADDF_FUNCTION
|ACM_DRIVERADDF_NOTIFYHWND
|
58 ACM_DRIVERADDF_GLOBAL
))
59 return MMSYSERR_INVALFLAG
;
61 /* Check if any incompatible flags */
62 if ((fdwAdd
& ACM_DRIVERADDF_FUNCTION
) &&
63 (fdwAdd
& ACM_DRIVERADDF_NOTIFYHWND
))
64 return MMSYSERR_INVALFLAG
;
66 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
67 * LoadDriver on it, to be sure we can call SendDriverMessage on the
70 *phadid
= (HACMDRIVERID
) MSACM_RegisterDriver(NULL
, NULL
, hinstModule
);
72 /* FIXME: lParam, dwPriority and fdwAdd ignored */
74 return MMSYSERR_NOERROR
;
77 /***********************************************************************
78 * acmDriverAddW (MSACM32.@)
82 MMRESULT WINAPI
acmDriverAddW(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
83 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
85 FIXME("(%p, %p, %ld, %ld, %ld): stub\n",
86 phadid
, hinstModule
, lParam
, dwPriority
, fdwAdd
);
88 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
89 return MMSYSERR_ERROR
;
92 /***********************************************************************
93 * acmDriverClose (MSACM32.@)
95 MMRESULT WINAPI
acmDriverClose(HACMDRIVER had
, DWORD fdwClose
)
98 PWINE_ACMDRIVERID padid
;
99 PWINE_ACMDRIVER
* tpad
;
102 return MMSYSERR_INVALFLAG
;
104 pad
= MSACM_GetDriver(had
);
106 return MMSYSERR_INVALHANDLE
;
108 padid
= pad
->obj
.pACMDriverID
;
110 /* remove driver from list */
111 for (tpad
= &(padid
->pACMDriverList
); *tpad
; *tpad
= (*tpad
)->pNextACMDriver
) {
113 *tpad
= (*tpad
)->pNextACMDriver
;
118 /* close driver if it has been opened */
119 if (pad
->hDrvr
&& !padid
->hInstModule
)
120 CloseDriver(pad
->hDrvr
, 0, 0);
122 HeapFree(MSACM_hHeap
, 0, pad
);
124 return MMSYSERR_NOERROR
;
127 /***********************************************************************
128 * acmDriverDetailsA (MSACM32.@)
130 MMRESULT WINAPI
acmDriverDetailsA(HACMDRIVERID hadid
, PACMDRIVERDETAILSA padd
, DWORD fdwDetails
)
133 ACMDRIVERDETAILSW addw
;
135 addw
.cbStruct
= sizeof(addw
);
136 mmr
= acmDriverDetailsW(hadid
, &addw
, fdwDetails
);
138 padd
->fccType
= addw
.fccType
;
139 padd
->fccComp
= addw
.fccComp
;
140 padd
->wMid
= addw
.wMid
;
141 padd
->wPid
= addw
.wPid
;
142 padd
->vdwACM
= addw
.vdwACM
;
143 padd
->vdwDriver
= addw
.vdwDriver
;
144 padd
->fdwSupport
= addw
.fdwSupport
;
145 padd
->cFormatTags
= addw
.cFormatTags
;
146 padd
->cFilterTags
= addw
.cFilterTags
;
147 padd
->hicon
= addw
.hicon
;
148 WideCharToMultiByte( CP_ACP
, 0, addw
.szShortName
, -1, padd
->szShortName
,
149 sizeof(padd
->szShortName
), NULL
, NULL
);
150 WideCharToMultiByte( CP_ACP
, 0, addw
.szLongName
, -1, padd
->szLongName
,
151 sizeof(padd
->szLongName
), NULL
, NULL
);
152 WideCharToMultiByte( CP_ACP
, 0, addw
.szCopyright
, -1, padd
->szCopyright
,
153 sizeof(padd
->szCopyright
), NULL
, NULL
);
154 WideCharToMultiByte( CP_ACP
, 0, addw
.szLicensing
, -1, padd
->szLicensing
,
155 sizeof(padd
->szLicensing
), NULL
, NULL
);
156 WideCharToMultiByte( CP_ACP
, 0, addw
.szFeatures
, -1, padd
->szFeatures
,
157 sizeof(padd
->szFeatures
), NULL
, NULL
);
162 /***********************************************************************
163 * acmDriverDetailsW (MSACM32.@)
165 MMRESULT WINAPI
acmDriverDetailsW(HACMDRIVERID hadid
, PACMDRIVERDETAILSW padd
, DWORD fdwDetails
)
171 return MMSYSERR_INVALFLAG
;
173 mmr
= acmDriverOpen(&acmDrvr
, hadid
, 0);
174 if (mmr
== MMSYSERR_NOERROR
) {
175 mmr
= (MMRESULT
)MSACM_Message(acmDrvr
, ACMDM_DRIVER_DETAILS
, (LPARAM
)padd
, 0);
177 acmDriverClose(acmDrvr
, 0);
183 /***********************************************************************
184 * acmDriverEnum (MSACM32.@)
186 MMRESULT WINAPI
acmDriverEnum(ACMDRIVERENUMCB fnCallback
, DWORD dwInstance
, DWORD fdwEnum
)
188 PWINE_ACMDRIVERID padid
;
191 if (!fnCallback
) return MMSYSERR_INVALPARAM
;
193 if (fdwEnum
& ~(ACM_DRIVERENUMF_NOLOCAL
|ACM_DRIVERENUMF_DISABLED
))
194 return MMSYSERR_INVALFLAG
;
196 for (padid
= MSACM_pFirstACMDriverID
; padid
; padid
= padid
->pNextACMDriverID
) {
197 fdwSupport
= padid
->fdwSupport
;
199 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
200 if (fdwEnum
& ACM_DRIVERENUMF_DISABLED
)
201 fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
205 if (!(*fnCallback
)((HACMDRIVERID
)padid
, dwInstance
, fdwSupport
))
209 return MMSYSERR_NOERROR
;
212 /***********************************************************************
213 * acmDriverID (MSACM32.@)
215 MMRESULT WINAPI
acmDriverID(HACMOBJ hao
, PHACMDRIVERID phadid
, DWORD fdwDriverID
)
220 return MMSYSERR_INVALPARAM
;
223 return MMSYSERR_INVALFLAG
;
225 pao
= MSACM_GetObj(hao
, WINE_ACMOBJ_DONTCARE
);
227 return MMSYSERR_INVALHANDLE
;
229 *phadid
= (HACMDRIVERID
) pao
->pACMDriverID
;
231 return MMSYSERR_NOERROR
;
234 /***********************************************************************
235 * acmDriverMessage (MSACM32.@)
238 LRESULT WINAPI
acmDriverMessage(HACMDRIVER had
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
240 if ((uMsg
>= ACMDM_USER
&& uMsg
< ACMDM_RESERVED_LOW
) ||
241 uMsg
== ACMDM_DRIVER_ABOUT
||
242 uMsg
== DRV_QUERYCONFIGURE
||
243 uMsg
== DRV_CONFIGURE
)
244 return MSACM_Message(had
, uMsg
, lParam1
, lParam2
);
245 return MMSYSERR_INVALPARAM
;
248 /***********************************************************************
249 * acmDriverOpen (MSACM32.@)
251 MMRESULT WINAPI
acmDriverOpen(PHACMDRIVER phad
, HACMDRIVERID hadid
, DWORD fdwOpen
)
253 PWINE_ACMDRIVERID padid
;
254 PWINE_ACMDRIVER pad
= NULL
;
257 TRACE("(%p, %p, %08lu)\n", phad
, hadid
, fdwOpen
);
260 return MMSYSERR_INVALPARAM
;
263 return MMSYSERR_INVALFLAG
;
265 padid
= MSACM_GetDriverID(hadid
);
267 return MMSYSERR_INVALHANDLE
;
269 pad
= HeapAlloc(MSACM_hHeap
, 0, sizeof(WINE_ACMDRIVER
));
271 return MMSYSERR_NOMEM
;
273 pad
->obj
.dwType
= WINE_ACMOBJ_DRIVER
;
274 pad
->obj
.pACMDriverID
= padid
;
276 if (!(pad
->hDrvr
= (HDRVR
)padid
->hInstModule
))
278 ACMDRVOPENDESCW adod
;
281 /* this is not an externally added driver... need to actually load it */
282 if (!padid
->pszDriverAlias
)
284 ret
= MMSYSERR_ERROR
;
288 adod
.cbStruct
= sizeof(adod
);
289 adod
.fccType
= ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
;
290 adod
.fccComp
= ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
;
291 adod
.dwVersion
= acmGetVersion();
292 adod
.dwFlags
= fdwOpen
;
294 len
= strlen("Drivers32") + 1;
295 adod
.pszSectionName
= HeapAlloc(MSACM_hHeap
, 0, len
* sizeof(WCHAR
));
296 MultiByteToWideChar(CP_ACP
, 0, "Drivers32", -1, (LPWSTR
)adod
.pszSectionName
, len
);
297 adod
.pszAliasName
= padid
->pszDriverAlias
;
300 pad
->hDrvr
= OpenDriver(padid
->pszDriverAlias
, NULL
, (DWORD
)&adod
);
302 HeapFree(MSACM_hHeap
, 0, (LPWSTR
)adod
.pszSectionName
);
310 /* insert new pad at beg of list */
311 pad
->pNextACMDriver
= padid
->pACMDriverList
;
312 padid
->pACMDriverList
= pad
;
314 /* FIXME: Create a WINE_ACMDRIVER32 */
315 *phad
= (HACMDRIVER
)pad
;
316 TRACE("'%s' => %08lx\n", debugstr_w(padid
->pszDriverAlias
), (DWORD
)pad
);
318 return MMSYSERR_NOERROR
;
320 if (pad
&& !pad
->hDrvr
)
321 HeapFree(MSACM_hHeap
, 0, pad
);
325 /***********************************************************************
326 * acmDriverPriority (MSACM32.@)
328 MMRESULT WINAPI
acmDriverPriority(HACMDRIVERID hadid
, DWORD dwPriority
, DWORD fdwPriority
)
330 PWINE_ACMDRIVERID padid
;
333 LONG lBufferLength
= sizeof(szBuffer
);
336 DWORD dwPriorityCounter
;
338 padid
= MSACM_GetDriverID(hadid
);
340 return MMSYSERR_INVALHANDLE
;
342 /* Check for unknown flags */
344 ~(ACM_DRIVERPRIORITYF_ENABLE
|ACM_DRIVERPRIORITYF_DISABLE
|
345 ACM_DRIVERPRIORITYF_BEGIN
|ACM_DRIVERPRIORITYF_END
))
346 return MMSYSERR_INVALFLAG
;
348 /* Check for incompatible flags */
349 if ((fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) &&
350 (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
))
351 return MMSYSERR_INVALFLAG
;
353 /* Check for incompatible flags */
354 if ((fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) &&
355 (fdwPriority
& ACM_DRIVERPRIORITYF_END
))
356 return MMSYSERR_INVALFLAG
;
358 lError
= RegOpenKeyA(HKEY_CURRENT_USER
,
359 "Software\\Microsoft\\Multimedia\\"
360 "Audio Compression Manager\\Priority v4.00",
363 /* FIXME: Create key */
364 if (lError
!= ERROR_SUCCESS
)
365 return MMSYSERR_ERROR
;
367 for (dwPriorityCounter
= 1; ; dwPriorityCounter
++) {
368 snprintf(szSubKey
, 17, "Priority%ld", dwPriorityCounter
);
369 lError
= RegQueryValueA(hPriorityKey
, szSubKey
, szBuffer
, &lBufferLength
);
370 if (lError
!= ERROR_SUCCESS
)
373 FIXME("(%p, %ld, %ld): stub (partial)\n",
374 hadid
, dwPriority
, fdwPriority
);
378 RegCloseKey(hPriorityKey
);
380 return MMSYSERR_ERROR
;
383 /***********************************************************************
384 * acmDriverRemove (MSACM32.@)
386 MMRESULT WINAPI
acmDriverRemove(HACMDRIVERID hadid
, DWORD fdwRemove
)
388 PWINE_ACMDRIVERID padid
;
390 padid
= MSACM_GetDriverID(hadid
);
392 return MMSYSERR_INVALHANDLE
;
395 return MMSYSERR_INVALFLAG
;
397 MSACM_UnregisterDriver(padid
);
399 return MMSYSERR_NOERROR
;