ReactOS 0.4.16-dev-91-g764881a
driver.c
Go to the documentation of this file.
1/* -*- tab-width: 8; c-basic-offset: 4 -*- */
2
3/*
4 * MSACM32 library
5 *
6 * Copyright 1998 Patrik Stridvall
7 * 1999 Eric Pouech
8 *
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.
13 *
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.
18 *
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
22 */
23
24
25#include <stdarg.h>
26#include <stdio.h>
27
28#include "windef.h"
29#include "winbase.h"
30#include "wingdi.h"
31#include "winuser.h"
32#include "winnls.h"
33#include "mmsystem.h"
34#include "mmreg.h"
35#include "msacm.h"
36#include "msacmdrv.h"
37#include "wineacm.h"
38#include "wine/debug.h"
39
41
42/***********************************************************************
43 * acmDriverAddA (MSACM32.@)
44 */
46 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
47{
48 MMRESULT resultW;
49 WCHAR * driverW = NULL;
50 LPARAM lParamW = lParam;
51
52 TRACE("(%p, %p, %08lx, %08x, %08x)\n",
53 phadid, hinstModule, lParam, dwPriority, fdwAdd);
54
55 if (!phadid) {
56 WARN("invalid parameter\n");
58 }
59
60 /* Check if any unknown flags */
61 if (fdwAdd &
64 WARN("invalid flag\n");
65 return MMSYSERR_INVALFLAG;
66 }
67
68 /* Check if any incompatible flags */
69 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
70 (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND)) {
71 WARN("invalid flag\n");
72 return MMSYSERR_INVALFLAG;
73 }
74
75 /* A->W translation of name */
77 INT len;
78
79 if (lParam == 0) return MMSYSERR_INVALPARAM;
81 driverW = HeapAlloc(MSACM_hHeap, 0, len * sizeof(WCHAR));
82 if (!driverW) return MMSYSERR_NOMEM;
84 lParamW = (LPARAM)driverW;
85 }
86
87 resultW = acmDriverAddW(phadid, hinstModule, lParamW, dwPriority, fdwAdd);
89 return resultW;
90}
91
92/***********************************************************************
93 * acmDriverAddW (MSACM32.@)
94 *
95 */
97 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
98{
99 PWINE_ACMLOCALDRIVER pLocalDrv = NULL;
100
101 TRACE("(%p, %p, %08lx, %08x, %08x)\n",
102 phadid, hinstModule, lParam, dwPriority, fdwAdd);
103
104 if (!phadid) {
105 WARN("invalid parameter\n");
106 return MMSYSERR_INVALPARAM;
107 }
108
109 /* Check if any unknown flags */
110 if (fdwAdd &
113 WARN("invalid flag\n");
114 return MMSYSERR_INVALFLAG;
115 }
116
117 /* Check if any incompatible flags */
118 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
119 (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND)) {
120 WARN("invalid flag\n");
121 return MMSYSERR_INVALFLAG;
122 }
123
124 switch (fdwAdd & ACM_DRIVERADDF_TYPEMASK) {
126 /*
127 hInstModule (unused)
128 lParam name of value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
129 dwPriority (unused, set to 0)
130 */
131 *phadid = (HACMDRIVERID) MSACM_RegisterDriverFromRegistry((LPCWSTR)lParam);
132 if (!*phadid) {
133 ERR("Unable to register driver via ACM_DRIVERADDF_NAME\n");
134 return MMSYSERR_INVALPARAM;
135 }
136 break;
138 /*
139 hInstModule Handle of module which contains driver entry proc
140 lParam Driver function address
141 dwPriority (unused, set to 0)
142 */
143 fdwAdd &= ~ACM_DRIVERADDF_TYPEMASK;
144 /* FIXME: fdwAdd ignored */
145 /* Application-supplied acmDriverProc's are placed at the top of the priority unless
146 fdwAdd indicates ACM_DRIVERADDF_GLOBAL
147 */
148 pLocalDrv = MSACM_RegisterLocalDriver(hinstModule, (DRIVERPROC)lParam);
149 *phadid = pLocalDrv ? (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, pLocalDrv) : NULL;
150 if (!*phadid) {
151 ERR("Unable to register driver via ACM_DRIVERADDF_FUNCTION\n");
152 return MMSYSERR_INVALPARAM;
153 }
154 break;
156 /*
157 hInstModule (unused)
158 lParam Handle of notification window
159 dwPriority Window message to send for notification broadcasts
160 */
161 *phadid = (HACMDRIVERID) MSACM_RegisterNotificationWindow((HWND)lParam, dwPriority);
162 if (!*phadid) {
163 ERR("Unable to register driver via ACM_DRIVERADDF_NOTIFYHWND\n");
164 return MMSYSERR_INVALPARAM;
165 }
166 break;
167 default:
168 ERR("invalid flag value 0x%08x for fdwAdd\n", fdwAdd);
169 return MMSYSERR_INVALFLAG;
170 }
171
173 return MMSYSERR_NOERROR;
174}
175
176/***********************************************************************
177 * acmDriverClose (MSACM32.@)
178 */
179MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
180{
181 PWINE_ACMDRIVER pad;
182 PWINE_ACMDRIVERID padid;
183 PWINE_ACMDRIVER* tpad;
184
185 TRACE("(%p, %08x)\n", had, fdwClose);
186
187 if (fdwClose) {
188 WARN("invalid flag\n");
189 return MMSYSERR_INVALFLAG;
190 }
191
192 pad = MSACM_GetDriver(had);
193 if (!pad) {
194 WARN("invalid handle\n");
196 }
197
198 padid = pad->obj.pACMDriverID;
199
200 /* remove driver from list */
201 for (tpad = &(padid->pACMDriverList); *tpad; tpad = &((*tpad)->pNextACMDriver)) {
202 if (*tpad == pad) {
203 *tpad = (*tpad)->pNextACMDriver;
204 break;
205 }
206 }
207
208 /* close driver if it has been opened */
209 if (pad->hDrvr && !pad->pLocalDrvrInst)
210 CloseDriver(pad->hDrvr, 0, 0);
211 else if (pad->pLocalDrvrInst)
213
214 pad->obj.dwType = 0;
215 HeapFree(MSACM_hHeap, 0, pad);
216
217 return MMSYSERR_NOERROR;
218}
219
220/***********************************************************************
221 * acmDriverDetailsA (MSACM32.@)
222 */
223MMRESULT WINAPI acmDriverDetailsA(HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, DWORD fdwDetails)
224{
225 MMRESULT mmr;
227
228 TRACE("(%p, %p, %08x)\n", hadid, padd, fdwDetails);
229
230 if (!padd) {
231 WARN("invalid parameter\n");
232 return MMSYSERR_INVALPARAM;
233 }
234
235 if (padd->cbStruct < 4) {
236 WARN("invalid parameter\n");
237 return MMSYSERR_INVALPARAM;
238 }
239
240 addw.cbStruct = sizeof(addw);
241 mmr = acmDriverDetailsW(hadid, &addw, fdwDetails);
242 if (mmr == 0) {
243 ACMDRIVERDETAILSA padda;
244
245 padda.fccType = addw.fccType;
246 padda.fccComp = addw.fccComp;
247 padda.wMid = addw.wMid;
248 padda.wPid = addw.wPid;
249 padda.vdwACM = addw.vdwACM;
250 padda.vdwDriver = addw.vdwDriver;
251 padda.fdwSupport = addw.fdwSupport;
252 padda.cFormatTags = addw.cFormatTags;
253 padda.cFilterTags = addw.cFilterTags;
254 padda.hicon = addw.hicon;
256 sizeof(padda.szShortName), NULL, NULL );
257 WideCharToMultiByte( CP_ACP, 0, addw.szLongName, -1, padda.szLongName,
258 sizeof(padda.szLongName), NULL, NULL );
260 sizeof(padda.szCopyright), NULL, NULL );
262 sizeof(padda.szLicensing), NULL, NULL );
263 WideCharToMultiByte( CP_ACP, 0, addw.szFeatures, -1, padda.szFeatures,
264 sizeof(padda.szFeatures), NULL, NULL );
265 padda.cbStruct = min(padd->cbStruct, sizeof(*padd));
266 memcpy(padd, &padda, padda.cbStruct);
267 }
268 return mmr;
269}
270
271/***********************************************************************
272 * acmDriverDetailsW (MSACM32.@)
273 */
274MMRESULT WINAPI acmDriverDetailsW(HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, DWORD fdwDetails)
275{
276 HACMDRIVER acmDrvr;
277 MMRESULT mmr;
278
279 TRACE("(%p, %p, %08x)\n", hadid, padd, fdwDetails);
280
281 if (!padd) {
282 WARN("invalid parameter\n");
283 return MMSYSERR_INVALPARAM;
284 }
285
286 if (padd->cbStruct < 4) {
287 WARN("invalid parameter\n");
288 return MMSYSERR_INVALPARAM;
289 }
290
291 if (fdwDetails) {
292 WARN("invalid flag\n");
293 return MMSYSERR_INVALFLAG;
294 }
295
296 mmr = acmDriverOpen(&acmDrvr, hadid, 0);
297 if (mmr == MMSYSERR_NOERROR) {
298 ACMDRIVERDETAILSW paddw;
299 paddw.cbStruct = sizeof(paddw);
300 mmr = MSACM_Message(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM)&paddw, 0);
301
302 acmDriverClose(acmDrvr, 0);
303 paddw.cbStruct = min(padd->cbStruct, sizeof(*padd));
304 memcpy(padd, &paddw, paddw.cbStruct);
305 }
306 else if (mmr == MMSYSERR_NODRIVER)
308
309 return mmr;
310}
311
312/***********************************************************************
313 * acmDriverEnum (MSACM32.@)
314 */
316 DWORD fdwEnum)
317{
318 PWINE_ACMDRIVERID padid;
319 DWORD fdwSupport;
320
321 TRACE("(%p, %08lx, %08x)\n", fnCallback, dwInstance, fdwEnum);
322
323 if (!fnCallback) {
324 WARN("invalid parameter\n");
325 return MMSYSERR_INVALPARAM;
326 }
327
329 WARN("invalid flag\n");
330 return MMSYSERR_INVALFLAG;
331 }
332
333 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
334 fdwSupport = padid->fdwSupport;
335
337 if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
339 else
340 continue;
341 }
342 if (!(*fnCallback)((HACMDRIVERID)padid, dwInstance, fdwSupport))
343 break;
344 }
345
346 return MMSYSERR_NOERROR;
347}
348
349/***********************************************************************
350 * acmDriverID (MSACM32.@)
351 */
352MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
353{
354 PWINE_ACMOBJ pao;
355
356 TRACE("(%p, %p, %08x)\n", hao, phadid, fdwDriverID);
357
358 if (fdwDriverID) {
359 WARN("invalid flag\n");
360 return MMSYSERR_INVALFLAG;
361 }
362
364 if (!pao) {
365 WARN("invalid handle\n");
367 }
368
369 if (!phadid) {
370 WARN("invalid parameter\n");
371 return MMSYSERR_INVALPARAM;
372 }
373
374 *phadid = (HACMDRIVERID) pao->pACMDriverID;
375
376 return MMSYSERR_NOERROR;
377}
378
379/***********************************************************************
380 * acmDriverMessage (MSACM32.@)
381 *
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.
386 *
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.
391 */
392LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
393{
394 TRACE("(%p, %04x, %08lx, %08lx\n", had, uMsg, lParam1, lParam2);
395
396 if ((uMsg >= ACMDM_USER && uMsg < ACMDM_RESERVED_LOW) ||
397 uMsg == ACMDM_DRIVER_ABOUT ||
398 uMsg == DRV_QUERYCONFIGURE ||
399 uMsg == DRV_CONFIGURE)
400 {
401 PWINE_ACMDRIVERID padid;
402 LRESULT lResult;
403 LPDRVCONFIGINFO pConfigInfo = NULL;
404 LPWSTR section_name = NULL;
405 LPWSTR alias_name = NULL;
406
407 /* Check whether handle is an HACMDRIVERID */
408 padid = MSACM_GetDriverID((HACMDRIVERID)had);
409
410 /* If the message is DRV_CONFIGURE, and the application provides no
411 DRVCONFIGINFO structure, msacm must supply its own.
412 */
413 if (uMsg == DRV_CONFIGURE && lParam2 == 0) {
414 LPWSTR pAlias;
415
416 /* Get the alias from the HACMDRIVERID */
417 if (padid) {
418 pAlias = padid->pszDriverAlias;
419 if (pAlias == NULL) {
420 WARN("DRV_CONFIGURE: no alias for this driver, cannot self-supply alias\n");
421 }
422 } else {
423 FIXME("DRV_CONFIGURE: reverse lookup HACMDRIVER -> HACMDRIVERID not implemented\n");
424 pAlias = NULL;
425 }
426
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.
431 */
432 const unsigned int iStructSize = 16;
433 pConfigInfo = HeapAlloc(MSACM_hHeap, 0, iStructSize);
434 if (!pConfigInfo) {
435 ERR("OOM while supplying DRVCONFIGINFO for DRV_CONFIGURE, using NULL\n");
436 } else {
437 static const WCHAR drivers32[] = {'D','r','i','v','e','r','s','3','2','\0'};
438
439 pConfigInfo->dwDCISize = iStructSize;
440
441 section_name = HeapAlloc(MSACM_hHeap, 0, (lstrlenW(drivers32) + 1) * sizeof(WCHAR));
442 if (section_name) lstrcpyW(section_name, drivers32);
443 pConfigInfo->lpszDCISectionName = section_name;
444 alias_name = HeapAlloc(MSACM_hHeap, 0, (lstrlenW(pAlias) + 1) * sizeof(WCHAR));
445 if (alias_name) lstrcpyW(alias_name, pAlias);
446 pConfigInfo->lpszDCIAliasName = alias_name;
447
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);
452 pConfigInfo = NULL;
453 ERR("OOM while supplying DRVCONFIGINFO for DRV_CONFIGURE, using NULL\n");
454 }
455 }
456 }
457
458 lParam2 = (LPARAM)pConfigInfo;
459 }
460
461 if (padid) {
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);
465 } else {
466 MMRESULT mmr = acmDriverOpen(&had, (HACMDRIVERID)padid, 0);
467 if (mmr != MMSYSERR_NOERROR) {
468 lResult = MMSYSERR_INVALPARAM;
469 } else {
470 lResult = acmDriverMessage(had, uMsg, lParam1, lParam2);
471 acmDriverClose(had, 0);
472 }
473 }
474 } else {
475 lResult = MSACM_Message(had, uMsg, lParam1, lParam2);
476 }
477 if (pConfigInfo) {
478 HeapFree(MSACM_hHeap, 0, alias_name);
479 HeapFree(MSACM_hHeap, 0, section_name);
480 HeapFree(MSACM_hHeap, 0, pConfigInfo);
481 }
482 return lResult;
483 }
484 WARN("invalid parameter\n");
485 return MMSYSERR_INVALPARAM;
486}
487
488/***********************************************************************
489 * acmDriverOpen (MSACM32.@)
490 */
491MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
492{
493 PWINE_ACMDRIVERID padid;
494 PWINE_ACMDRIVER pad = NULL;
496
497 TRACE("(%p, %p, %08u)\n", phad, hadid, fdwOpen);
498
499 if (!phad) {
500 WARN("invalid parameter\n");
501 return MMSYSERR_INVALPARAM;
502 }
503
504 if (fdwOpen) {
505 WARN("invalid flag\n");
506 return MMSYSERR_INVALFLAG;
507 }
508
509 padid = MSACM_GetDriverID(hadid);
510 if (!padid) {
511 WARN("invalid handle\n");
513 }
514
515 pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
516 if (!pad) {
517 WARN("no memory\n");
518 return MMSYSERR_NOMEM;
519 }
520
522 pad->obj.pACMDriverID = padid;
523 pad->hDrvr = 0;
524 pad->pLocalDrvrInst = NULL;
525
526 if (padid->pLocalDriver == NULL)
527 {
528 ACMDRVOPENDESCW adod;
529 int len;
530 LPWSTR section_name;
531
532 /* this is not an externally added driver... need to actually load it */
533 if (!padid->pszDriverAlias)
534 {
536 goto gotError;
537 }
538
539 adod.cbStruct = sizeof(adod);
542 adod.dwVersion = acmGetVersion();
543 adod.dwFlags = fdwOpen;
544 adod.dwError = 0;
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;
550 adod.dnDevNode = 0;
551
552 pad->hDrvr = OpenDriver(padid->pszDriverAlias, NULL, (DWORD_PTR)&adod);
553
554 HeapFree(MSACM_hHeap, 0, section_name);
555 if (!pad->hDrvr)
556 {
557 ret = adod.dwError;
558 if (ret == MMSYSERR_NOERROR)
560 goto gotError;
561 }
562 }
563 else
564 {
565 ACMDRVOPENDESCW adod;
566
567 pad->hDrvr = NULL;
568
569 adod.cbStruct = sizeof(adod);
572 adod.dwVersion = acmGetVersion();
573 adod.dwFlags = fdwOpen;
574 adod.dwError = 0;
575 adod.pszSectionName = NULL;
576 adod.pszAliasName = NULL;
577 adod.dnDevNode = 0;
578
580 if (!pad->pLocalDrvrInst)
581 {
582 ret = adod.dwError;
583 if (ret == MMSYSERR_NOERROR)
585 goto gotError;
586 }
587 }
588
589 /* insert new pad at beg of list */
590 pad->pNextACMDriver = padid->pACMDriverList;
591 padid->pACMDriverList = pad;
592
593 /* FIXME: Create a WINE_ACMDRIVER32 */
594 *phad = (HACMDRIVER)pad;
595 TRACE("%s => %p\n", debugstr_w(padid->pszDriverAlias), pad);
596
597 return MMSYSERR_NOERROR;
598 gotError:
599 WARN("failed: ret = %08x\n", ret);
600 HeapFree(MSACM_hHeap, 0, pad);
601 return ret;
602}
603
604/***********************************************************************
605 * acmDriverPriority (MSACM32.@)
606 */
607MMRESULT WINAPI acmDriverPriority(HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority)
608{
609
610 TRACE("(%p, %08x, %08x)\n", hadid, dwPriority, fdwPriority);
611
612 /* Check for unknown flags */
613 if (fdwPriority &
616 WARN("invalid flag\n");
617 return MMSYSERR_INVALFLAG;
618 }
619
620 /* Check for incompatible flags */
621 if ((fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) &&
622 (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE)) {
623 WARN("invalid flag\n");
624 return MMSYSERR_INVALFLAG;
625 }
626
627 /* Check for incompatible flags */
628 if ((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) &&
629 (fdwPriority & ACM_DRIVERPRIORITYF_END)) {
630 WARN("invalid flag\n");
631 return MMSYSERR_INVALFLAG;
632 }
633
634 /* According to MSDN, ACM_DRIVERPRIORITYF_BEGIN and ACM_DRIVERPRIORITYF_END
635 may only appear by themselves, and in addition, hadid and dwPriority must
636 both be zero */
637 if ((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) ||
638 (fdwPriority & ACM_DRIVERPRIORITYF_END)) {
640 WARN("ACM_DRIVERPRIORITYF_[BEGIN|END] cannot be used with any other flags\n");
641 return MMSYSERR_INVALPARAM;
642 }
643 if (dwPriority) {
644 WARN("priority invalid with ACM_DRIVERPRIORITYF_[BEGIN|END]\n");
645 return MMSYSERR_INVALPARAM;
646 }
647 if (hadid) {
648 WARN("non-null hadid invalid with ACM_DRIVERPRIORITYF_[BEGIN|END]\n");
649 return MMSYSERR_INVALPARAM;
650 }
651 /* FIXME: MSDN wording suggests that deferred notification should be
652 implemented as a system-wide lock held by a calling task, and that
653 re-enabling notifications should broadcast them across all processes.
654 This implementation uses a simple DWORD counter. One consequence of the
655 current implementation is that applications will never see
656 MMSYSERR_ALLOCATED as a return error.
657 */
658 if (fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) {
660 } else if (fdwPriority & ACM_DRIVERPRIORITYF_END) {
662 }
663 return MMSYSERR_NOERROR;
664 } else {
665 PWINE_ACMDRIVERID padid;
666 PWINE_ACMNOTIFYWND panwnd;
667 BOOL bPerformBroadcast = FALSE;
668
669 /* Fetch driver ID */
670 padid = MSACM_GetDriverID(hadid);
671 panwnd = MSACM_GetNotifyWnd(hadid);
672 if (!padid && !panwnd) {
673 WARN("invalid handle\n");
675 }
676
677 if (padid) {
678 /* Check whether driver ID is appropriate for requested op */
679 if (dwPriority) {
682 }
683 if (dwPriority != 1 && dwPriority != (DWORD)-1) {
684 FIXME("unexpected priority %d, using sign only\n", dwPriority);
685 if ((signed)dwPriority < 0) dwPriority = (DWORD)-1;
686 if (dwPriority > 0) dwPriority = 1;
687 }
688
689 if (dwPriority == 1 && (padid->pPrevACMDriverID == NULL ||
691 /* do nothing - driver is first of list, or first after last
692 local driver */
693 } else if (dwPriority == (DWORD)-1 && padid->pNextACMDriverID == NULL) {
694 /* do nothing - driver is last of list */
695 } else {
696 MSACM_RePositionDriver(padid, dwPriority);
697 bPerformBroadcast = TRUE;
698 }
699 }
700
701 /* Check whether driver ID should be enabled or disabled */
702 if (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE) {
705 bPerformBroadcast = TRUE;
706 }
707 } else if (fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) {
709 padid->fdwSupport &= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED;
710 bPerformBroadcast = TRUE;
711 }
712 }
713 }
714
715 if (panwnd) {
716 if (dwPriority) {
718 }
719
720 /* Check whether notify window should be enabled or disabled */
721 if (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE) {
724 bPerformBroadcast = TRUE;
725 }
726 } else if (fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) {
728 panwnd->fdwSupport &= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED;
729 bPerformBroadcast = TRUE;
730 }
731 }
732 }
733
734 /* Perform broadcast of changes */
735 if (bPerformBroadcast) {
738 }
739 return MMSYSERR_NOERROR;
740 }
741}
742
743/***********************************************************************
744 * acmDriverRemove (MSACM32.@)
745 */
746MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
747{
748 PWINE_ACMDRIVERID padid;
749 PWINE_ACMNOTIFYWND panwnd;
750
751 TRACE("(%p, %08x)\n", hadid, fdwRemove);
752
753 padid = MSACM_GetDriverID(hadid);
754 panwnd = MSACM_GetNotifyWnd(hadid);
755 if (!padid && !panwnd) {
756 WARN("invalid handle\n");
758 }
759
760 if (fdwRemove) {
761 WARN("invalid flag\n");
762 return MMSYSERR_INVALFLAG;
763 }
764
765 if (padid) MSACM_UnregisterDriver(padid);
766 if (panwnd) MSACM_UnRegisterNotificationWindow(panwnd);
768
769 return MMSYSERR_NOERROR;
770}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
Definition: driver.c:491
MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
Definition: driver.c:179
MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
Definition: driver.c:746
MMRESULT WINAPI acmDriverPriority(HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority)
Definition: driver.c:607
MMRESULT WINAPI acmDriverDetailsW(HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, DWORD fdwDetails)
Definition: driver.c:274
MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
Definition: driver.c:352
MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum)
Definition: driver.c:315
MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule, LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
Definition: driver.c:96
MMRESULT WINAPI acmDriverDetailsA(HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, DWORD fdwDetails)
Definition: driver.c:223
MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule, LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
Definition: driver.c:45
LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:392
PWINE_ACMNOTIFYWND MSACM_RegisterNotificationWindow(HWND hNotifyWnd, DWORD dwNotifyMsg)
Definition: internal.c:416
PWINE_ACMNOTIFYWND MSACM_UnRegisterNotificationWindow(const WINE_ACMNOTIFYWND *panwnd)
Definition: internal.c:481
void MSACM_WriteCurrentPriorities(void)
Definition: internal.c:668
PWINE_ACMNOTIFYWND MSACM_GetNotifyWnd(HACMDRIVERID hDriver)
Definition: internal.c:852
PWINE_ACMDRIVERID MSACM_RegisterDriverFromRegistry(LPCWSTR pszRegEntry)
Definition: internal.c:61
HANDLE MSACM_hHeap
Definition: internal.c:47
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
void MSACM_EnableNotifications(void)
Definition: internal.c:467
void MSACM_BroadcastNotification(void)
Definition: internal.c:443
void MSACM_RePositionDriver(PWINE_ACMDRIVERID padid, DWORD dwPriority)
Definition: internal.c:504
PWINE_ACMLOCALDRIVERINST MSACM_OpenLocalDriver(PWINE_ACMLOCALDRIVER paldrv, LPARAM lParam2)
Definition: internal.c:1026
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
Definition: internal.c:773
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
Definition: internal.c:844
PWINE_ACMDRIVERID MSACM_pFirstACMDriverID
Definition: internal.c:48
void MSACM_DisableNotifications(void)
Definition: internal.c:459
PWINE_ACMDRIVERID MSACM_RegisterDriver(LPCWSTR pszDriverAlias, LPCWSTR pszFileName, PWINE_ACMLOCALDRIVER pLocalDriver)
Definition: internal.c:285
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj, DWORD type)
Definition: internal.c:823
PWINE_ACMLOCALDRIVER MSACM_RegisterLocalDriver(HMODULE hModule, DRIVERPROC lpDriverProc)
Definition: internal.c:883
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
Definition: internal.c:836
LRESULT MSACM_CloseLocalDriver(PWINE_ACMLOCALDRIVERINST paldrv)
Definition: internal.c:1081
HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam)
Definition: driver.c:400
LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:462
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
UINT MMRESULT
Definition: mmsystem.h:962
#define DRV_QUERYCONFIGURE
Definition: mmsystem.h:126
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
#define MMSYSERR_NODRIVER
Definition: mmsystem.h:102
LRESULT(CALLBACK * DRIVERPROC)(DWORD_PTR, HDRVR, UINT, LPARAM, LPARAM)
Definition: mmsystem.h:1001
#define DRV_CONFIGURE
Definition: mmsystem.h:125
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MMSYSERR_INVALFLAG
Definition: mmsystem.h:106
#define min(a, b)
Definition: monoChain.cc:55
DWORD WINAPI acmGetVersion(void)
Definition: msacm32_main.c:76
#define ACM_DRIVERADDF_FUNCTION
Definition: msacm.h:46
HACMDRIVERID * PHACMDRIVERID
Definition: msacm.h:235
#define ACMDM_DRIVER_ABOUT
Definition: msacm.h:227
#define ACM_DRIVERENUMF_DISABLED
Definition: msacm.h:70
#define ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
Definition: msacm.h:59
HACMDRIVER * PHACMDRIVER
Definition: msacm.h:236
#define ACM_DRIVERADDF_GLOBAL
Definition: msacm.h:50
#define ACM_DRIVERADDF_NOTIFYHWND
Definition: msacm.h:47
#define ACM_DRIVERENUMF_NOLOCAL
Definition: msacm.h:69
BOOL(CALLBACK * ACMDRIVERENUMCB)(HACMDRIVERID hadid, DWORD_PTR dwInstance, DWORD fdwSupport)
Definition: msacm.h:244
#define ACM_DRIVERPRIORITYF_END
Definition: msacm.h:76
#define ACM_DRIVERADDF_TYPEMASK
Definition: msacm.h:48
#define ACMDM_RESERVED_LOW
Definition: msacm.h:222
#define ACM_DRIVERPRIORITYF_DISABLE
Definition: msacm.h:73
#define ACMDRIVERDETAILS_SUPPORTF_DISABLED
Definition: msacm.h:67
#define ACMDM_USER
Definition: msacm.h:221
#define ACM_DRIVERPRIORITYF_ENABLE
Definition: msacm.h:72
#define ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
Definition: msacm.h:58
#define ACMDRIVERDETAILS_SUPPORTF_LOCAL
Definition: msacm.h:66
#define ACM_DRIVERPRIORITYF_BEGIN
Definition: msacm.h:75
#define ACM_DRIVERADDF_NAME
Definition: msacm.h:45
#define ACMDM_DRIVER_DETAILS
Definition: msacmdrv.h:46
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
static const WCHAR driverW[]
#define TRACE(s)
Definition: solgame.cpp:4
FOURCC fccType
Definition: msacm.h:274
CHAR szFeatures[ACMDRIVERDETAILS_FEATURES_CHARS]
Definition: msacm.h:293
DWORD cbStruct
Definition: msacm.h:272
CHAR szCopyright[ACMDRIVERDETAILS_COPYRIGHT_CHARS]
Definition: msacm.h:291
DWORD vdwDriver
Definition: msacm.h:281
CHAR szLicensing[ACMDRIVERDETAILS_LICENSING_CHARS]
Definition: msacm.h:292
CHAR szShortName[ACMDRIVERDETAILS_SHORTNAME_CHARS]
Definition: msacm.h:289
DWORD cFilterTags
Definition: msacm.h:285
FOURCC fccComp
Definition: msacm.h:275
DWORD fdwSupport
Definition: msacm.h:283
CHAR szLongName[ACMDRIVERDETAILS_LONGNAME_CHARS]
Definition: msacm.h:290
DWORD cFormatTags
Definition: msacm.h:284
DWORD cFilterTags
Definition: msacm.h:311
DWORD cbStruct
Definition: msacm.h:298
WCHAR szCopyright[ACMDRIVERDETAILS_COPYRIGHT_CHARS]
Definition: msacm.h:317
WCHAR szLongName[ACMDRIVERDETAILS_LONGNAME_CHARS]
Definition: msacm.h:316
WCHAR szShortName[ACMDRIVERDETAILS_SHORTNAME_CHARS]
Definition: msacm.h:315
FOURCC fccComp
Definition: msacm.h:301
WCHAR szLicensing[ACMDRIVERDETAILS_LICENSING_CHARS]
Definition: msacm.h:318
FOURCC fccType
Definition: msacm.h:300
WCHAR szFeatures[ACMDRIVERDETAILS_FEATURES_CHARS]
Definition: msacm.h:319
DWORD cFormatTags
Definition: msacm.h:310
DWORD fdwSupport
Definition: msacm.h:309
DWORD vdwDriver
Definition: msacm.h:307
FOURCC fccType
Definition: msacmdrv.h:87
LPCWSTR pszAliasName
Definition: msacmdrv.h:93
LPCWSTR pszSectionName
Definition: msacmdrv.h:92
FOURCC fccComp
Definition: msacmdrv.h:88
DWORD dwVersion
Definition: msacmdrv.h:89
DWORD cbStruct
Definition: msacmdrv.h:86
DWORD dnDevNode
Definition: msacmdrv.h:94
PWINE_ACMLOCALDRIVER pLocalDriver
Definition: wineacm.h:91
LPWSTR pszDriverAlias
Definition: wineacm.h:89
PWINE_ACMDRIVER pACMDriverList
Definition: wineacm.h:92
DWORD fdwSupport
Definition: wineacm.h:98
PWINE_ACMDRIVERID pNextACMDriverID
Definition: wineacm.h:93
PWINE_ACMDRIVERID pPrevACMDriverID
Definition: wineacm.h:94
PWINE_ACMLOCALDRIVERINST pLocalDrvrInst
Definition: wineacm.h:73
HDRVR hDrvr
Definition: wineacm.h:72
WINE_ACMOBJ obj
Definition: wineacm.h:71
PWINE_ACMDRIVER pNextACMDriver
Definition: wineacm.h:75
PWINE_ACMDRIVERID pACMDriverID
Definition: wineacm.h:45
DWORD dwType
Definition: wineacm.h:44
LPCWSTR lpszDCIAliasName
Definition: mmsystem.h:991
LPCWSTR lpszDCISectionName
Definition: mmsystem.h:990
uint32_t DWORD_PTR
Definition: typedefs.h:65
int32_t INT
Definition: typedefs.h:58
int ret
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
#define WINAPI
Definition: msvc.h:6
#define WINE_ACMOBJ_DONTCARE
Definition: wineacm.h:35
#define WINE_ACMOBJ_DRIVER
Definition: wineacm.h:37
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185