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
26 WINE_DEFAULT_DEBUG_CHANNEL(winmm
);
28 /* each known type of driver has an instance of this structure */
29 typedef struct tagWINE_LLTYPE
{
30 /* those attributes depend on the specification of the type */
31 LPCSTR typestr
; /* name (for debugging) */
32 BOOL bSupportMapper
; /* if type is allowed to support mapper */
33 /* those attributes reflect the loaded/current situation for the type */
34 UINT wMaxId
; /* number of loaded devices (sum across all loaded drivers) */
35 LPWINE_MLD lpMlds
; /* "static" mlds to access the part though device IDs */
36 int nMapper
; /* index to mapper */
39 static int MMDrvsHi
/* = 0 */;
40 static WINE_MM_DRIVER MMDrvs
[8];
41 static LPWINE_MLD MM_MLDrvs
[40];
42 #define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]))
44 #define A(_x,_y) {#_y, _x, 0, NULL, -1}
45 /* Note: the indices of this array must match the definitions
46 * of the MMDRV_???? manifest constants
48 static WINE_LLTYPE llTypes
[MMDRV_MAX
] = {
58 /**************************************************************************
59 * MMDRV_GetNum [internal]
61 UINT
MMDRV_GetNum(UINT type
)
63 TRACE("(%04x)\n", type
);
64 assert(type
< MMDRV_MAX
);
65 return llTypes
[type
].wMaxId
;
68 /**************************************************************************
69 * MMDRV_Message [internal]
71 DWORD
MMDRV_Message(LPWINE_MLD mld
, UINT wMsg
, DWORD_PTR dwParam1
,
74 LPWINE_MM_DRIVER lpDrv
;
76 WINE_MM_DRIVER_PART
* part
;
77 WINE_LLTYPE
* llType
= &llTypes
[mld
->type
];
80 TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx)\n",
81 llTypes
[mld
->type
].typestr
, mld
->uDeviceID
, wMsg
,
82 mld
->dwDriverInstance
, dwParam1
, dwParam2
);
84 if (mld
->uDeviceID
== (UINT16
)-1) {
85 if (!llType
->bSupportMapper
) {
86 WARN("uDev=-1 requested on non-mappable ll type %s\n",
87 llTypes
[mld
->type
].typestr
);
88 return MMSYSERR_BADDEVICEID
;
92 if (mld
->uDeviceID
>= llType
->wMaxId
) {
93 WARN("uDev(%u) requested >= max (%d)\n", mld
->uDeviceID
, llType
->wMaxId
);
94 return MMSYSERR_BADDEVICEID
;
96 devID
= mld
->uDeviceID
;
99 lpDrv
= &MMDrvs
[mld
->mmdIndex
];
100 part
= &lpDrv
->parts
[mld
->type
];
103 /* some sanity checks */
104 if (!(part
->nIDMin
<= devID
))
105 ERR("!(part->nIDMin(%d) <= devID(%d))\n", part
->nIDMin
, devID
);
106 if (!(devID
< part
->nIDMax
))
107 ERR("!(devID(%d) < part->nIDMax(%d))\n", devID
, part
->nIDMax
);
110 assert(part
->fnMessage32
);
112 TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n",
113 mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
114 ret
= part
->fnMessage32(mld
->uDeviceID
, wMsg
, mld
->dwDriverInstance
, dwParam1
, dwParam2
);
115 TRACE("=> %s\n", WINMM_ErrorToString(ret
));
120 /**************************************************************************
121 * MMDRV_Alloc [internal]
123 LPWINE_MLD
MMDRV_Alloc(UINT size
, UINT type
, LPHANDLE hndl
, DWORD
* dwFlags
,
124 DWORD_PTR
* dwCallback
, DWORD_PTR
* dwInstance
)
128 TRACE("(%d, %04x, %p, %p, %p, %p)\n",
129 size
, type
, hndl
, dwFlags
, dwCallback
, dwInstance
);
131 mld
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
132 if (!mld
) return NULL
;
134 /* find an empty slot in MM_MLDrvs table */
135 for (i
= 0; i
< MAX_MM_MLDRVS
; i
++) if (!MM_MLDrvs
[i
]) break;
137 if (i
== MAX_MM_MLDRVS
) {
138 /* the MM_MLDrvs table could be made growable in the future if needed */
139 ERR("Too many open drivers\n");
140 HeapFree(GetProcessHeap(), 0, mld
);
144 *hndl
= (HANDLE
)(i
| 0x8000);
147 if ((UINT_PTR
)*hndl
< MMDRV_GetNum(type
) || ((UINT_PTR
)*hndl
>> 16)) {
148 /* FIXME: those conditions must be fulfilled so that:
149 * - we can distinguish between device IDs and handles
150 * - we can use handles as 16 or 32 bit entities
152 ERR("Shouldn't happen. Bad allocation scheme\n");
155 mld
->dwFlags
= HIWORD(*dwFlags
);
156 mld
->dwCallback
= *dwCallback
;
157 mld
->dwClientInstance
= *dwInstance
;
162 /**************************************************************************
163 * MMDRV_Free [internal]
165 void MMDRV_Free(HANDLE hndl
, LPWINE_MLD mld
)
167 TRACE("(%p, %p)\n", hndl
, mld
);
169 if ((UINT_PTR
)hndl
& 0x8000) {
170 UINT_PTR idx
= (UINT_PTR
)hndl
& ~0x8000;
171 if (idx
< sizeof(MM_MLDrvs
) / sizeof(MM_MLDrvs
[0])) {
172 MM_MLDrvs
[idx
] = NULL
;
173 HeapFree(GetProcessHeap(), 0, mld
);
177 ERR("Bad Handle %p at %p (not freed)\n", hndl
, mld
);
180 /**************************************************************************
181 * MMDRV_Open [internal]
183 DWORD
MMDRV_Open(LPWINE_MLD mld
, UINT wMsg
, DWORD_PTR dwParam1
, DWORD dwFlags
)
185 DWORD dwRet
= MMSYSERR_BADDEVICEID
;
186 DWORD_PTR dwInstance
;
187 WINE_LLTYPE
* llType
= &llTypes
[mld
->type
];
188 TRACE("(%p, %04x, 0x%08lx, 0x%08x)\n", mld
, wMsg
, dwParam1
, dwFlags
);
190 mld
->dwDriverInstance
= (DWORD_PTR
)&dwInstance
;
192 if (mld
->uDeviceID
== (UINT
)-1 || mld
->uDeviceID
== (UINT16
)-1) {
193 TRACE("MAPPER mode requested !\n");
194 /* check if mapper is supported by type */
195 if (llType
->bSupportMapper
) {
196 if (llType
->nMapper
== -1) {
197 /* no driver for mapper has been loaded, try a dumb implementation */
198 TRACE("No mapper loaded, doing it by hand\n");
199 for (mld
->uDeviceID
= 0; mld
->uDeviceID
< llType
->wMaxId
; mld
->uDeviceID
++) {
200 if ((dwRet
= MMDRV_Open(mld
, wMsg
, dwParam1
, dwFlags
)) == MMSYSERR_NOERROR
) {
201 /* to share this function epilog */
202 dwInstance
= mld
->dwDriverInstance
;
207 mld
->uDeviceID
= (UINT16
)-1;
208 mld
->mmdIndex
= llType
->lpMlds
[-1].mmdIndex
;
209 TRACE("Setting mmdIndex to %u\n", mld
->mmdIndex
);
210 dwRet
= MMDRV_Message(mld
, wMsg
, dwParam1
, dwFlags
);
214 if (mld
->uDeviceID
< llType
->wMaxId
) {
215 mld
->mmdIndex
= llType
->lpMlds
[mld
->uDeviceID
].mmdIndex
;
216 TRACE("Setting mmdIndex to %u\n", mld
->mmdIndex
);
217 dwRet
= MMDRV_Message(mld
, wMsg
, dwParam1
, dwFlags
);
220 if (dwRet
== MMSYSERR_NOERROR
)
221 mld
->dwDriverInstance
= dwInstance
;
225 /**************************************************************************
226 * MMDRV_Close [internal]
228 DWORD
MMDRV_Close(LPWINE_MLD mld
, UINT wMsg
)
230 TRACE("(%p, %04x)\n", mld
, wMsg
);
231 return MMDRV_Message(mld
, wMsg
, 0L, 0L);
234 /**************************************************************************
235 * MMDRV_GetByID [internal]
237 static LPWINE_MLD
MMDRV_GetByID(UINT uDevID
, UINT type
)
239 TRACE("(%04x, %04x)\n", uDevID
, type
);
240 if (uDevID
< llTypes
[type
].wMaxId
)
241 return &llTypes
[type
].lpMlds
[uDevID
];
242 if ((uDevID
== (UINT16
)-1 || uDevID
== (UINT
)-1) && llTypes
[type
].nMapper
!= -1)
243 return &llTypes
[type
].lpMlds
[-1];
247 /**************************************************************************
248 * MMDRV_Get [internal]
250 LPWINE_MLD
MMDRV_Get(HANDLE _hndl
, UINT type
, BOOL bCanBeID
)
252 LPWINE_MLD mld
= NULL
;
253 UINT_PTR hndl
= (UINT_PTR
)_hndl
;
254 TRACE("(%p, %04x, %c)\n", _hndl
, type
, bCanBeID
? 'Y' : 'N');
256 assert(type
< MMDRV_MAX
);
258 if (hndl
>= llTypes
[type
].wMaxId
&&
259 hndl
!= (UINT16
)-1 && hndl
!= (UINT
)-1) {
261 UINT idx
= hndl
& ~0x8000;
262 if (idx
< sizeof(MM_MLDrvs
) / sizeof(MM_MLDrvs
[0])) {
265 mld
= MM_MLDrvs
[idx
];
266 if (mld
&& mld
->type
!= type
) mld
= NULL
;
276 if (mld
== NULL
&& bCanBeID
) {
277 mld
= MMDRV_GetByID(hndl
, type
);
282 /**************************************************************************
283 * MMDRV_GetRelated [internal]
285 LPWINE_MLD
MMDRV_GetRelated(HANDLE hndl
, UINT srcType
,
286 BOOL bSrcCanBeID
, UINT dstType
)
289 TRACE("(%p, %04x, %c, %04x)\n",
290 hndl
, srcType
, bSrcCanBeID
? 'Y' : 'N', dstType
);
292 if ((mld
= MMDRV_Get(hndl
, srcType
, bSrcCanBeID
)) != NULL
) {
293 WINE_MM_DRIVER_PART
* part
= &MMDrvs
[mld
->mmdIndex
].parts
[dstType
];
294 if (part
->nIDMin
< part
->nIDMax
)
295 return MMDRV_GetByID(part
->nIDMin
, dstType
);
300 /**************************************************************************
301 * MMDRV_PhysicalFeatures [internal]
303 UINT
MMDRV_PhysicalFeatures(LPWINE_MLD mld
, UINT uMsg
,
304 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
306 WINE_MM_DRIVER
* lpDrv
= &MMDrvs
[mld
->mmdIndex
];
308 TRACE("(%p, %04x, %08lx, %08lx)\n", mld
, uMsg
, dwParam1
, dwParam2
);
310 /* all those function calls are undocumented */
312 case DRV_QUERYDRVENTRY
:
313 lstrcpynA((LPSTR
)dwParam1
, lpDrv
->drvname
, LOWORD(dwParam2
));
315 case DRV_QUERYDEVNODE
:
316 *(LPDWORD
)dwParam1
= 0L; /* should be DevNode */
319 WARN("NIY QueryName\n");
321 case DRV_QUERYDRIVERIDS
:
322 WARN("NIY call VxD\n");
323 /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts
324 * dwParam1 is buffer and dwParam2 is sizeof(buffer)
325 * I don't know where the result is stored though
328 case DRV_QUERYMAPPABLE
:
329 return (lpDrv
->bIsMapper
) ? 2 : 0;
331 case DRVM_MAPPER_PREFERRED_GET
:
332 /* FIXME: get from registry someday */
333 *((LPDWORD
)dwParam1
) = -1; /* No preferred device */
334 *((LPDWORD
)dwParam2
) = 0;
337 case DRV_QUERYDEVICEINTERFACE
:
338 case DRV_QUERYDEVICEINTERFACESIZE
:
339 return MMDRV_Message(mld
, uMsg
, dwParam1
, dwParam2
);
341 case DRV_QUERYDSOUNDIFACE
: /* Wine-specific: Retrieve DirectSound interface */
342 case DRV_QUERYDSOUNDDESC
: /* Wine-specific: Retrieve DirectSound driver description*/
343 return MMDRV_Message(mld
, uMsg
, dwParam1
, dwParam2
);
346 WARN("Unknown call %04x\n", uMsg
);
347 return MMSYSERR_INVALPARAM
;
352 /**************************************************************************
353 * MMDRV_InitPerType [internal]
355 static BOOL
MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv
, UINT type
, UINT wMsg
)
357 WINE_MM_DRIVER_PART
* part
= &lpDrv
->parts
[type
];
361 TRACE("(%p, %04x, %04x)\n", lpDrv
, type
, wMsg
);
363 part
->nIDMin
= part
->nIDMax
= 0;
365 /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */
366 /* the DRVM_ENABLE is only required when the PnP node is non zero */
367 if (part
->fnMessage32
) {
368 ret
= part
->fnMessage32(0, DRVM_INIT
, 0L, 0L, 0L);
369 TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret
));
371 ret
= part
->fnMessage32(0, DRVM_ENABLE
, 0L, 0L, 0L);
372 TRACE("DRVM_ENABLE => %08lx\n", ret
);
374 count
= part
->fnMessage32(0, wMsg
, 0L, 0L, 0L);
378 TRACE("Got %u dev for (%s:%s)\n", count
, lpDrv
->drvname
, llTypes
[type
].typestr
);
383 /* got some drivers */
384 if (lpDrv
->bIsMapper
) {
385 /* it seems native mappers return 0 devices :-( */
386 if (llTypes
[type
].nMapper
!= -1)
387 ERR("Two mappers for type %s (%d, %s)\n",
388 llTypes
[type
].typestr
, llTypes
[type
].nMapper
, lpDrv
->drvname
);
390 ERR("Strange: mapper with %d > 1 devices\n", count
);
391 llTypes
[type
].nMapper
= MMDrvsHi
;
395 part
->nIDMin
= llTypes
[type
].wMaxId
;
396 llTypes
[type
].wMaxId
+= count
;
397 part
->nIDMax
= llTypes
[type
].wMaxId
;
399 TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n",
400 part
->nIDMin
, part
->nIDMax
, llTypes
[type
].wMaxId
,
401 lpDrv
->drvname
, llTypes
[type
].typestr
);
402 /* realloc translation table */
403 if (llTypes
[type
].lpMlds
)
404 llTypes
[type
].lpMlds
= (LPWINE_MLD
)
405 HeapReAlloc(GetProcessHeap(), 0, llTypes
[type
].lpMlds
- 1,
406 sizeof(WINE_MLD
) * (llTypes
[type
].wMaxId
+ 1)) + 1;
408 llTypes
[type
].lpMlds
= (LPWINE_MLD
)
409 HeapAlloc(GetProcessHeap(), 0,
410 sizeof(WINE_MLD
) * (llTypes
[type
].wMaxId
+ 1)) + 1;
412 /* re-build the translation table */
413 if (llTypes
[type
].nMapper
!= -1) {
414 TRACE("%s:Trans[%d] -> %s\n", llTypes
[type
].typestr
, -1, MMDrvs
[llTypes
[type
].nMapper
].drvname
);
415 llTypes
[type
].lpMlds
[-1].uDeviceID
= (UINT16
)-1;
416 llTypes
[type
].lpMlds
[-1].type
= type
;
417 llTypes
[type
].lpMlds
[-1].mmdIndex
= llTypes
[type
].nMapper
;
418 llTypes
[type
].lpMlds
[-1].dwDriverInstance
= 0;
420 for (i
= k
= 0; i
<= MMDrvsHi
; i
++) {
421 while (MMDrvs
[i
].parts
[type
].nIDMin
<= k
&& k
< MMDrvs
[i
].parts
[type
].nIDMax
) {
422 TRACE("%s:Trans[%d] -> %s\n", llTypes
[type
].typestr
, k
, MMDrvs
[i
].drvname
);
423 llTypes
[type
].lpMlds
[k
].uDeviceID
= k
;
424 llTypes
[type
].lpMlds
[k
].type
= type
;
425 llTypes
[type
].lpMlds
[k
].mmdIndex
= i
;
426 llTypes
[type
].lpMlds
[k
].dwDriverInstance
= 0;
433 /**************************************************************************
434 * MMDRV_Install [internal]
436 BOOL
MMDRV_Install(LPCSTR drvRegName
, LPCSTR drvFileName
, BOOL bIsMapper
)
439 LPWINE_MM_DRIVER lpDrv
= &MMDrvs
[MMDrvsHi
];
441 WINEMM_msgFunc32 func
;
443 TRACE("('%s', '%s', mapper=%c);\n", drvRegName
, drvFileName
, bIsMapper
? 'Y' : 'N');
445 for (i
= 0; i
< MMDrvsHi
; i
++) {
446 if (!strcmp(drvRegName
, MMDrvs
[i
].drvname
)) return FALSE
;
449 /* Be sure that size of MMDrvs matches the max number of loadable
451 * If not just increase size of MMDrvs
453 assert(MMDrvsHi
<= sizeof(MMDrvs
)/sizeof(MMDrvs
[0]));
455 memset(lpDrv
, 0, sizeof(*lpDrv
));
457 if (!(lpDrv
->hDriver
= OpenDriverA(drvFileName
, 0, 0))) {
458 WARN("Couldn't open driver '%s'\n", drvFileName
);
462 d
= DRIVER_FindFromHDrvr(lpDrv
->hDriver
);
464 if (!(d
= DRIVER_FindFromHDrvr(lpDrv
->hDriver
))) {
465 CloseDriver(lpDrv
->hDriver
, 0, 0);
466 WARN("Couldn't get the WINE internal structure for driver '%s'\n", drvFileName
);
470 /* Then look for xxxMessage functions */
471 #define AA(_h,_w,_x,_y,_z) \
472 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
474 { lpDrv->parts[_w].fnMessage##_y = func; count++; \
475 TRACE("Got %d bit func '%s'\n", _y, #_x); }
478 #define A(_x,_y) AA(d->hModule,_x,_y,32,GetProcAddress)
479 A(MMDRV_AUX
, auxMessage
);
480 A(MMDRV_MIXER
, mxdMessage
);
481 A(MMDRV_MIDIIN
, midMessage
);
482 A(MMDRV_MIDIOUT
, modMessage
);
483 A(MMDRV_WAVEIN
, widMessage
);
484 A(MMDRV_WAVEOUT
, wodMessage
);
490 CloseDriver(lpDrv
->hDriver
, 0, 0);
491 WARN("No message functions found\n");
495 /* FIXME: being a mapper or not should be known by another way */
496 /* it's known for NE drvs (the description is of the form '*mapper: *'
497 * I don't have any clue for PE drvs
499 lpDrv
->bIsMapper
= bIsMapper
;
500 lpDrv
->drvname
= strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName
) + 1), drvRegName
);
502 /* Finish init and get the count of the devices */
504 if (MMDRV_InitPerType(lpDrv
, MMDRV_AUX
, AUXDM_GETNUMDEVS
)) i
= 1;
505 if (MMDRV_InitPerType(lpDrv
, MMDRV_MIXER
, MXDM_GETNUMDEVS
)) i
= 1;
506 if (MMDRV_InitPerType(lpDrv
, MMDRV_MIDIIN
, MIDM_GETNUMDEVS
)) i
= 1;
507 if (MMDRV_InitPerType(lpDrv
, MMDRV_MIDIOUT
, MODM_GETNUMDEVS
)) i
= 1;
508 if (MMDRV_InitPerType(lpDrv
, MMDRV_WAVEIN
, WIDM_GETNUMDEVS
)) i
= 1;
509 if (MMDRV_InitPerType(lpDrv
, MMDRV_WAVEOUT
, WODM_GETNUMDEVS
)) i
= 1;
510 /* if all those func calls return FALSE, then the driver must be unloaded */
512 CloseDriver(lpDrv
->hDriver
, 0, 0);
513 HeapFree(GetProcessHeap(), 0, lpDrv
->drvname
);
514 WARN("Driver initialization failed\n");
523 /**************************************************************************
526 BOOL
MMDRV_Init(void)
528 /* Redundant code, keeping this for reference only (for now) */
531 char driver_buffer
[256];
532 char mapper_buffer
[256];
533 char midi_buffer
[256];
539 strcpy(driver_buffer
, WINE_DEFAULT_WINMM_DRIVER
);
540 strcpy(mapper_buffer
, WINE_DEFAULT_WINMM_MAPPER
);
541 strcpy(midi_buffer
, WINE_DEFAULT_WINMM_MIDI
);
543 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
544 if (!RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hKey
))
546 size
= sizeof(driver_buffer
);
547 if (RegQueryValueExA(hKey
, "Audio", 0, &type
, (LPVOID
)driver_buffer
, &size
))
548 strcpy(driver_buffer
, WINE_DEFAULT_WINMM_DRIVER
);
554 char filename
[sizeof(driver_buffer
)+10];
555 char *next
= strchr(p
, ',');
556 if (next
) *next
++ = 0;
557 sprintf( filename
, "wine%s.drv", p
);
558 if ((ret
= MMDRV_Install( filename
, filename
, FALSE
))) break;
562 ret
|= MMDRV_Install("beepmidi.dll", "beepmidi.dll", FALSE
);
564 ret
|= MMDRV_Install("wavemapper", WINE_DEFAULT_WINMM_MAPPER
, TRUE
);
565 ret
|= MMDRV_Install("midimapper", WINE_DEFAULT_WINMM_MIDI
, TRUE
);
568 INT driver_count
= 0;
570 driver_count
+= LoadRegistryMMEDrivers(NT_MME_DRIVERS_KEY
);
571 driver_count
+= LoadRegistryMMEDrivers(NT_MME_DRIVERS32_KEY
);
573 /* Explorer doesn't like us failing */
575 // return ( driver_count > 0 );
579 /******************************************************************
584 static BOOL
MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv
, UINT type
)
586 WINE_MM_DRIVER_PART
* part
= &lpDrv
->parts
[type
];
588 TRACE("(%p, %04x)\n", lpDrv
, type
);
590 if (part
->fnMessage32
) {
592 ret
= part
->fnMessage32(0, DRVM_DISABLE
, 0L, 0L, 0L);
593 TRACE("DRVM_DISABLE => %08lx\n", ret
);
595 ret
= part
->fnMessage32(0, DRVM_EXIT
, 0L, 0L, 0L);
596 TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret
));
602 /******************************************************************
607 void MMDRV_Exit(void)
612 for (i
= 0; i
< sizeof(MM_MLDrvs
) / sizeof(MM_MLDrvs
[0]); i
++)
614 if (MM_MLDrvs
[i
] != NULL
)
616 FIXME("Closing while ll-driver open\n");
618 /* FIXME: should generate a message depending on type */
619 MMDRV_Free((HANDLE
)(i
| 0x8000), MM_MLDrvs
[i
]);
624 /* unload driver, in reverse order of loading */
628 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_AUX
);
629 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_MIXER
);
630 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_MIDIIN
);
631 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_MIDIOUT
);
632 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_WAVEIN
);
633 MMDRV_ExitPerType(&MMDrvs
[i
], MMDRV_WAVEOUT
);
634 CloseDriver(MMDrvs
[i
].hDriver
, 0, 0);
636 if (llTypes
[MMDRV_AUX
].lpMlds
)
637 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_AUX
].lpMlds
- 1);
638 if (llTypes
[MMDRV_MIXER
].lpMlds
)
639 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_MIXER
].lpMlds
- 1);
640 if (llTypes
[MMDRV_MIDIIN
].lpMlds
)
641 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_MIDIIN
].lpMlds
- 1);
642 if (llTypes
[MMDRV_MIDIOUT
].lpMlds
)
643 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_MIDIOUT
].lpMlds
- 1);
644 if (llTypes
[MMDRV_WAVEIN
].lpMlds
)
645 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_WAVEIN
].lpMlds
- 1);
646 if (llTypes
[MMDRV_WAVEOUT
].lpMlds
)
647 HeapFree(GetProcessHeap(), 0, llTypes
[MMDRV_WAVEOUT
].lpMlds
- 1);