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"
43 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(msacm
);
47 /***********************************************************************
48 * acmDriverAddA (MSACM32.@)
50 MMRESULT WINAPI
acmDriverAddA(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
51 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
54 WCHAR
* driverW
= NULL
;
55 LPARAM lParamW
= lParam
;
57 TRACE("(%p, %p, %08lx, %08lx, %08lx)\n",
58 phadid
, hinstModule
, lParam
, dwPriority
, fdwAdd
);
61 WARN("invalid parameter\n");
62 return MMSYSERR_INVALPARAM
;
65 /* Check if any unknown flags */
67 ~(ACM_DRIVERADDF_FUNCTION
|ACM_DRIVERADDF_NOTIFYHWND
|
68 ACM_DRIVERADDF_GLOBAL
)) {
69 WARN("invalid flag\n");
70 return MMSYSERR_INVALFLAG
;
73 /* Check if any incompatible flags */
74 if ((fdwAdd
& ACM_DRIVERADDF_FUNCTION
) &&
75 (fdwAdd
& ACM_DRIVERADDF_NOTIFYHWND
)) {
76 WARN("invalid flag\n");
77 return MMSYSERR_INVALFLAG
;
80 /* A->W translation of name */
81 if ((fdwAdd
& ACM_DRIVERADDF_TYPEMASK
) == ACM_DRIVERADDF_NAME
) {
84 if (lParam
== 0) return MMSYSERR_INVALPARAM
;
85 len
= MultiByteToWideChar(CP_ACP
, 0, (LPSTR
)lParam
, -1, NULL
, 0);
86 driverW
= HeapAlloc(MSACM_hHeap
, 0, len
* sizeof(WCHAR
));
87 if (!driverW
) return MMSYSERR_NOMEM
;
88 MultiByteToWideChar(CP_ACP
, 0, (LPSTR
)lParam
, -1, driverW
, len
);
89 lParamW
= (LPARAM
)driverW
;
92 resultW
= acmDriverAddW(phadid
, hinstModule
, lParamW
, dwPriority
, fdwAdd
);
93 HeapFree(MSACM_hHeap
, 0, driverW
);
97 /***********************************************************************
98 * acmDriverAddW (MSACM32.@)
101 MMRESULT WINAPI
acmDriverAddW(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
102 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
104 PWINE_ACMLOCALDRIVER pLocalDrv
= NULL
;
106 TRACE("(%p, %p, %08lx, %08lx, %08lx)\n",
107 phadid
, hinstModule
, lParam
, dwPriority
, fdwAdd
);
110 WARN("invalid parameter\n");
111 return MMSYSERR_INVALPARAM
;
114 /* Check if any unknown flags */
116 ~(ACM_DRIVERADDF_FUNCTION
|ACM_DRIVERADDF_NOTIFYHWND
|
117 ACM_DRIVERADDF_GLOBAL
)) {
118 WARN("invalid flag\n");
119 return MMSYSERR_INVALFLAG
;
122 /* Check if any incompatible flags */
123 if ((fdwAdd
& ACM_DRIVERADDF_FUNCTION
) &&
124 (fdwAdd
& ACM_DRIVERADDF_NOTIFYHWND
)) {
125 WARN("invalid flag\n");
126 return MMSYSERR_INVALFLAG
;
129 switch (fdwAdd
& ACM_DRIVERADDF_TYPEMASK
) {
130 case ACM_DRIVERADDF_NAME
:
133 lParam name of value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
134 dwPriority (unused, set to 0)
136 *phadid
= (HACMDRIVERID
) MSACM_RegisterDriverFromRegistry((LPCWSTR
)lParam
);
138 ERR("Unable to register driver via ACM_DRIVERADDF_NAME\n");
139 return MMSYSERR_INVALPARAM
;
142 case ACM_DRIVERADDF_FUNCTION
:
144 hInstModule Handle of module which contains driver entry proc
145 lParam Driver function address
146 dwPriority (unused, set to 0)
148 fdwAdd
&= ~ACM_DRIVERADDF_TYPEMASK
;
149 /* FIXME: fdwAdd ignored */
150 /* Application-supplied acmDriverProc's are placed at the top of the priority unless
151 fdwAdd indicates ACM_DRIVERADDF_GLOBAL
153 pLocalDrv
= MSACM_RegisterLocalDriver(hinstModule
, (DRIVERPROC
)lParam
);
154 *phadid
= pLocalDrv
? (HACMDRIVERID
) MSACM_RegisterDriver(NULL
, NULL
, pLocalDrv
) : NULL
;
156 ERR("Unable to register driver via ACM_DRIVERADDF_FUNCTION\n");
157 return MMSYSERR_INVALPARAM
;
160 case ACM_DRIVERADDF_NOTIFYHWND
:
163 lParam Handle of notification window
164 dwPriority Window message to send for notification broadcasts
166 *phadid
= (HACMDRIVERID
) MSACM_RegisterNotificationWindow((HWND
)lParam
, dwPriority
);
168 ERR("Unable to register driver via ACM_DRIVERADDF_NOTIFYHWND\n");
169 return MMSYSERR_INVALPARAM
;
173 ERR("invalid flag value 0x%08lx for fdwAdd\n", fdwAdd
& ACM_DRIVERADDF_TYPEMASK
);
174 return MMSYSERR_INVALFLAG
;
177 MSACM_BroadcastNotification();
178 return MMSYSERR_NOERROR
;
181 /***********************************************************************
182 * acmDriverClose (MSACM32.@)
184 MMRESULT WINAPI
acmDriverClose(HACMDRIVER had
, DWORD fdwClose
)
187 PWINE_ACMDRIVERID padid
;
188 PWINE_ACMDRIVER
* tpad
;
190 TRACE("(%p, %08lx)\n", had
, fdwClose
);
193 WARN("invalid flag\n");
194 return MMSYSERR_INVALFLAG
;
197 pad
= MSACM_GetDriver(had
);
199 WARN("invalid handle\n");
200 return MMSYSERR_INVALHANDLE
;
203 padid
= pad
->obj
.pACMDriverID
;
205 /* remove driver from list */
206 for (tpad
= &(padid
->pACMDriverList
); *tpad
; tpad
= &((*tpad
)->pNextACMDriver
)) {
208 *tpad
= (*tpad
)->pNextACMDriver
;
213 /* close driver if it has been opened */
214 if (pad
->hDrvr
&& !pad
->pLocalDrvrInst
)
215 CloseDriver(pad
->hDrvr
, 0, 0);
216 else if (pad
->pLocalDrvrInst
)
217 MSACM_CloseLocalDriver(pad
->pLocalDrvrInst
);
219 HeapFree(MSACM_hHeap
, 0, pad
);
221 return MMSYSERR_NOERROR
;
224 /***********************************************************************
225 * acmDriverDetailsA (MSACM32.@)
227 MMRESULT WINAPI
acmDriverDetailsA(HACMDRIVERID hadid
, PACMDRIVERDETAILSA padd
, DWORD fdwDetails
)
230 ACMDRIVERDETAILSW addw
;
232 TRACE("(%p, %p, %08lx)\n", hadid
, padd
, fdwDetails
);
235 WARN("invalid parameter\n");
236 return MMSYSERR_INVALPARAM
;
239 if (padd
->cbStruct
< 4) {
240 WARN("invalid parameter\n");
241 return MMSYSERR_INVALPARAM
;
244 addw
.cbStruct
= sizeof(addw
);
245 mmr
= acmDriverDetailsW(hadid
, &addw
, fdwDetails
);
247 ACMDRIVERDETAILSA padda
;
249 padda
.fccType
= addw
.fccType
;
250 padda
.fccComp
= addw
.fccComp
;
251 padda
.wMid
= addw
.wMid
;
252 padda
.wPid
= addw
.wPid
;
253 padda
.vdwACM
= addw
.vdwACM
;
254 padda
.vdwDriver
= addw
.vdwDriver
;
255 padda
.fdwSupport
= addw
.fdwSupport
;
256 padda
.cFormatTags
= addw
.cFormatTags
;
257 padda
.cFilterTags
= addw
.cFilterTags
;
258 padda
.hicon
= addw
.hicon
;
259 WideCharToMultiByte( CP_ACP
, 0, addw
.szShortName
, -1, padda
.szShortName
,
260 sizeof(padda
.szShortName
), NULL
, NULL
);
261 WideCharToMultiByte( CP_ACP
, 0, addw
.szLongName
, -1, padda
.szLongName
,
262 sizeof(padda
.szLongName
), NULL
, NULL
);
263 WideCharToMultiByte( CP_ACP
, 0, addw
.szCopyright
, -1, padda
.szCopyright
,
264 sizeof(padda
.szCopyright
), NULL
, NULL
);
265 WideCharToMultiByte( CP_ACP
, 0, addw
.szLicensing
, -1, padda
.szLicensing
,
266 sizeof(padda
.szLicensing
), NULL
, NULL
);
267 WideCharToMultiByte( CP_ACP
, 0, addw
.szFeatures
, -1, padda
.szFeatures
,
268 sizeof(padda
.szFeatures
), NULL
, NULL
);
269 padda
.cbStruct
= min(padd
->cbStruct
, sizeof(*padd
));
270 memcpy(padd
, &padda
, padda
.cbStruct
);
275 /***********************************************************************
276 * acmDriverDetailsW (MSACM32.@)
278 MMRESULT WINAPI
acmDriverDetailsW(HACMDRIVERID hadid
, PACMDRIVERDETAILSW padd
, DWORD fdwDetails
)
283 TRACE("(%p, %p, %08lx)\n", hadid
, padd
, fdwDetails
);
286 WARN("invalid parameter\n");
287 return MMSYSERR_INVALPARAM
;
290 if (padd
->cbStruct
< 4) {
291 WARN("invalid parameter\n");
292 return MMSYSERR_INVALPARAM
;
296 WARN("invalid flag\n");
297 return MMSYSERR_INVALFLAG
;
300 mmr
= acmDriverOpen(&acmDrvr
, hadid
, 0);
301 if (mmr
== MMSYSERR_NOERROR
) {
302 ACMDRIVERDETAILSW paddw
;
303 paddw
.cbStruct
= sizeof(paddw
);
304 mmr
= (MMRESULT
)MSACM_Message(acmDrvr
, ACMDM_DRIVER_DETAILS
, (LPARAM
)&paddw
, 0);
306 acmDriverClose(acmDrvr
, 0);
307 paddw
.cbStruct
= min(padd
->cbStruct
, sizeof(*padd
));
308 memcpy(padd
, &paddw
, paddw
.cbStruct
);
314 /***********************************************************************
315 * acmDriverEnum (MSACM32.@)
317 MMRESULT WINAPI
acmDriverEnum(ACMDRIVERENUMCB fnCallback
, DWORD dwInstance
, DWORD fdwEnum
)
319 PWINE_ACMDRIVERID padid
;
322 TRACE("(%p, %08lx, %08lx)\n", fnCallback
, dwInstance
, fdwEnum
);
325 WARN("invalid parameter\n");
326 return MMSYSERR_INVALPARAM
;
329 if (fdwEnum
& ~(ACM_DRIVERENUMF_NOLOCAL
|ACM_DRIVERENUMF_DISABLED
)) {
330 WARN("invalid flag\n");
331 return MMSYSERR_INVALFLAG
;
334 for (padid
= MSACM_pFirstACMDriverID
; padid
; padid
= padid
->pNextACMDriverID
) {
335 fdwSupport
= padid
->fdwSupport
;
337 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
338 if (fdwEnum
& ACM_DRIVERENUMF_DISABLED
)
339 fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
343 if (!(*fnCallback
)((HACMDRIVERID
)padid
, dwInstance
, fdwSupport
))
347 return MMSYSERR_NOERROR
;
350 /***********************************************************************
351 * acmDriverID (MSACM32.@)
353 MMRESULT WINAPI
acmDriverID(HACMOBJ hao
, PHACMDRIVERID phadid
, DWORD fdwDriverID
)
357 TRACE("(%p, %p, %08lx)\n", hao
, phadid
, fdwDriverID
);
360 WARN("invalid flag\n");
361 return MMSYSERR_INVALFLAG
;
364 pao
= MSACM_GetObj(hao
, WINE_ACMOBJ_DONTCARE
);
366 WARN("invalid handle\n");
367 return MMSYSERR_INVALHANDLE
;
371 WARN("invalid parameter\n");
372 return MMSYSERR_INVALPARAM
;
375 *phadid
= (HACMDRIVERID
) pao
->pACMDriverID
;
377 return MMSYSERR_NOERROR
;
380 /***********************************************************************
381 * acmDriverMessage (MSACM32.@)
383 * Note: MSDN documentation (July 2001) is incomplete. This function
384 * accepts sending messages to an HACMDRIVERID in addition to the
385 * documented HACMDRIVER. In fact, for DRV_QUERYCONFIGURE and DRV_CONFIGURE,
386 * this might actually be the required mode of operation.
388 * Note: For DRV_CONFIGURE, msacm supplies its own DRVCONFIGINFO structure
389 * when the application fails to supply one. Some native drivers depend on
390 * this and refuse to display unless a valid DRVCONFIGINFO structure is
391 * built and supplied.
393 LRESULT WINAPI
acmDriverMessage(HACMDRIVER had
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
395 TRACE("(%p, %04x, %08lx, %08lx\n", had
, uMsg
, lParam1
, lParam2
);
397 if ((uMsg
>= ACMDM_USER
&& uMsg
< ACMDM_RESERVED_LOW
) ||
398 uMsg
== ACMDM_DRIVER_ABOUT
||
399 uMsg
== DRV_QUERYCONFIGURE
||
400 uMsg
== DRV_CONFIGURE
)
402 PWINE_ACMDRIVERID padid
;
404 LPDRVCONFIGINFO pConfigInfo
= NULL
;
406 /* Check whether handle is an HACMDRIVERID */
407 padid
= MSACM_GetDriverID((HACMDRIVERID
)had
);
409 /* If the message is DRV_CONFIGURE, and the application provides no
410 DRVCONFIGINFO structure, msacm must supply its own.
412 if (uMsg
== DRV_CONFIGURE
&& lParam2
== 0) {
415 /* Get the alias from the HACMDRIVERID */
417 pAlias
= padid
->pszDriverAlias
;
418 if (pAlias
== NULL
) {
419 WARN("DRV_CONFIGURE: no alias for this driver, cannot self-supply alias\n");
422 FIXME("DRV_CONFIGURE: reverse lookup HACMDRIVER -> HACMDRIVERID not implemented\n");
426 if (pAlias
!= NULL
) {
427 unsigned int iStructSize
= 16;
428 /* This verification is required because DRVCONFIGINFO is 12 bytes
429 long, yet native msacm reports a 16-byte structure to codecs.
431 if (iStructSize
< sizeof(DRVCONFIGINFO
)) iStructSize
= sizeof(DRVCONFIGINFO
);
432 pConfigInfo
= HeapAlloc(MSACM_hHeap
, 0, iStructSize
);
434 ERR("OOM while supplying DRVCONFIGINFO for DRV_CONFIGURE, using NULL\n");
436 static const WCHAR drivers32
[] = {'D','r','i','v','e','r','s','3','2','\0'};
437 pConfigInfo
->dwDCISize
= iStructSize
;
439 pConfigInfo
->lpszDCISectionName
= HeapAlloc(MSACM_hHeap
, 0, (strlenW(drivers32
) + 1) * sizeof(WCHAR
));
440 if (pConfigInfo
->lpszDCISectionName
) strcpyW((WCHAR
*)pConfigInfo
->lpszDCISectionName
, drivers32
);
441 pConfigInfo
->lpszDCIAliasName
= HeapAlloc(MSACM_hHeap
, 0, (strlenW(pAlias
) + 1) * sizeof(WCHAR
));
442 if (pConfigInfo
->lpszDCIAliasName
) strcpyW((WCHAR
*)pConfigInfo
->lpszDCIAliasName
, pAlias
);
444 if (pConfigInfo
->lpszDCISectionName
== NULL
|| pConfigInfo
->lpszDCIAliasName
== NULL
) {
445 HeapFree(MSACM_hHeap
, 0, (void *)pConfigInfo
->lpszDCIAliasName
);
446 HeapFree(MSACM_hHeap
, 0, (void *)pConfigInfo
->lpszDCISectionName
);
447 HeapFree(MSACM_hHeap
, 0, pConfigInfo
);
449 ERR("OOM while supplying DRVCONFIGINFO for DRV_CONFIGURE, using NULL\n");
454 lParam2
= (LPARAM
)pConfigInfo
;
458 /* Handle is really an HACMDRIVERID, must have an open session to get an HACMDRIVER */
459 if (padid
->pACMDriverList
!= NULL
) {
460 lResult
= MSACM_Message((HACMDRIVER
)padid
->pACMDriverList
, uMsg
, lParam1
, lParam2
);
462 MMRESULT mmr
= acmDriverOpen(&had
, (HACMDRIVERID
)padid
, 0);
463 if (mmr
!= MMSYSERR_NOERROR
) {
464 lResult
= MMSYSERR_INVALPARAM
;
466 lResult
= acmDriverMessage(had
, uMsg
, lParam1
, lParam2
);
467 acmDriverClose(had
, 0);
471 lResult
= MSACM_Message(had
, uMsg
, lParam1
, lParam2
);
474 HeapFree(MSACM_hHeap
, 0, (void *)pConfigInfo
->lpszDCIAliasName
);
475 HeapFree(MSACM_hHeap
, 0, (void *)pConfigInfo
->lpszDCISectionName
);
476 HeapFree(MSACM_hHeap
, 0, pConfigInfo
);
480 WARN("invalid parameter\n");
481 return MMSYSERR_INVALPARAM
;
484 /***********************************************************************
485 * acmDriverOpen (MSACM32.@)
487 MMRESULT WINAPI
acmDriverOpen(PHACMDRIVER phad
, HACMDRIVERID hadid
, DWORD fdwOpen
)
489 PWINE_ACMDRIVERID padid
;
490 PWINE_ACMDRIVER pad
= NULL
;
493 TRACE("(%p, %p, %08lu)\n", phad
, hadid
, fdwOpen
);
496 WARN("invalid parameter\n");
497 return MMSYSERR_INVALPARAM
;
501 WARN("invalid flag\n");
502 return MMSYSERR_INVALFLAG
;
505 padid
= MSACM_GetDriverID(hadid
);
507 WARN("invalid handle\n");
508 return MMSYSERR_INVALHANDLE
;
511 pad
= HeapAlloc(MSACM_hHeap
, 0, sizeof(WINE_ACMDRIVER
));
514 return MMSYSERR_NOMEM
;
517 pad
->obj
.dwType
= WINE_ACMOBJ_DRIVER
;
518 pad
->obj
.pACMDriverID
= padid
;
520 pad
->pLocalDrvrInst
= NULL
;
522 if (padid
->pLocalDriver
== NULL
)
524 ACMDRVOPENDESCW adod
;
527 /* this is not an externally added driver... need to actually load it */
528 if (!padid
->pszDriverAlias
)
530 ret
= MMSYSERR_ERROR
;
534 adod
.cbStruct
= sizeof(adod
);
535 adod
.fccType
= ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
;
536 adod
.fccComp
= ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
;
537 adod
.dwVersion
= acmGetVersion();
538 adod
.dwFlags
= fdwOpen
;
540 len
= strlen("Drivers32") + 1;
541 adod
.pszSectionName
= HeapAlloc(MSACM_hHeap
, 0, len
* sizeof(WCHAR
));
542 MultiByteToWideChar(CP_ACP
, 0, "Drivers32", -1, (LPWSTR
)adod
.pszSectionName
, len
);
543 adod
.pszAliasName
= padid
->pszDriverAlias
;
546 pad
->hDrvr
= OpenDriver(padid
->pszDriverAlias
, NULL
, (DWORD
)&adod
);
548 HeapFree(MSACM_hHeap
, 0, (LPWSTR
)adod
.pszSectionName
);
557 ACMDRVOPENDESCW adod
;
561 adod
.cbStruct
= sizeof(adod
);
562 adod
.fccType
= ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
;
563 adod
.fccComp
= ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
;
564 adod
.dwVersion
= acmGetVersion();
565 adod
.dwFlags
= fdwOpen
;
567 adod
.pszSectionName
= NULL
;
568 adod
.pszAliasName
= NULL
;
571 pad
->pLocalDrvrInst
= MSACM_OpenLocalDriver(padid
->pLocalDriver
, (DWORD
)&adod
);
572 if (!pad
->pLocalDrvrInst
)
579 /* insert new pad at beg of list */
580 pad
->pNextACMDriver
= padid
->pACMDriverList
;
581 padid
->pACMDriverList
= pad
;
583 /* FIXME: Create a WINE_ACMDRIVER32 */
584 *phad
= (HACMDRIVER
)pad
;
585 TRACE("'%s' => %p\n", debugstr_w(padid
->pszDriverAlias
), pad
);
587 return MMSYSERR_NOERROR
;
589 WARN("failed: ret = %08x\n", ret
);
590 if (pad
&& !pad
->hDrvr
)
591 HeapFree(MSACM_hHeap
, 0, pad
);
595 /***********************************************************************
596 * acmDriverPriority (MSACM32.@)
598 MMRESULT WINAPI
acmDriverPriority(HACMDRIVERID hadid
, DWORD dwPriority
, DWORD fdwPriority
)
601 TRACE("(%p, %08lx, %08lx)\n", hadid
, dwPriority
, fdwPriority
);
603 /* Check for unknown flags */
605 ~(ACM_DRIVERPRIORITYF_ENABLE
|ACM_DRIVERPRIORITYF_DISABLE
|
606 ACM_DRIVERPRIORITYF_BEGIN
|ACM_DRIVERPRIORITYF_END
)) {
607 WARN("invalid flag\n");
608 return MMSYSERR_INVALFLAG
;
611 /* Check for incompatible flags */
612 if ((fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) &&
613 (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
)) {
614 WARN("invalid flag\n");
615 return MMSYSERR_INVALFLAG
;
618 /* Check for incompatible flags */
619 if ((fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) &&
620 (fdwPriority
& ACM_DRIVERPRIORITYF_END
)) {
621 WARN("invalid flag\n");
622 return MMSYSERR_INVALFLAG
;
625 /* According to MSDN, ACM_DRIVERPRIORITYF_BEGIN and ACM_DRIVERPRIORITYF_END
626 may only appear by themselves, and in addition, hadid and dwPriority must
628 if ((fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) ||
629 (fdwPriority
& ACM_DRIVERPRIORITYF_END
)) {
630 if (fdwPriority
& ~(ACM_DRIVERPRIORITYF_BEGIN
|ACM_DRIVERPRIORITYF_END
)) {
631 WARN("ACM_DRIVERPRIORITYF_[BEGIN|END] cannot be used with any other flags\n");
632 return MMSYSERR_INVALPARAM
;
635 WARN("priority invalid with ACM_DRIVERPRIORITYF_[BEGIN|END]\n");
636 return MMSYSERR_INVALPARAM
;
639 WARN("non-null hadid invalid with ACM_DRIVERPRIORITYF_[BEGIN|END]\n");
640 return MMSYSERR_INVALPARAM
;
642 /* FIXME: MSDN wording suggests that deferred notification should be
643 implemented as a system-wide lock held by a calling task, and that
644 re-enabling notifications should broadcast them across all processes.
645 This implementation uses a simple DWORD counter. One consequence of the
646 current implementation is that applications will never see
647 MMSYSERR_ALLOCATED as a return error.
649 if (fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) {
650 MSACM_DisableNotifications();
651 } else if (fdwPriority
& ACM_DRIVERPRIORITYF_END
) {
652 MSACM_EnableNotifications();
654 return MMSYSERR_NOERROR
;
656 PWINE_ACMDRIVERID padid
;
657 PWINE_ACMNOTIFYWND panwnd
;
658 BOOL bPerformBroadcast
= FALSE
;
660 /* Fetch driver ID */
661 padid
= MSACM_GetDriverID(hadid
);
662 panwnd
= MSACM_GetNotifyWnd(hadid
);
663 if (!padid
&& !panwnd
) {
664 WARN("invalid handle\n");
665 return MMSYSERR_INVALHANDLE
;
669 /* Check whether driver ID is appropriate for requested op */
671 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_LOCAL
) {
672 return MMSYSERR_NOTSUPPORTED
;
674 if (dwPriority
!= 1 && dwPriority
!= -1) {
675 FIXME("unexpected priority %ld, using sign only\n", dwPriority
);
676 if (dwPriority
< 0) dwPriority
= -1;
677 if (dwPriority
> 0) dwPriority
= 1;
680 if (dwPriority
== 1 && (padid
->pPrevACMDriverID
== NULL
||
681 (padid
->pPrevACMDriverID
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_LOCAL
))) {
682 /* do nothing - driver is first of list, or first after last
684 } else if (dwPriority
== -1 && padid
->pNextACMDriverID
== NULL
) {
685 /* do nothing - driver is last of list */
687 MSACM_RePositionDriver(padid
, dwPriority
);
688 bPerformBroadcast
= TRUE
;
692 /* Check whether driver ID should be enabled or disabled */
693 if (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
) {
694 if (!(padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
)) {
695 padid
->fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
696 bPerformBroadcast
= TRUE
;
698 } else if (fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) {
699 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
700 padid
->fdwSupport
&= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
701 bPerformBroadcast
= TRUE
;
708 return MMSYSERR_NOTSUPPORTED
;
711 /* Check whether notify window should be enabled or disabled */
712 if (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
) {
713 if (!(panwnd
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
)) {
714 panwnd
->fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
715 bPerformBroadcast
= TRUE
;
717 } else if (fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) {
718 if (panwnd
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
719 panwnd
->fdwSupport
&= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
720 bPerformBroadcast
= TRUE
;
725 /* Perform broadcast of changes */
726 if (bPerformBroadcast
) {
727 MSACM_WriteCurrentPriorities();
728 MSACM_BroadcastNotification();
730 return MMSYSERR_NOERROR
;
734 /***********************************************************************
735 * acmDriverRemove (MSACM32.@)
737 MMRESULT WINAPI
acmDriverRemove(HACMDRIVERID hadid
, DWORD fdwRemove
)
739 PWINE_ACMDRIVERID padid
;
740 PWINE_ACMNOTIFYWND panwnd
;
742 TRACE("(%p, %08lx)\n", hadid
, fdwRemove
);
744 padid
= MSACM_GetDriverID(hadid
);
745 panwnd
= MSACM_GetNotifyWnd(hadid
);
746 if (!padid
&& !panwnd
) {
747 WARN("invalid handle\n");
748 return MMSYSERR_INVALHANDLE
;
752 WARN("invalid flag\n");
753 return MMSYSERR_INVALFLAG
;
756 if (padid
) MSACM_UnregisterDriver(padid
);
757 if (panwnd
) MSACM_UnRegisterNotificationWindow(panwnd
);
758 MSACM_BroadcastNotification();
760 return MMSYSERR_NOERROR
;