vbscript: Implemented Sgn.
[wine/multimedia.git] / dlls / winmm / lolvldrv.c
blobc3b36740b252e301f50cf8e2da2af021dcbd02ca
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*
4 * MMSYSTEM low level drivers handling functions
6 * Copyright 1999 Eric Pouech
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
28 #define COBJMACROS
29 #include <string.h>
30 #include <stdarg.h>
31 #include <stdio.h>
32 #include <assert.h>
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winreg.h"
36 #include "winnls.h"
37 #include "winemm.h"
38 #include "wine/debug.h"
39 #include "wine/exception.h"
41 #include "wingdi.h"
42 #include "ole2.h"
43 #include "devpkey.h"
44 #include "mmdeviceapi.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(winmm);
48 /* each known type of driver has an instance of this structure */
49 typedef struct tagWINE_LLTYPE {
50 /* those attributes depend on the specification of the type */
51 LPCSTR typestr; /* name (for debugging) */
52 /* those attributes reflect the loaded/current situation for the type */
53 UINT wMaxId; /* number of loaded devices (sum across all loaded drivers) */
54 LPWINE_MLD lpMlds; /* "static" mlds to access the part though device IDs */
55 int nMapper; /* index to mapper */
56 } WINE_LLTYPE;
58 static WINE_LLTYPE llTypes[MMDRV_MAX] = {
59 { "Aux", 0, 0, -1 },
60 { "Mixer", 0, 0, -1 },
61 { "MidiIn", 0, 0, -1 },
62 { "MidiOut", 0, 0, -1 },
63 { "WaveIn", 0, 0, -1 },
64 { "WaveOut", 0, 0, -1 }
67 static BOOL drivers_loaded;
68 static int MMDrvsHi;
69 static WINE_MM_DRIVER MMDrvs[8];
70 static LPWINE_MLD MM_MLDrvs[40];
71 #define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]))
73 static void MMDRV_Init(void);
75 static void MMDRV_InitSingleType(UINT type) {
76 if (!drivers_loaded) {
77 drivers_loaded = TRUE;
78 MMDRV_Init();
82 /**************************************************************************
83 * MMDRV_GetNum [internal]
85 UINT MMDRV_GetNum(UINT type)
87 TRACE("(%04x)\n", type);
88 assert(type < MMDRV_MAX);
89 MMDRV_InitSingleType(type);
90 return llTypes[type].wMaxId;
93 /**************************************************************************
94 * MMDRV_Message [internal]
96 DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1,
97 DWORD_PTR dwParam2)
99 LPWINE_MM_DRIVER lpDrv;
100 DWORD ret;
101 WINE_MM_DRIVER_PART* part;
102 WINE_LLTYPE* llType = &llTypes[mld->type];
104 TRACE("(%s %d %u 0x%08lx 0x%08lx 0x%08lx)\n",
105 llTypes[mld->type].typestr, mld->uDeviceID, wMsg,
106 mld->dwDriverInstance, dwParam1, dwParam2);
108 if ((UINT16)mld->uDeviceID == (UINT16)-1) {
109 if (llType->nMapper == -1) {
110 WARN("uDev=-1 requested on non-mapped ll type %s\n",
111 llTypes[mld->type].typestr);
112 return MMSYSERR_BADDEVICEID;
114 } else {
115 if (mld->uDeviceID >= llType->wMaxId) {
116 WARN("uDev(%u) requested >= max (%d)\n", mld->uDeviceID, llType->wMaxId);
117 return MMSYSERR_BADDEVICEID;
121 lpDrv = &MMDrvs[mld->mmdIndex];
122 part = &lpDrv->parts[mld->type];
124 assert(part->fnMessage32);
126 TRACE("Calling message(dev=%d msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n",
127 mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2);
128 ret = part->fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2);
129 TRACE("=> %s\n", WINMM_ErrorToString(ret));
131 return ret;
134 /**************************************************************************
135 * MMDRV_Alloc [internal]
137 LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
138 DWORD_PTR* dwCallback, DWORD_PTR* dwInstance)
140 LPWINE_MLD mld;
141 UINT_PTR i;
142 TRACE("(%d, %04x, %p, %p, %p, %p)\n",
143 size, type, hndl, dwFlags, dwCallback, dwInstance);
145 mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
146 if (!mld) return NULL;
148 /* find an empty slot in MM_MLDrvs table */
149 for (i = 0; i < MAX_MM_MLDRVS; i++) if (!MM_MLDrvs[i]) break;
151 if (i == MAX_MM_MLDRVS) {
152 /* the MM_MLDrvs table could be made growable in the future if needed */
153 ERR("Too many open drivers\n");
154 HeapFree(GetProcessHeap(), 0, mld);
155 return NULL;
157 MM_MLDrvs[i] = mld;
158 *hndl = (HANDLE)(i | 0x8000);
160 mld->type = type;
161 if ((UINT_PTR)*hndl < MMDRV_GetNum(type) || ((UINT_PTR)*hndl >> 16)) {
162 /* FIXME: those conditions must be fulfilled so that:
163 * - we can distinguish between device IDs and handles
164 * - we can use handles as 16 or 32 bit entities
166 ERR("Shouldn't happen. Bad allocation scheme\n");
169 mld->dwFlags = HIWORD(*dwFlags);
170 mld->dwCallback = *dwCallback;
171 mld->dwClientInstance = *dwInstance;
173 return mld;
176 /**************************************************************************
177 * MMDRV_Free [internal]
179 void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
181 TRACE("(%p, %p)\n", hndl, mld);
183 if ((UINT_PTR)hndl & 0x8000) {
184 UINT_PTR idx = (UINT_PTR)hndl & ~0x8000;
185 if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
186 MM_MLDrvs[idx] = NULL;
187 HeapFree(GetProcessHeap(), 0, mld);
188 return;
191 ERR("Bad Handle %p at %p (not freed)\n", hndl, mld);
194 /**************************************************************************
195 * MMDRV_Open [internal]
197 DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwFlags)
199 DWORD dwRet = MMSYSERR_BADDEVICEID;
200 DWORD_PTR dwInstance;
201 WINE_LLTYPE* llType = &llTypes[mld->type];
202 TRACE("(%p, %04x, 0x%08lx, 0x%08x)\n", mld, wMsg, dwParam1, dwFlags);
204 mld->dwDriverInstance = (DWORD_PTR)&dwInstance;
206 if (mld->uDeviceID == (UINT)-1 || mld->uDeviceID == (UINT16)-1) {
207 TRACE("MAPPER mode requested !\n");
208 if (llType->nMapper == -1) {
209 WARN("Mapper not supported for type %s\n", llTypes[mld->type].typestr);
210 return MMSYSERR_BADDEVICEID;
212 mld->mmdIndex = llType->lpMlds[-1].mmdIndex;
213 TRACE("Setting mmdIndex to %u\n", mld->mmdIndex);
214 dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags);
215 } else {
216 if (mld->uDeviceID < llType->wMaxId) {
217 mld->mmdIndex = llType->lpMlds[mld->uDeviceID].mmdIndex;
218 TRACE("Setting mmdIndex to %u\n", mld->mmdIndex);
219 dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags);
222 if (dwRet == MMSYSERR_NOERROR)
223 mld->dwDriverInstance = dwInstance;
224 return dwRet;
227 /**************************************************************************
228 * MMDRV_Close [internal]
230 DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg)
232 TRACE("(%p, %04x)\n", mld, wMsg);
233 return MMDRV_Message(mld, wMsg, 0L, 0L);
236 /**************************************************************************
237 * MMDRV_GetByID [internal]
239 static LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type)
241 TRACE("(%04x, %04x)\n", uDevID, type);
242 if (uDevID < llTypes[type].wMaxId)
243 return &llTypes[type].lpMlds[uDevID];
244 if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1)
245 return &llTypes[type].lpMlds[-1];
246 return NULL;
249 /**************************************************************************
250 * MMDRV_Get [internal]
252 LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
254 LPWINE_MLD mld = NULL;
255 UINT_PTR hndl = (UINT_PTR)_hndl;
256 TRACE("(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
258 assert(type < MMDRV_MAX);
259 MMDRV_InitSingleType(type);
261 if (hndl >= llTypes[type].wMaxId &&
262 hndl != (UINT16)-1 && hndl != (UINT)-1) {
263 if (hndl & 0x8000) {
264 UINT idx = hndl & ~0x8000;
265 if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
266 __TRY
268 mld = MM_MLDrvs[idx];
269 if (mld && mld->type != type) mld = NULL;
271 __EXCEPT_PAGE_FAULT
273 mld = NULL;
275 __ENDTRY;
279 if (mld == NULL && bCanBeID) {
280 mld = MMDRV_GetByID(hndl, type);
282 return mld;
285 /**************************************************************************
286 * MMDRV_PhysicalFeatures [internal]
288 UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg,
289 DWORD_PTR dwParam1, DWORD_PTR dwParam2)
291 WINE_MM_DRIVER* lpDrv = &MMDrvs[mld->mmdIndex];
293 TRACE("(%p, %04x, %08lx, %08lx)\n", mld, uMsg, dwParam1, dwParam2);
295 /* all those function calls are undocumented */
296 switch (uMsg) {
297 case DRV_QUERYDRVENTRY:
298 lstrcpynA((LPSTR)dwParam1, lpDrv->drvname, LOWORD(dwParam2));
299 break;
300 case DRV_QUERYDEVNODE:
301 *(LPDWORD)dwParam1 = 0L; /* should be DevNode */
302 break;
303 case DRV_QUERYNAME:
304 WARN("NIY QueryName\n");
305 break;
306 case DRV_QUERYDRIVERIDS:
307 WARN("NIY call VxD\n");
308 /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts
309 * dwParam1 is buffer and dwParam2 is sizeof(buffer)
310 * I don't know where the result is stored though
312 break;
313 case DRV_QUERYMAPPABLE:
314 return (lpDrv->bIsMapper) ? 2 : 0;
316 case DRVM_MAPPER_PREFERRED_GET:
317 /* FIXME: get from registry someday */
318 *((LPDWORD)dwParam1) = -1; /* No preferred device */
319 *((LPDWORD)dwParam2) = 0;
320 break;
322 case DRV_QUERYDEVICEINTERFACE:
323 case DRV_QUERYDEVICEINTERFACESIZE:
324 return MMDRV_Message(mld, uMsg, dwParam1, dwParam2);
326 default:
327 WARN("Unknown call %04x\n", uMsg);
328 return MMSYSERR_INVALPARAM;
330 return 0L;
333 /**************************************************************************
334 * MMDRV_InitPerType [internal]
336 static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
338 WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
339 DWORD ret;
340 UINT count = 0;
341 int i, k;
342 TRACE("(%p, %04x, %04x)\n", lpDrv, type, wMsg);
344 part->nIDMin = part->nIDMax = 0;
346 /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */
347 /* the DRVM_ENABLE is only required when the PnP node is non zero */
348 if (part->fnMessage32) {
349 ret = part->fnMessage32(0, DRVM_INIT, 0L, 0L, 0L);
350 TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret));
351 #if 0
352 ret = part->fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L);
353 TRACE("DRVM_ENABLE => %08lx\n", ret);
354 #endif
355 count = part->fnMessage32(0, wMsg, 0L, 0L, 0L);
357 else return FALSE;
359 TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr);
361 if (HIWORD(count))
362 return FALSE;
364 /* got some drivers */
365 if (lpDrv->bIsMapper) {
366 llTypes[type].nMapper = MMDrvsHi;
367 } else {
368 if (count == 0)
369 return FALSE;
370 part->nIDMin = llTypes[type].wMaxId;
371 llTypes[type].wMaxId += count;
372 part->nIDMax = llTypes[type].wMaxId;
374 TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n",
375 part->nIDMin, part->nIDMax, llTypes[type].wMaxId,
376 lpDrv->drvname, llTypes[type].typestr);
377 /* realloc translation table */
378 if (llTypes[type].lpMlds)
379 llTypes[type].lpMlds = (LPWINE_MLD)
380 HeapReAlloc(GetProcessHeap(), 0, llTypes[type].lpMlds - 1,
381 sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1;
382 else
383 llTypes[type].lpMlds = (LPWINE_MLD)
384 HeapAlloc(GetProcessHeap(), 0,
385 sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1;
387 /* re-build the translation table */
388 if (lpDrv->bIsMapper) {
389 TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, -1, MMDrvs[llTypes[type].nMapper].drvname);
390 llTypes[type].lpMlds[-1].uDeviceID = (UINT)-1;
391 llTypes[type].lpMlds[-1].type = type;
392 llTypes[type].lpMlds[-1].mmdIndex = llTypes[type].nMapper;
393 llTypes[type].lpMlds[-1].dwDriverInstance = 0;
395 for (i = k = 0; i <= MMDrvsHi; i++) {
396 while (MMDrvs[i].parts[type].nIDMin <= k && k < MMDrvs[i].parts[type].nIDMax) {
397 TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, k, MMDrvs[i].drvname);
398 llTypes[type].lpMlds[k].uDeviceID = k;
399 llTypes[type].lpMlds[k].type = type;
400 llTypes[type].lpMlds[k].mmdIndex = i;
401 llTypes[type].lpMlds[k].dwDriverInstance = 0;
402 k++;
405 return TRUE;
408 /**************************************************************************
409 * MMDRV_Install [internal]
411 static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
413 int i, count = 0;
414 LPWINE_MM_DRIVER lpDrv = &MMDrvs[MMDrvsHi];
415 LPWINE_DRIVER d;
416 WINEMM_msgFunc32 func;
418 TRACE("('%s', '%s', mapper=%c);\n", drvRegName, drvFileName, bIsMapper ? 'Y' : 'N');
420 for (i = 0; i < MMDrvsHi; i++) {
421 if (!strcmp(drvRegName, MMDrvs[i].drvname)) return FALSE;
424 /* Be sure that size of MMDrvs matches the max number of loadable
425 * drivers !!
426 * If not just increase size of MMDrvs
428 assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0]));
430 memset(lpDrv, 0, sizeof(*lpDrv));
432 if (!(lpDrv->hDriver = OpenDriverA(drvFileName, 0, 0))) {
433 WARN("Couldn't open driver '%s'\n", drvFileName);
434 return FALSE;
437 d = DRIVER_FindFromHDrvr(lpDrv->hDriver);
439 /* Then look for xxxMessage functions */
440 #define AA(_h,_w,_x,_y,_z) \
441 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
442 if (func != NULL) \
443 { lpDrv->parts[_w].fnMessage##_y = func; count++; \
444 TRACE("Got %d bit func '%s'\n", _y, #_x); }
446 if (d->hModule) {
447 #define A(_x,_y) AA(d->hModule,_x,_y,32,GetProcAddress)
448 A(MMDRV_AUX, auxMessage);
449 A(MMDRV_MIXER, mxdMessage);
450 A(MMDRV_MIDIIN, midMessage);
451 A(MMDRV_MIDIOUT, modMessage);
452 A(MMDRV_WAVEIN, widMessage);
453 A(MMDRV_WAVEOUT, wodMessage);
454 #undef A
456 #undef AA
458 if (!count) {
459 CloseDriver(lpDrv->hDriver, 0, 0);
460 WARN("No message functions found\n");
461 return FALSE;
464 /* FIXME: being a mapper or not should be known by another way */
465 /* it's known for NE drvs (the description is of the form '*mapper: *'
466 * I don't have any clue for PE drvs
468 lpDrv->bIsMapper = bIsMapper;
469 lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName);
471 /* Finish init and get the count of the devices */
472 i = 0;
473 if (MMDRV_InitPerType(lpDrv, MMDRV_AUX, AUXDM_GETNUMDEVS)) i = 1;
474 if (MMDRV_InitPerType(lpDrv, MMDRV_MIXER, MXDM_GETNUMDEVS)) i = 1;
475 if (MMDRV_InitPerType(lpDrv, MMDRV_MIDIIN, MIDM_GETNUMDEVS)) i = 1;
476 if (MMDRV_InitPerType(lpDrv, MMDRV_MIDIOUT, MODM_GETNUMDEVS)) i = 1;
477 if (MMDRV_InitPerType(lpDrv, MMDRV_WAVEIN, WIDM_GETNUMDEVS)) i = 1;
478 if (MMDRV_InitPerType(lpDrv, MMDRV_WAVEOUT, WODM_GETNUMDEVS)) i = 1;
479 /* if all those func calls return FALSE, then the driver must be unloaded */
480 if (!i) {
481 CloseDriver(lpDrv->hDriver, 0, 0);
482 HeapFree(GetProcessHeap(), 0, lpDrv->drvname);
483 WARN("Driver initialization failed\n");
484 return FALSE;
487 MMDrvsHi++;
489 return TRUE;
492 /**************************************************************************
493 * MMDRV_Init
495 static void MMDRV_Init(void)
497 IMMDeviceEnumerator *devenum;
498 IMMDevice *device;
499 IPropertyStore *ps;
500 PROPVARIANT pv;
501 DWORD size;
502 char *drvA;
503 HRESULT init_hr, hr;
505 static const WCHAR wine_info_deviceW[] = {'W','i','n','e',' ',
506 'i','n','f','o',' ','d','e','v','i','c','e',0};
508 TRACE("()\n");
510 init_hr = CoInitialize(NULL);
512 hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
513 CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum);
514 if(FAILED(hr)){
515 ERR("CoCreateInstance failed: %08x\n", hr);
516 goto exit;
519 hr = IMMDeviceEnumerator_GetDevice(devenum, wine_info_deviceW, &device);
520 IMMDeviceEnumerator_Release(devenum);
521 if(FAILED(hr)){
522 ERR("GetDevice failed: %08x\n", hr);
523 goto exit;
526 hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
527 if(FAILED(hr)){
528 ERR("OpenPropertyStore failed: %08x\n", hr);
529 IMMDevice_Release(device);
530 goto exit;
533 hr = IPropertyStore_GetValue(ps,
534 (const PROPERTYKEY *)&DEVPKEY_Device_Driver, &pv);
535 IPropertyStore_Release(ps);
536 IMMDevice_Release(device);
537 if(FAILED(hr)){
538 ERR("GetValue failed: %08x\n", hr);
539 goto exit;
542 size = WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1,
543 NULL, 0, NULL, NULL);
544 drvA = HeapAlloc(GetProcessHeap(), 0, size);
545 WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1, drvA, size, NULL, NULL);
547 MMDRV_Install(drvA, drvA, FALSE);
549 HeapFree(GetProcessHeap(), 0, drvA);
550 PropVariantClear(&pv);
552 MMDRV_Install("wavemapper", "msacm32.drv", TRUE);
553 MMDRV_Install("midimapper", "midimap.dll", TRUE);
555 exit:
556 if(SUCCEEDED(init_hr))
557 CoUninitialize();
560 /******************************************************************
561 * ExitPerType
565 static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type)
567 WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
568 DWORD ret;
569 TRACE("(%p, %04x)\n", lpDrv, type);
571 if (part->fnMessage32) {
572 #if 0
573 ret = part->fnMessage32(0, DRVM_DISABLE, 0L, 0L, 0L);
574 TRACE("DRVM_DISABLE => %08lx\n", ret);
575 #endif
576 ret = part->fnMessage32(0, DRVM_EXIT, 0L, 0L, 0L);
577 TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret));
580 return TRUE;
583 /******************************************************************
584 * Exit
588 void MMDRV_Exit(void)
590 unsigned int i;
591 TRACE("()\n");
593 for (i = 0; i < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]); i++)
595 if (MM_MLDrvs[i] != NULL)
597 FIXME("Closing while ll-driver open\n");
598 #if 0
599 /* FIXME: should generate a message depending on type */
600 MMDRV_Free((HANDLE)(i | 0x8000), MM_MLDrvs[i]);
601 #endif
605 /* unload driver, in reverse order of loading */
606 i = sizeof(MMDrvs) / sizeof(MMDrvs[0]);
607 while (i-- > 0)
609 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_AUX);
610 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_MIXER);
611 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_MIDIIN);
612 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_MIDIOUT);
613 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_WAVEIN);
614 MMDRV_ExitPerType(&MMDrvs[i], MMDRV_WAVEOUT);
615 CloseDriver(MMDrvs[i].hDriver, 0, 0);
617 if (llTypes[MMDRV_AUX].lpMlds)
618 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_AUX].lpMlds - 1);
619 if (llTypes[MMDRV_MIXER].lpMlds)
620 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIXER].lpMlds - 1);
621 if (llTypes[MMDRV_MIDIIN].lpMlds)
622 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIIN].lpMlds - 1);
623 if (llTypes[MMDRV_MIDIOUT].lpMlds)
624 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIOUT].lpMlds - 1);
625 if (llTypes[MMDRV_WAVEIN].lpMlds)
626 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEIN].lpMlds - 1);
627 if (llTypes[MMDRV_WAVEOUT].lpMlds)
628 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEOUT].lpMlds - 1);