1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * MMSYSTEM low level drivers handling functions
6 * Copyright 1999 Eric Pouech
7 * Modified for use with ReactOS by Andrew Greenwood, 2007
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"
35 #include "wine/debug.h"
36 #include "wine/exception.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(winmm
);
40 /* each known type of driver has an instance of this structure */
41 typedef struct tagWINE_LLTYPE
{
42 /* those attributes depend on the specification of the type */
43 LPCSTR typestr
; /* name (for debugging) */
44 BOOL bSupportMapper
; /* if type is allowed to support mapper */
45 /* those attributes reflect the loaded/current situation for the type */
46 UINT wMaxId
; /* number of loaded devices (sum across all loaded drivers) */
47 LPWINE_MLD lpMlds
; /* "static" mlds to access the part though device IDs */
48 int nMapper
; /* index to mapper */
51 static int MMDrvsHi
/* = 0 */;
52 static WINE_MM_DRIVER MMDrvs
[8];
53 static LPWINE_MLD MM_MLDrvs
[40];
54 #define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]))
56 #define A(_x,_y) {#_y, _x, 0, NULL, -1}
57 /* Note: the indices of this array must match the definitions
58 * of the MMDRV_???? manifest constants
60 static WINE_LLTYPE llTypes
[MMDRV_MAX
] = {
70 /**************************************************************************
71 * MMDRV_GetNum [internal]
73 UINT
MMDRV_GetNum(UINT type
)
75 TRACE("(%04x)\n", type
);
76 assert(type
< MMDRV_MAX
);
77 return llTypes
[type
].wMaxId
;
80 /**************************************************************************
81 * MMDRV_Message [internal]
83 DWORD
MMDRV_Message(LPWINE_MLD mld
, UINT wMsg
, DWORD_PTR dwParam1
,
86 LPWINE_MM_DRIVER lpDrv
;
88 WINE_MM_DRIVER_PART
* part
;
89 WINE_LLTYPE
* llType
= &llTypes
[mld
->type
];
92 TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx)\n",
93 llTypes
[mld
->type
].typestr
, mld
->uDeviceID
, wMsg
,
94 mld
->dwDriverInstance
, dwParam1
, dwParam2
);
96 if (mld
->uDeviceID
== (UINT16
)-1) {
97 if (!llType
->bSupportMapper
) {
98 WARN("uDev=-1 requested on non-mappable ll type %s\n",
99 llTypes
[mld
->type
].typestr
);
100 return MMSYSERR_BADDEVICEID
;
104 if (mld
->uDeviceID
>= llType
->wMaxId
) {
105 WARN("uDev(%u) requested >= max (%d)\n", mld
->uDeviceID
, llType
->wMaxId
);
106 return MMSYSERR_BADDEVICEID
;
108 devID
= mld
->uDeviceID
;
111 lpDrv
= &MMDrvs
[mld
->mmdIndex
];
112 part
= &lpDrv
->parts
[mld
->type
];
115 /* some sanity checks */
116 if (!(part
->nIDMin
<= devID
))
117 ERR("!(part->nIDMin(%d) <= devID(%d))\n", part
->nIDMin
, devID
);
118 if (!(devID
< part
->nIDMax
))
119 ERR("!(devID(%d) < part->nIDMax(%d))\n", devID
, part
->nIDMax
);
122 assert(part
->fnMessage32
);
124 TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n",
125 mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
126 ret
= part
->fnMessage32(mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
127 TRACE("=> %s\n", WINMM_ErrorToString(ret
));
132 /**************************************************************************
133 * MMDRV_Alloc [internal]
135 LPWINE_MLD
MMDRV_Alloc(UINT size
, UINT type
, LPHANDLE hndl
, DWORD
* dwFlags
,
136 DWORD_PTR
* dwCallback
, DWORD_PTR
* dwInstance
)
140 TRACE("(%d, %04x, %p, %p, %p, %p)\n",
141 size
, type
, hndl
, dwFlags
, dwCallback
, dwInstance
);
143 mld
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
144 if (!mld
) return NULL
;
146 /* find an empty slot in MM_MLDrvs table */
147 for (i
= 0; i
< MAX_MM_MLDRVS
; i
++) if (!MM_MLDrvs
[i
]) break;
149 if (i
== MAX_MM_MLDRVS
) {
150 /* the MM_MLDrvs table could be made growable in the future if needed */
151 ERR("Too many open drivers\n");
152 HeapFree(GetProcessHeap(), 0, mld
);
156 *hndl
= (HANDLE
)(i
| 0x8000);
159 if ((UINT_PTR
)*hndl
< MMDRV_GetNum(type
) || ((UINT_PTR
)*hndl
>> 16)) {
160 /* FIXME: those conditions must be fulfilled so that:
161 * - we can distinguish between device IDs and handles
162 * - we can use handles as 16 or 32 bit entities
164 ERR("Shouldn't happen. Bad allocation scheme\n");
167 mld
->dwFlags
= HIWORD(*dwFlags
);
168 mld
->dwCallback
= *dwCallback
;
169 mld
->dwClientInstance
= *dwInstance
;
174 /**************************************************************************
175 * MMDRV_Free [internal]
177 void MMDRV_Free(HANDLE hndl
, LPWINE_MLD mld
)
179 TRACE("(%p, %p)\n", hndl
, mld
);
181 if ((UINT_PTR
)hndl
& 0x8000) {
182 UINT_PTR idx
= (UINT_PTR
)hndl
& ~0x8000;
183 if (idx
< sizeof(MM_MLDrvs
) / sizeof(MM_MLDrvs
[0])) {
184 MM_MLDrvs
[idx
] = NULL
;
185 HeapFree(GetProcessHeap(), 0, mld
);
189 ERR("Bad Handle %p at %p (not freed)\n", hndl
, mld
);
192 /**************************************************************************
193 * MMDRV_Open [internal]
195 DWORD
MMDRV_Open(LPWINE_MLD mld
, UINT wMsg
, DWORD_PTR dwParam1
, DWORD dwFlags
)
197 DWORD dwRet
= MMSYSERR_BADDEVICEID
;
198 DWORD_PTR dwInstance
;
199 WINE_LLTYPE
* llType
= &llTypes
[mld
->type
];
200 TRACE("(%p, %04x, 0x%08lx, 0x%08x)\n", mld
, wMsg
, dwParam1
, dwFlags
);
202 mld
->dwDriverInstance
= (DWORD_PTR
)&dwInstance
;
204 if (mld
->uDeviceID
== (UINT
)-1 || mld
->uDeviceID
== (UINT16
)-1) {
205 TRACE("MAPPER mode requested !\n");
206 /* check if mapper is supported by type */
207 if (llType
->bSupportMapper
) {
208 if (llType
->nMapper
== -1) {
209 /* no driver for mapper has been loaded, try a dumb implementation */
210 TRACE("No mapper loaded, doing it by hand\n");
211 for (mld
->uDeviceID
= 0; mld
->uDeviceID
< llType
->wMaxId
; mld
->uDeviceID
++) {
212 if ((dwRet
= MMDRV_Open(mld
, wMsg
, dwParam1
, dwFlags
)) == MMSYSERR_NOERROR
) {
213 /* to share this function epilog */
214 dwInstance
= mld
->dwDriverInstance
;
219 mld
->uDeviceID
= (UINT16
)-1;
220 mld
->mmdIndex
= llType
->lpMlds
[-1].mmdIndex
;
221 TRACE("Setting mmdIndex to %u\n", mld
->mmdIndex
);
222 dwRet
= MMDRV_Message(mld
, wMsg
, dwParam1
, dwFlags
);
226 if (mld
->uDeviceID
< llType
->wMaxId
) {
227 mld
->mmdIndex
= llType
->lpMlds
[mld
->uDeviceID
].mmdIndex
;
228 TRACE("Setting mmdIndex to %u\n", mld
->mmdIndex
);
229 dwRet
= MMDRV_Message(mld
, wMsg
, dwParam1
, dwFlags
);
232 if (dwRet
== MMSYSERR_NOERROR
)
233 mld
->dwDriverInstance
= dwInstance
;
237 /**************************************************************************
238 * MMDRV_Close [internal]
240 DWORD
MMDRV_Close(LPWINE_MLD mld
, UINT wMsg
)
242 TRACE("(%p, %04x)\n", mld
, wMsg
);
243 return MMDRV_Message(mld
, wMsg
, 0L, 0L);
246 /**************************************************************************
247 * MMDRV_GetByID [internal]
249 static LPWINE_MLD
MMDRV_GetByID(UINT uDevID
, UINT type
)
251 TRACE("(%04x, %04x)\n", uDevID
, type
);
252 if (uDevID
< llTypes
[type
].wMaxId
)
253 return &llTypes
[type
].lpMlds
[uDevID
];
254 if ((uDevID
== (UINT16
)-1 || uDevID
== (UINT
)-1) && llTypes
[type
].nMapper
!= -1)
255 return &llTypes
[type
].lpMlds
[-1];
259 /**************************************************************************
260 * MMDRV_Get [internal]
262 LPWINE_MLD
MMDRV_Get(HANDLE _hndl
, UINT type
, BOOL bCanBeID
)
264 LPWINE_MLD mld
= NULL
;
265 UINT_PTR hndl
= (UINT_PTR
)_hndl
;
266 TRACE("(%p, %04x, %c)\n", _hndl
, type
, bCanBeID
? 'Y' : 'N');
268 assert(type
< MMDRV_MAX
);
270 if (hndl
>= llTypes
[type
].wMaxId
&&
271 hndl
!= (UINT16
)-1 && hndl
!= (UINT
)-1) {
273 UINT idx
= hndl
& ~0x8000;
274 if (idx
< sizeof(MM_MLDrvs
) / sizeof(MM_MLDrvs
[0])) {
277 mld
= MM_MLDrvs
[idx
];
278 if (mld
&& mld
->type
!= type
) mld
= NULL
;
288 if (mld
== NULL
&& bCanBeID
) {
289 mld
= MMDRV_GetByID(hndl
, type
);
294 /**************************************************************************
295 * MMDRV_GetRelated [internal]
297 LPWINE_MLD
MMDRV_GetRelated(HANDLE hndl
, UINT srcType
,
298 BOOL bSrcCanBeID
, UINT dstType
)
301 TRACE("(%p, %04x, %c, %04x)\n",
302 hndl
, srcType
, bSrcCanBeID
? 'Y' : 'N', dstType
);
304 if ((mld
= MMDRV_Get(hndl
, srcType
, bSrcCanBeID
)) != NULL
) {
305 WINE_MM_DRIVER_PART
* part
= &MMDrvs
[mld
->mmdIndex
].parts
[dstType
];
306 if (part
->nIDMin
< part
->nIDMax
)
307 return MMDRV_GetByID(part
->nIDMin
, dstType
);
312 /**************************************************************************
313 * MMDRV_PhysicalFeatures [internal]
315 UINT
MMDRV_PhysicalFeatures(LPWINE_MLD mld
, UINT uMsg
,
316 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
318 WINE_MM_DRIVER
* lpDrv
= &MMDrvs
[mld
->mmdIndex
];
320 TRACE("(%p, %04x, %08lx, %08lx)\n", mld
, uMsg
, dwParam1
, dwParam2
);
322 /* all those function calls are undocumented */
324 case DRV_QUERYDRVENTRY
:
325 lstrcpynA((LPSTR
)dwParam1
, lpDrv
->drvname
, LOWORD(dwParam2
));
327 case DRV_QUERYDEVNODE
:
328 *(LPDWORD
)dwParam1
= 0L; /* should be DevNode */
331 WARN("NIY QueryName\n");
333 case DRV_QUERYDRIVERIDS
:
334 WARN("NIY call VxD\n");
335 /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts
336 * dwParam1 is buffer and dwParam2 is sizeof(buffer)
337 * I don't know where the result is stored though
340 case DRV_QUERYMAPPABLE
:
341 return (lpDrv
->bIsMapper
) ? 2 : 0;
343 case DRVM_MAPPER_PREFERRED_GET
:
344 /* FIXME: get from registry someday */
345 *((LPDWORD
)dwParam1
) = -1; /* No preferred device */
346 *((LPDWORD
)dwParam2
) = 0;
349 case DRV_QUERYDEVICEINTERFACE
:
350 case DRV_QUERYDEVICEINTERFACESIZE
:
351 return MMDRV_Message(mld
, uMsg
, dwParam1
, dwParam2
);
353 case DRV_QUERYDSOUNDIFACE
: /* Wine-specific: Retrieve DirectSound interface */
354 case DRV_QUERYDSOUNDDESC
: /* Wine-specific: Retrieve DirectSound driver description*/
355 return MMDRV_Message(mld
, uMsg
, dwParam1
, dwParam2
);
358 WARN("Unknown call %04x\n", uMsg
);
359 return MMSYSERR_INVALPARAM
;
364 /**************************************************************************
365 * MMDRV_InitPerType [internal]
367 static BOOL
MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv
, UINT type
, UINT wMsg
)
369 WINE_MM_DRIVER_PART
* part
= &lpDrv
->parts
[type
];
373 TRACE("(%p, %04x, %04x)\n", lpDrv
, type
, wMsg
);
375 part
->nIDMin
= part
->nIDMax
= 0;
377 /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */
378 /* the DRVM_ENABLE is only required when the PnP node is non zero */
379 if (part
->fnMessage32
) {
380 ret
= part
->fnMessage32(0, DRVM_INIT
, 0L, 0L, 0L);
381 TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret
));
383 ret
= part
->fnMessage32(0, DRVM_ENABLE
, 0L, 0L, 0L);
384 TRACE("DRVM_ENABLE => %08lx\n", ret
);
386 count
= part
->fnMessage32(0, wMsg
, 0L, 0L, 0L);
390 TRACE("Got %u dev for (%s:%s)\n", count
, lpDrv
->drvname
, llTypes
[type
].typestr
);
395 /* got some drivers */
396 if (lpDrv
->bIsMapper
) {
397 /* it seems native mappers return 0 devices :-( */
398 if (llTypes
[type
].nMapper
!= -1)
399 ERR("Two mappers for type %s (%d, %s)\n",
400 llTypes
[type
].typestr
, llTypes
[type
].nMapper
, lpDrv
->drvname
);
402 ERR("Strange: mapper with %d > 1 devices\n", count
);
403 llTypes
[type
].nMapper
= MMDrvsHi
;
407 part
->nIDMin
= llTypes
[type
].wMaxId
;
408 llTypes
[type
].wMaxId
+= count
;
409 part
->nIDMax
= llTypes
[type
].wMaxId
;
411 TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n",
412 part
->nIDMin
, part
->nIDMax
, llTypes
[type
].wMaxId
,
413 lpDrv
->drvname
, llTypes
[type
].typestr
);
414 /* realloc translation table */
415 if (llTypes
[type
].lpMlds
)
416 llTypes
[type
].lpMlds
= (LPWINE_MLD
)
417 HeapReAlloc(GetProcessHeap(), 0, llTypes
[type
].lpMlds
- 1,
418 sizeof(WINE_MLD
) * (llTypes
[type
].wMaxId
+ 1)) + 1;
420 llTypes
[type
].lpMlds
= (LPWINE_MLD
)
421 HeapAlloc(GetProcessHeap(), 0,
422 sizeof(WINE_MLD
) * (llTypes
[type
].wMaxId
+ 1)) + 1;
424 /* re-build the translation table */
425 if (llTypes
[type
].nMapper
!= -1) {
426 TRACE("%s:Trans[%d] -> %s\n", llTypes
[type
].typestr
, -1, MMDrvs
[llTypes
[type
].nMapper
].drvname
);
427 llTypes
[type
].lpMlds
[-1].uDeviceID
= (UINT16
)-1;
428 llTypes
[type
].lpMlds
[-1].type
= type
;
429 llTypes
[type
].lpMlds
[-1].mmdIndex
= llTypes
[type
].nMapper
;
430 llTypes
[type
].lpMlds
[-1].dwDriverInstance
= 0;
432 for (i
= k
= 0; i
<= MMDrvsHi
; i
++) {
433 while (MMDrvs
[i
].parts
[type
].nIDMin
<= k
&& k
< MMDrvs
[i
].parts
[type
].nIDMax
) {
434 TRACE("%s:Trans[%d] -> %s\n", llTypes
[type
].typestr
, k
, MMDrvs
[i
].drvname
);
435 llTypes
[type
].lpMlds
[k
].uDeviceID
= k
;
436 llTypes
[type
].lpMlds
[k
].type
= type
;
437 llTypes
[type
].lpMlds
[k
].mmdIndex
= i
;
438 llTypes
[type
].lpMlds
[k
].dwDriverInstance
= 0;
445 /**************************************************************************
446 * MMDRV_Install [internal]
448 BOOL
MMDRV_Install(LPCSTR drvRegName
, LPCSTR drvFileName
, BOOL bIsMapper
)
451 LPWINE_MM_DRIVER lpDrv
= &MMDrvs
[MMDrvsHi
];
453 WINEMM_msgFunc32 func
;
455 TRACE("('%s', '%s', mapper=%c);\n", drvRegName
, drvFileName
, bIsMapper
? 'Y' : 'N');
457 for (i
= 0; i
< MMDrvsHi
; i
++) {
458 if (!strcmp(drvRegName
, MMDrvs
[i
].drvname
)) return FALSE
;
461 /* Be sure that size of MMDrvs matches the max number of loadable
463 * If not just increase size of MMDrvs
465 assert(MMDrvsHi
<= sizeof(MMDrvs
)/sizeof(MMDrvs
[0]));
467 memset(lpDrv
, 0, sizeof(*lpDrv
));
469 if (!(lpDrv
->hDriver
= OpenDriverA(drvFileName
, 0, 0))) {
470 WARN("Couldn't open driver '%s'\n", drvFileName
);
474 d
= DRIVER_FindFromHDrvr(lpDrv
->hDriver
);
476 if (!(d
= DRIVER_FindFromHDrvr(lpDrv
->hDriver
))) {
477 CloseDriver(lpDrv
->hDriver
, 0, 0);
478 WARN("Couldn't get the WINE internal structure for driver '%s'\n", drvFileName
);
482 /* Then look for xxxMessage functions */
483 #define AA(_h,_w,_x,_y,_z) \
484 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
486 { lpDrv->parts[_w].fnMessage##_y = func; count++; \
487 TRACE("Got %d bit func '%s'\n", _y, #_x); }
490 #define A(_x,_y) AA(d->hModule,_x,_y,32,GetProcAddress)
491 A(MMDRV_AUX
, auxMessage
);
492 A(MMDRV_MIXER
, mxdMessage
);
493 A(MMDRV_MIDIIN
, midMessage
);
494 A(MMDRV_MIDIOUT
, modMessage
);
495 A(MMDRV_WAVEIN
, widMessage
);
496 A(MMDRV_WAVEOUT
, wodMessage
);
502 CloseDriver(lpDrv
->hDriver
, 0, 0);
503 WARN("No message functions found\n");
507 /* FIXME: being a mapper or not should be known by another way */
508 /* it's known for NE drvs (the description is of the form '*mapper: *'
509 * I don't have any clue for PE drvs
511 lpDrv
->bIsMapper
= bIsMapper
;
512 lpDrv
->drvname
= strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName
) + 1), drvRegName
);
514 /* Finish init and get the count of the devices */
516 if (MMDRV_InitPerType(lpDrv
, MMDRV_AUX
, AUXDM_GETNUMDEVS
)) i
= 1;
517 if (MMDRV_InitPerType(lpDrv
, MMDRV_MIXER
, MXDM_GETNUMDEVS
)) i
= 1;
518 if (MMDRV_InitPerType(lpDrv
, MMDRV_MIDIIN
, MIDM_GETNUMDEVS
)) i
= 1;
519 if (MMDRV_InitPerType(lpDrv
, MMDRV_MIDIOUT
, MODM_GETNUMDEVS
)) i
= 1;
520 if (MMDRV_InitPerType(lpDrv
, MMDRV_WAVEIN
, WIDM_GETNUMDEVS
)) i
= 1;
521 if (MMDRV_InitPerType(lpDrv
, MMDRV_WAVEOUT
, WODM_GETNUMDEVS
)) i
= 1;
522 /* if all those func calls return FALSE, then the driver must be unloaded */
524 CloseDriver(lpDrv
->hDriver
, 0, 0);
525 HeapFree(GetProcessHeap(), 0, lpDrv
->drvname
);
526 WARN("Driver initialization failed\n");
535 /**************************************************************************
538 BOOL
MMDRV_Init(void)
540 /* Redundant code, keeping this for reference only (for now) */
543 char driver_buffer
[256];
544 char mapper_buffer
[256];
545 char midi_buffer
[256];
551 strcpy(driver_buffer
, WINE_DEFAULT_WINMM_DRIVER
);
552 strcpy(mapper_buffer
, WINE_DEFAULT_WINMM_MAPPER
);
553 strcpy(midi_buffer
, WINE_DEFAULT_WINMM_MIDI
);
555 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
556 if (!RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hKey
))
558 size
= sizeof(driver_buffer
);
559 if (RegQueryValueExA(hKey
, "Audio", 0, &type
, (LPVOID
)driver_buffer
, &size
))
560 strcpy(driver_buffer
, WINE_DEFAULT_WINMM_DRIVER
);
566 char filename
[sizeof(driver_buffer
)+10];
567 char *next
= strchr(p
, ',');
568 if (next
) *next
++ = 0;
569 sprintf( filename
, "wine%s.drv", p
);
570 if ((ret
= MMDRV_Install( filename
, filename
, FALSE
))) break;
574 ret
|= MMDRV_Install("beepmidi.dll", "beepmidi.dll", FALSE
);
576 ret
|= MMDRV_Install("wavemapper", WINE_DEFAULT_WINMM_MAPPER
, TRUE
);
577 ret
|= MMDRV_Install("midimapper", WINE_DEFAULT_WINMM_MIDI
, TRUE
);
580 INT driver_count
= 0;
582 driver_count
+= LoadRegistryMMEDrivers(NT_MME_DRIVERS_KEY
);
583 driver_count
+= LoadRegistryMMEDrivers(NT_MME_DRIVERS32_KEY
);
585 /* Explorer doesn't like us failing */
587 // return ( driver_count > 0 );
591 /******************************************************************
596 static BOOL
MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv
, UINT type
)
598 WINE_MM_DRIVER_PART
* part
= &lpDrv
->parts
[type
];
600 TRACE("(%p, %04x)\n", lpDrv
, type
);
602 if (part
->fnMessage32
) {
604 ret
= part
->fnMessage32(0, DRVM_DISABLE
, 0L, 0L, 0L);
605 TRACE("DRVM_DISABLE => %08lx\n", ret
);
607 ret
= part
->fnMessage32(0, DRVM_EXIT
, 0L, 0L, 0L);
608 TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret
));
614 /******************************************************************
619 void MMDRV_Exit(void)
624 for (i
= 0; i
< sizeof(MM_MLDrvs
) / sizeof(MM_MLDrvs
[0]); i
++)
626 if (MM_MLDrvs
[i
] != NULL
)
628 FIXME("Closing while ll-driver open\n");
630 /* FIXME: should generate a message depending on type */
631 MMDRV_Free((HANDLE
)(i
| 0x8000), MM_MLDrvs
[i
]);
636 /* unload driver, in reverse order of loading */
637 i
= sizeof(MMDrvs
) / sizeof(MMDrvs
[0]);
640 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_AUX
);
641 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_MIXER
);
642 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_MIDIIN
);
643 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_MIDIOUT
);
644 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_WAVEIN
);
645 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_WAVEOUT
);
646 CloseDriver(MMDrvs
[i
].hDriver
, 0, 0);
648 if (llTypes
[MMDRV_AUX
].lpMlds
)
649 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_AUX
].lpMlds
- 1);
650 if (llTypes
[MMDRV_MIXER
].lpMlds
)
651 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_MIXER
].lpMlds
- 1);
652 if (llTypes
[MMDRV_MIDIIN
].lpMlds
)
653 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_MIDIIN
].lpMlds
- 1);
654 if (llTypes
[MMDRV_MIDIOUT
].lpMlds
)
655 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_MIDIOUT
].lpMlds
- 1);
656 if (llTypes
[MMDRV_WAVEIN
].lpMlds
)
657 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_WAVEIN
].lpMlds
- 1);
658 if (llTypes
[MMDRV_WAVEOUT
].lpMlds
)
659 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_WAVEOUT
].lpMlds
- 1);