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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/port.h"
40 #include "wine/debug.h"
41 #include "wine/unicode.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msacm
);
45 /***********************************************************************
46 * acmDriverAddA (MSACM32.@)
48 MMRESULT WINAPI
acmDriverAddA(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
49 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
52 WCHAR
* driverW
= NULL
;
53 LPARAM lParamW
= lParam
;
55 TRACE("(%p, %p, %08lx, %08x, %08x)\n",
56 phadid
, hinstModule
, lParam
, dwPriority
, fdwAdd
);
59 WARN("invalid parameter\n");
60 return MMSYSERR_INVALPARAM
;
63 /* Check if any unknown flags */
65 ~(ACM_DRIVERADDF_FUNCTION
|ACM_DRIVERADDF_NOTIFYHWND
|
66 ACM_DRIVERADDF_GLOBAL
)) {
67 WARN("invalid flag\n");
68 return MMSYSERR_INVALFLAG
;
71 /* Check if any incompatible flags */
72 if ((fdwAdd
& ACM_DRIVERADDF_FUNCTION
) &&
73 (fdwAdd
& ACM_DRIVERADDF_NOTIFYHWND
)) {
74 WARN("invalid flag\n");
75 return MMSYSERR_INVALFLAG
;
78 /* A->W translation of name */
79 if ((fdwAdd
& ACM_DRIVERADDF_TYPEMASK
) == ACM_DRIVERADDF_NAME
) {
82 if (lParam
== 0) return MMSYSERR_INVALPARAM
;
83 len
= MultiByteToWideChar(CP_ACP
, 0, (LPSTR
)lParam
, -1, NULL
, 0);
84 driverW
= HeapAlloc(MSACM_hHeap
, 0, len
* sizeof(WCHAR
));
85 if (!driverW
) return MMSYSERR_NOMEM
;
86 MultiByteToWideChar(CP_ACP
, 0, (LPSTR
)lParam
, -1, driverW
, len
);
87 lParamW
= (LPARAM
)driverW
;
90 resultW
= acmDriverAddW(phadid
, hinstModule
, lParamW
, dwPriority
, fdwAdd
);
91 HeapFree(MSACM_hHeap
, 0, driverW
);
95 /***********************************************************************
96 * acmDriverAddW (MSACM32.@)
99 MMRESULT WINAPI
acmDriverAddW(PHACMDRIVERID phadid
, HINSTANCE hinstModule
,
100 LPARAM lParam
, DWORD dwPriority
, DWORD fdwAdd
)
102 PWINE_ACMLOCALDRIVER pLocalDrv
= NULL
;
104 TRACE("(%p, %p, %08lx, %08x, %08x)\n",
105 phadid
, hinstModule
, lParam
, dwPriority
, fdwAdd
);
108 WARN("invalid parameter\n");
109 return MMSYSERR_INVALPARAM
;
112 /* Check if any unknown flags */
114 ~(ACM_DRIVERADDF_FUNCTION
|ACM_DRIVERADDF_NOTIFYHWND
|
115 ACM_DRIVERADDF_GLOBAL
)) {
116 WARN("invalid flag\n");
117 return MMSYSERR_INVALFLAG
;
120 /* Check if any incompatible flags */
121 if ((fdwAdd
& ACM_DRIVERADDF_FUNCTION
) &&
122 (fdwAdd
& ACM_DRIVERADDF_NOTIFYHWND
)) {
123 WARN("invalid flag\n");
124 return MMSYSERR_INVALFLAG
;
127 switch (fdwAdd
& ACM_DRIVERADDF_TYPEMASK
) {
128 case ACM_DRIVERADDF_NAME
:
131 lParam name of value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
132 dwPriority (unused, set to 0)
134 *phadid
= (HACMDRIVERID
) MSACM_RegisterDriverFromRegistry((LPCWSTR
)lParam
);
136 ERR("Unable to register driver via ACM_DRIVERADDF_NAME\n");
137 return MMSYSERR_INVALPARAM
;
140 case ACM_DRIVERADDF_FUNCTION
:
142 hInstModule Handle of module which contains driver entry proc
143 lParam Driver function address
144 dwPriority (unused, set to 0)
146 fdwAdd
&= ~ACM_DRIVERADDF_TYPEMASK
;
147 /* FIXME: fdwAdd ignored */
148 /* Application-supplied acmDriverProc's are placed at the top of the priority unless
149 fdwAdd indicates ACM_DRIVERADDF_GLOBAL
151 pLocalDrv
= MSACM_RegisterLocalDriver(hinstModule
, (DRIVERPROC
)lParam
);
152 *phadid
= pLocalDrv
? (HACMDRIVERID
) MSACM_RegisterDriver(NULL
, NULL
, pLocalDrv
) : NULL
;
154 ERR("Unable to register driver via ACM_DRIVERADDF_FUNCTION\n");
155 return MMSYSERR_INVALPARAM
;
158 case ACM_DRIVERADDF_NOTIFYHWND
:
161 lParam Handle of notification window
162 dwPriority Window message to send for notification broadcasts
164 *phadid
= (HACMDRIVERID
) MSACM_RegisterNotificationWindow((HWND
)lParam
, dwPriority
);
166 ERR("Unable to register driver via ACM_DRIVERADDF_NOTIFYHWND\n");
167 return MMSYSERR_INVALPARAM
;
171 ERR("invalid flag value 0x%08lx for fdwAdd\n", fdwAdd
& ACM_DRIVERADDF_TYPEMASK
);
172 return MMSYSERR_INVALFLAG
;
175 MSACM_BroadcastNotification();
176 return MMSYSERR_NOERROR
;
179 /***********************************************************************
180 * acmDriverClose (MSACM32.@)
182 MMRESULT WINAPI
acmDriverClose(HACMDRIVER had
, DWORD fdwClose
)
185 PWINE_ACMDRIVERID padid
;
186 PWINE_ACMDRIVER
* tpad
;
188 TRACE("(%p, %08x)\n", had
, fdwClose
);
191 WARN("invalid flag\n");
192 return MMSYSERR_INVALFLAG
;
195 pad
= MSACM_GetDriver(had
);
197 WARN("invalid handle\n");
198 return MMSYSERR_INVALHANDLE
;
201 padid
= pad
->obj
.pACMDriverID
;
203 /* remove driver from list */
204 for (tpad
= &(padid
->pACMDriverList
); *tpad
; tpad
= &((*tpad
)->pNextACMDriver
)) {
206 *tpad
= (*tpad
)->pNextACMDriver
;
211 /* close driver if it has been opened */
212 if (pad
->hDrvr
&& !pad
->pLocalDrvrInst
)
213 CloseDriver(pad
->hDrvr
, 0, 0);
214 else if (pad
->pLocalDrvrInst
)
215 MSACM_CloseLocalDriver(pad
->pLocalDrvrInst
);
217 HeapFree(MSACM_hHeap
, 0, pad
);
219 return MMSYSERR_NOERROR
;
222 /***********************************************************************
223 * acmDriverDetailsA (MSACM32.@)
225 MMRESULT WINAPI
acmDriverDetailsA(HACMDRIVERID hadid
, PACMDRIVERDETAILSA padd
, DWORD fdwDetails
)
228 ACMDRIVERDETAILSW addw
;
230 TRACE("(%p, %p, %08x)\n", hadid
, padd
, fdwDetails
);
233 WARN("invalid parameter\n");
234 return MMSYSERR_INVALPARAM
;
237 if (padd
->cbStruct
< 4) {
238 WARN("invalid parameter\n");
239 return MMSYSERR_INVALPARAM
;
242 addw
.cbStruct
= sizeof(addw
);
243 mmr
= acmDriverDetailsW(hadid
, &addw
, fdwDetails
);
245 ACMDRIVERDETAILSA padda
;
247 padda
.fccType
= addw
.fccType
;
248 padda
.fccComp
= addw
.fccComp
;
249 padda
.wMid
= addw
.wMid
;
250 padda
.wPid
= addw
.wPid
;
251 padda
.vdwACM
= addw
.vdwACM
;
252 padda
.vdwDriver
= addw
.vdwDriver
;
253 padda
.fdwSupport
= addw
.fdwSupport
;
254 padda
.cFormatTags
= addw
.cFormatTags
;
255 padda
.cFilterTags
= addw
.cFilterTags
;
256 padda
.hicon
= addw
.hicon
;
257 WideCharToMultiByte( CP_ACP
, 0, addw
.szShortName
, -1, padda
.szShortName
,
258 sizeof(padda
.szShortName
), NULL
, NULL
);
259 WideCharToMultiByte( CP_ACP
, 0, addw
.szLongName
, -1, padda
.szLongName
,
260 sizeof(padda
.szLongName
), NULL
, NULL
);
261 WideCharToMultiByte( CP_ACP
, 0, addw
.szCopyright
, -1, padda
.szCopyright
,
262 sizeof(padda
.szCopyright
), NULL
, NULL
);
263 WideCharToMultiByte( CP_ACP
, 0, addw
.szLicensing
, -1, padda
.szLicensing
,
264 sizeof(padda
.szLicensing
), NULL
, NULL
);
265 WideCharToMultiByte( CP_ACP
, 0, addw
.szFeatures
, -1, padda
.szFeatures
,
266 sizeof(padda
.szFeatures
), NULL
, NULL
);
267 padda
.cbStruct
= min(padd
->cbStruct
, sizeof(*padd
));
268 memcpy(padd
, &padda
, padda
.cbStruct
);
273 /***********************************************************************
274 * acmDriverDetailsW (MSACM32.@)
276 MMRESULT WINAPI
acmDriverDetailsW(HACMDRIVERID hadid
, PACMDRIVERDETAILSW padd
, DWORD fdwDetails
)
281 TRACE("(%p, %p, %08x)\n", hadid
, padd
, fdwDetails
);
284 WARN("invalid parameter\n");
285 return MMSYSERR_INVALPARAM
;
288 if (padd
->cbStruct
< 4) {
289 WARN("invalid parameter\n");
290 return MMSYSERR_INVALPARAM
;
294 WARN("invalid flag\n");
295 return MMSYSERR_INVALFLAG
;
298 mmr
= acmDriverOpen(&acmDrvr
, hadid
, 0);
299 if (mmr
== MMSYSERR_NOERROR
) {
300 ACMDRIVERDETAILSW paddw
;
301 paddw
.cbStruct
= sizeof(paddw
);
302 mmr
= MSACM_Message(acmDrvr
, ACMDM_DRIVER_DETAILS
, (LPARAM
)&paddw
, 0);
304 acmDriverClose(acmDrvr
, 0);
305 paddw
.cbStruct
= min(padd
->cbStruct
, sizeof(*padd
));
306 memcpy(padd
, &paddw
, paddw
.cbStruct
);
312 /***********************************************************************
313 * acmDriverEnum (MSACM32.@)
315 MMRESULT WINAPI
acmDriverEnum(ACMDRIVERENUMCB fnCallback
, DWORD_PTR dwInstance
,
318 PWINE_ACMDRIVERID padid
;
321 TRACE("(%p, %08lx, %08x)\n", fnCallback
, dwInstance
, fdwEnum
);
324 WARN("invalid parameter\n");
325 return MMSYSERR_INVALPARAM
;
328 if (fdwEnum
& ~(ACM_DRIVERENUMF_NOLOCAL
|ACM_DRIVERENUMF_DISABLED
)) {
329 WARN("invalid flag\n");
330 return MMSYSERR_INVALFLAG
;
333 for (padid
= MSACM_pFirstACMDriverID
; padid
; padid
= padid
->pNextACMDriverID
) {
334 fdwSupport
= padid
->fdwSupport
;
336 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
337 if (fdwEnum
& ACM_DRIVERENUMF_DISABLED
)
338 fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
342 if (!(*fnCallback
)((HACMDRIVERID
)padid
, dwInstance
, fdwSupport
))
346 return MMSYSERR_NOERROR
;
349 /***********************************************************************
350 * acmDriverID (MSACM32.@)
352 MMRESULT WINAPI
acmDriverID(HACMOBJ hao
, PHACMDRIVERID phadid
, DWORD fdwDriverID
)
356 TRACE("(%p, %p, %08x)\n", hao
, phadid
, fdwDriverID
);
359 WARN("invalid flag\n");
360 return MMSYSERR_INVALFLAG
;
363 pao
= MSACM_GetObj(hao
, WINE_ACMOBJ_DONTCARE
);
365 WARN("invalid handle\n");
366 return MMSYSERR_INVALHANDLE
;
370 WARN("invalid parameter\n");
371 return MMSYSERR_INVALPARAM
;
374 *phadid
= (HACMDRIVERID
) pao
->pACMDriverID
;
376 return MMSYSERR_NOERROR
;
379 /***********************************************************************
380 * acmDriverMessage (MSACM32.@)
382 * Note: MSDN documentation (July 2001) is incomplete. This function
383 * accepts sending messages to an HACMDRIVERID in addition to the
384 * documented HACMDRIVER. In fact, for DRV_QUERYCONFIGURE and DRV_CONFIGURE,
385 * this might actually be the required mode of operation.
387 * Note: For DRV_CONFIGURE, msacm supplies its own DRVCONFIGINFO structure
388 * when the application fails to supply one. Some native drivers depend on
389 * this and refuse to display unless a valid DRVCONFIGINFO structure is
390 * built and supplied.
392 LRESULT WINAPI
acmDriverMessage(HACMDRIVER had
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
394 TRACE("(%p, %04x, %08lx, %08lx\n", had
, uMsg
, lParam1
, lParam2
);
396 if ((uMsg
>= ACMDM_USER
&& uMsg
< ACMDM_RESERVED_LOW
) ||
397 uMsg
== ACMDM_DRIVER_ABOUT
||
398 uMsg
== DRV_QUERYCONFIGURE
||
399 uMsg
== DRV_CONFIGURE
)
401 PWINE_ACMDRIVERID padid
;
403 LPDRVCONFIGINFO pConfigInfo
= NULL
;
404 LPWSTR section_name
= NULL
;
405 LPWSTR alias_name
= NULL
;
407 /* Check whether handle is an HACMDRIVERID */
408 padid
= MSACM_GetDriverID((HACMDRIVERID
)had
);
410 /* If the message is DRV_CONFIGURE, and the application provides no
411 DRVCONFIGINFO structure, msacm must supply its own.
413 if (uMsg
== DRV_CONFIGURE
&& lParam2
== 0) {
416 /* Get the alias from the HACMDRIVERID */
418 pAlias
= padid
->pszDriverAlias
;
419 if (pAlias
== NULL
) {
420 WARN("DRV_CONFIGURE: no alias for this driver, cannot self-supply alias\n");
423 FIXME("DRV_CONFIGURE: reverse lookup HACMDRIVER -> HACMDRIVERID not implemented\n");
427 if (pAlias
!= NULL
) {
428 /* DRVCONFIGINFO is only 12 bytes long, but native msacm
429 * reports a 16-byte structure to codecs, so allocate 16 bytes,
430 * just to be on the safe side.
432 const unsigned int iStructSize
= 16;
433 pConfigInfo
= HeapAlloc(MSACM_hHeap
, 0, iStructSize
);
435 ERR("OOM while supplying DRVCONFIGINFO for DRV_CONFIGURE, using NULL\n");
437 static const WCHAR drivers32
[] = {'D','r','i','v','e','r','s','3','2','\0'};
439 pConfigInfo
->dwDCISize
= iStructSize
;
441 section_name
= HeapAlloc(MSACM_hHeap
, 0, (strlenW(drivers32
) + 1) * sizeof(WCHAR
));
442 if (section_name
) strcpyW(section_name
, drivers32
);
443 pConfigInfo
->lpszDCISectionName
= section_name
;
444 alias_name
= HeapAlloc(MSACM_hHeap
, 0, (strlenW(pAlias
) + 1) * sizeof(WCHAR
));
445 if (alias_name
) strcpyW(alias_name
, pAlias
);
446 pConfigInfo
->lpszDCIAliasName
= alias_name
;
448 if (pConfigInfo
->lpszDCISectionName
== NULL
|| pConfigInfo
->lpszDCIAliasName
== NULL
) {
449 HeapFree(MSACM_hHeap
, 0, alias_name
);
450 HeapFree(MSACM_hHeap
, 0, section_name
);
451 HeapFree(MSACM_hHeap
, 0, pConfigInfo
);
453 ERR("OOM while supplying DRVCONFIGINFO for DRV_CONFIGURE, using NULL\n");
458 lParam2
= (LPARAM
)pConfigInfo
;
462 /* Handle is really an HACMDRIVERID, must have an open session to get an HACMDRIVER */
463 if (padid
->pACMDriverList
!= NULL
) {
464 lResult
= MSACM_Message((HACMDRIVER
)padid
->pACMDriverList
, uMsg
, lParam1
, lParam2
);
466 MMRESULT mmr
= acmDriverOpen(&had
, (HACMDRIVERID
)padid
, 0);
467 if (mmr
!= MMSYSERR_NOERROR
) {
468 lResult
= MMSYSERR_INVALPARAM
;
470 lResult
= acmDriverMessage(had
, uMsg
, lParam1
, lParam2
);
471 acmDriverClose(had
, 0);
475 lResult
= MSACM_Message(had
, uMsg
, lParam1
, lParam2
);
478 HeapFree(MSACM_hHeap
, 0, alias_name
);
479 HeapFree(MSACM_hHeap
, 0, section_name
);
480 HeapFree(MSACM_hHeap
, 0, pConfigInfo
);
484 WARN("invalid parameter\n");
485 return MMSYSERR_INVALPARAM
;
488 /***********************************************************************
489 * acmDriverOpen (MSACM32.@)
491 MMRESULT WINAPI
acmDriverOpen(PHACMDRIVER phad
, HACMDRIVERID hadid
, DWORD fdwOpen
)
493 PWINE_ACMDRIVERID padid
;
494 PWINE_ACMDRIVER pad
= NULL
;
497 TRACE("(%p, %p, %08u)\n", phad
, hadid
, fdwOpen
);
500 WARN("invalid parameter\n");
501 return MMSYSERR_INVALPARAM
;
505 WARN("invalid flag\n");
506 return MMSYSERR_INVALFLAG
;
509 padid
= MSACM_GetDriverID(hadid
);
511 WARN("invalid handle\n");
512 return MMSYSERR_INVALHANDLE
;
515 pad
= HeapAlloc(MSACM_hHeap
, 0, sizeof(WINE_ACMDRIVER
));
518 return MMSYSERR_NOMEM
;
521 pad
->obj
.dwType
= WINE_ACMOBJ_DRIVER
;
522 pad
->obj
.pACMDriverID
= padid
;
524 pad
->pLocalDrvrInst
= NULL
;
526 if (padid
->pLocalDriver
== NULL
)
528 ACMDRVOPENDESCW adod
;
532 /* this is not an externally added driver... need to actually load it */
533 if (!padid
->pszDriverAlias
)
535 ret
= MMSYSERR_ERROR
;
539 adod
.cbStruct
= sizeof(adod
);
540 adod
.fccType
= ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
;
541 adod
.fccComp
= ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
;
542 adod
.dwVersion
= acmGetVersion();
543 adod
.dwFlags
= fdwOpen
;
545 len
= strlen("Drivers32") + 1;
546 section_name
= HeapAlloc(MSACM_hHeap
, 0, len
* sizeof(WCHAR
));
547 MultiByteToWideChar(CP_ACP
, 0, "Drivers32", -1, section_name
, len
);
548 adod
.pszSectionName
= section_name
;
549 adod
.pszAliasName
= padid
->pszDriverAlias
;
552 pad
->hDrvr
= OpenDriver(padid
->pszDriverAlias
, NULL
, (DWORD_PTR
)&adod
);
554 HeapFree(MSACM_hHeap
, 0, section_name
);
563 ACMDRVOPENDESCW adod
;
567 adod
.cbStruct
= sizeof(adod
);
568 adod
.fccType
= ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
;
569 adod
.fccComp
= ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
;
570 adod
.dwVersion
= acmGetVersion();
571 adod
.dwFlags
= fdwOpen
;
573 adod
.pszSectionName
= NULL
;
574 adod
.pszAliasName
= NULL
;
577 pad
->pLocalDrvrInst
= MSACM_OpenLocalDriver(padid
->pLocalDriver
, (DWORD_PTR
)&adod
);
578 if (!pad
->pLocalDrvrInst
)
585 /* insert new pad at beg of list */
586 pad
->pNextACMDriver
= padid
->pACMDriverList
;
587 padid
->pACMDriverList
= pad
;
589 /* FIXME: Create a WINE_ACMDRIVER32 */
590 *phad
= (HACMDRIVER
)pad
;
591 TRACE("%s => %p\n", debugstr_w(padid
->pszDriverAlias
), pad
);
593 return MMSYSERR_NOERROR
;
595 WARN("failed: ret = %08x\n", ret
);
596 if (pad
&& !pad
->hDrvr
)
597 HeapFree(MSACM_hHeap
, 0, pad
);
601 /***********************************************************************
602 * acmDriverPriority (MSACM32.@)
604 MMRESULT WINAPI
acmDriverPriority(HACMDRIVERID hadid
, DWORD dwPriority
, DWORD fdwPriority
)
607 TRACE("(%p, %08x, %08x)\n", hadid
, dwPriority
, fdwPriority
);
609 /* Check for unknown flags */
611 ~(ACM_DRIVERPRIORITYF_ENABLE
|ACM_DRIVERPRIORITYF_DISABLE
|
612 ACM_DRIVERPRIORITYF_BEGIN
|ACM_DRIVERPRIORITYF_END
)) {
613 WARN("invalid flag\n");
614 return MMSYSERR_INVALFLAG
;
617 /* Check for incompatible flags */
618 if ((fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) &&
619 (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
)) {
620 WARN("invalid flag\n");
621 return MMSYSERR_INVALFLAG
;
624 /* Check for incompatible flags */
625 if ((fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) &&
626 (fdwPriority
& ACM_DRIVERPRIORITYF_END
)) {
627 WARN("invalid flag\n");
628 return MMSYSERR_INVALFLAG
;
631 /* According to MSDN, ACM_DRIVERPRIORITYF_BEGIN and ACM_DRIVERPRIORITYF_END
632 may only appear by themselves, and in addition, hadid and dwPriority must
634 if ((fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) ||
635 (fdwPriority
& ACM_DRIVERPRIORITYF_END
)) {
636 if (fdwPriority
& ~(ACM_DRIVERPRIORITYF_BEGIN
|ACM_DRIVERPRIORITYF_END
)) {
637 WARN("ACM_DRIVERPRIORITYF_[BEGIN|END] cannot be used with any other flags\n");
638 return MMSYSERR_INVALPARAM
;
641 WARN("priority invalid with ACM_DRIVERPRIORITYF_[BEGIN|END]\n");
642 return MMSYSERR_INVALPARAM
;
645 WARN("non-null hadid invalid with ACM_DRIVERPRIORITYF_[BEGIN|END]\n");
646 return MMSYSERR_INVALPARAM
;
648 /* FIXME: MSDN wording suggests that deferred notification should be
649 implemented as a system-wide lock held by a calling task, and that
650 re-enabling notifications should broadcast them across all processes.
651 This implementation uses a simple DWORD counter. One consequence of the
652 current implementation is that applications will never see
653 MMSYSERR_ALLOCATED as a return error.
655 if (fdwPriority
& ACM_DRIVERPRIORITYF_BEGIN
) {
656 MSACM_DisableNotifications();
657 } else if (fdwPriority
& ACM_DRIVERPRIORITYF_END
) {
658 MSACM_EnableNotifications();
660 return MMSYSERR_NOERROR
;
662 PWINE_ACMDRIVERID padid
;
663 PWINE_ACMNOTIFYWND panwnd
;
664 BOOL bPerformBroadcast
= FALSE
;
666 /* Fetch driver ID */
667 padid
= MSACM_GetDriverID(hadid
);
668 panwnd
= MSACM_GetNotifyWnd(hadid
);
669 if (!padid
&& !panwnd
) {
670 WARN("invalid handle\n");
671 return MMSYSERR_INVALHANDLE
;
675 /* Check whether driver ID is appropriate for requested op */
677 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_LOCAL
) {
678 return MMSYSERR_NOTSUPPORTED
;
680 if (dwPriority
!= 1 && dwPriority
!= (DWORD
)-1) {
681 FIXME("unexpected priority %d, using sign only\n", dwPriority
);
682 if ((signed)dwPriority
< 0) dwPriority
= (DWORD
)-1;
683 if (dwPriority
> 0) dwPriority
= 1;
686 if (dwPriority
== 1 && (padid
->pPrevACMDriverID
== NULL
||
687 (padid
->pPrevACMDriverID
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_LOCAL
))) {
688 /* do nothing - driver is first of list, or first after last
690 } else if (dwPriority
== (DWORD
)-1 && padid
->pNextACMDriverID
== NULL
) {
691 /* do nothing - driver is last of list */
693 MSACM_RePositionDriver(padid
, dwPriority
);
694 bPerformBroadcast
= TRUE
;
698 /* Check whether driver ID should be enabled or disabled */
699 if (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
) {
700 if (!(padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
)) {
701 padid
->fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
702 bPerformBroadcast
= TRUE
;
704 } else if (fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) {
705 if (padid
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
706 padid
->fdwSupport
&= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
707 bPerformBroadcast
= TRUE
;
714 return MMSYSERR_NOTSUPPORTED
;
717 /* Check whether notify window should be enabled or disabled */
718 if (fdwPriority
& ACM_DRIVERPRIORITYF_DISABLE
) {
719 if (!(panwnd
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
)) {
720 panwnd
->fdwSupport
|= ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
721 bPerformBroadcast
= TRUE
;
723 } else if (fdwPriority
& ACM_DRIVERPRIORITYF_ENABLE
) {
724 if (panwnd
->fdwSupport
& ACMDRIVERDETAILS_SUPPORTF_DISABLED
) {
725 panwnd
->fdwSupport
&= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED
;
726 bPerformBroadcast
= TRUE
;
731 /* Perform broadcast of changes */
732 if (bPerformBroadcast
) {
733 MSACM_WriteCurrentPriorities();
734 MSACM_BroadcastNotification();
736 return MMSYSERR_NOERROR
;
740 /***********************************************************************
741 * acmDriverRemove (MSACM32.@)
743 MMRESULT WINAPI
acmDriverRemove(HACMDRIVERID hadid
, DWORD fdwRemove
)
745 PWINE_ACMDRIVERID padid
;
746 PWINE_ACMNOTIFYWND panwnd
;
748 TRACE("(%p, %08x)\n", hadid
, fdwRemove
);
750 padid
= MSACM_GetDriverID(hadid
);
751 panwnd
= MSACM_GetNotifyWnd(hadid
);
752 if (!padid
&& !panwnd
) {
753 WARN("invalid handle\n");
754 return MMSYSERR_INVALHANDLE
;
758 WARN("invalid flag\n");
759 return MMSYSERR_INVALFLAG
;
762 if (padid
) MSACM_UnregisterDriver(padid
);
763 if (panwnd
) MSACM_UnRegisterNotificationWindow(panwnd
);
764 MSACM_BroadcastNotification();
766 return MMSYSERR_NOERROR
;